-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modify the Linker Script #19
Comments
Definitely! You can copy the linker script from the corresponding |
So this line |
Change it to:
(you also need to include memory definitions before the linker script) |
Will I need to modify the memory-hifive1-revb.x too, or just the linker? |
Only if you need a different memory layout or you do not have a bootloader. |
Are the region alias' sensitive to renaming? For example, keeping U and M level code separate wouldn't I need to have a .textM and a .textU etc? Maybe I can build and run my M level code with one linker and memory file (original). Then once completed, build and run the U level code with a modified linker and memory file that has different memory addresses. Or should this be a single process with some kind of compile time flags/switches? |
Region aliases are different things, they were added to prevent hardcoding |
I've never done this before, obviously. How completely nuts does this look? INCLUDE memory-fe310.x REGION_ALIAS("REGION_MTEXT", MFLASH); REGION_ALIAS("REGION_UTEXT", UFLASH); /Skip first 64k allocated for bootloader/ |
You don't need the first INCLUDE as you defined your own RAM regions, but other things look sane |
Wow, really? LOL, cool. Obviously, I can tweak the region sizes a bit to not waste space, just divided everything in half to start. I will get rid of the include line. Next, I need to modify the link.x file to handle these regions, correct? |
Correct. Or you can create two different memory.x files, one for M-mode and one for U-mode and use them to link two different binaries with the same (possibly modified) link.x file. |
Right, that makes sense. If I did that, then I wouldn't need the change the region names just the memory boundaries. I would also have to $cargo run twice this way. Once to load m-mode stuff, and once to load the u-mode stuff? |
Yes, you're right. |
I really appreciate your help! |
One more thought. I plan on entering the user mode memory section by setting the stack pointer address and changing to u mode. When I write my user mode code, I don't need an #[entry] attribute point included, just in the machine mode code. That should allow the machine code to be called on start up, then I will use the mret process to move into the user mode portion from m-mode. Should that work? |
Probably you need to write your own startup code for the user mode and place it somewhere (beginning of the user mode |
I see what you are saying. |
Nope, the problem is the quickstart template is adding the -Thifive1-link.x argument which calls the hifive-memory.x file then link.x linker. I think I can just do this |
This seems to be working, but the ram doesn't start at the origin I define, it always puts it at 0x80000000. |
Strange, try to rebuild the project. Sometimes these script files don't get updated and linker uses the old version. |
Yahoo! That worked. I ran |
Is it possible to modify the linker script on my project? I want to keep all machine mode and user mode functions separated in memory. I thought that I might can build the machine code and the user code separately, then change the linker script somehow to load them into separate memory locations. Then I can use the PMP to sandbox my user mode operation.
The text was updated successfully, but these errors were encountered: