-
Notifications
You must be signed in to change notification settings - Fork 747
Fix something that was not the root cause of relocation bug from #2219 at the time, the root cause was a bug in LLD, and now that bug is fixed, so we can use the canonical way of ensuring the relocation section has a predictable LMA #4108
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
Conversation
I think this missed a file in git. Only the makefile change is here (though, the PR description certainly makes sense for what should also be here I think) |
This is frustrating because we are just going in circles. I don't trust the LLVM linker. #2816 In the past we changed this because things broke. Now we are changing it because it seems wrong. |
Currently we rely on `-nmagic` for the linker not to do funny things with the beginning of the relocation section such that it always actually is stored starting at `_etext`. This is a hack. Instead, we can force the load-memory-address (LMA) of the relocate section to be exactly `_etext` using `AT (_etext)`. see <https://sourceware.org/binutils/docs/ld/Output-Section-LMA.html>
69dab0c
to
334d7af
Compare
Is the premise of this PR that the LLVM linker is fixed? This PR is really just reverting e17d4ac |
This does seem to be explicitly supported in As far as I can tell this was a bug in ARM targets (https://bugs.llvm.org/show_bug.cgi?id=45313 https://bugs.llvm.org/show_bug.cgi?id=38776) that was fixed (llvm/llvm-project@bb4a36e). |
Technically reverting except retaining the whitespace fixes :) |
Man, we almost didn't have to deal with this bug; latency of rust pulling llvm releases I imagine :/. Looks like a reasonable thing to revert assuming nothing else changes. I imagine we could just compile all the boards on both sides of this patch and diff the output of |
I'm ok with this if we change the PR title. This was in the tree at the time of the issue Line 255 in 7c2bf67
yet, well, here we are. A lot of debugging went into making the linker work and making Tock without additional dependencies. It's not as simple as just saying one line of a linker script was the root cause. |
@bradjc New title, tell me what you think. Feel free to adjust however you like |
Pull Request Overview
This pull request fixes the actual root cause of #2219 and fixed originally in #2336
Currently we rely on
-nmagic
for the linker not to do funny things with the beginning of the relocation section such that it always actually is stored starting at_etext
. This is a hack. Instead, we can force the load-memory-address (LMA) of the relocate section to be exactly_etext
usingAT (_etext)
.see https://sourceware.org/binutils/docs/ld/Output-Section-LMA.html
Testing Strategy
This is compile tested. In practice, this doesn't actually remove
-nmagic
since that's still nice to have (the linker won't inject zero padding unnecessarily to the binary).I validated that this precisely places the relocation section by removing
-nmagic
, and also by modifying theAT (_etext)
statement to be various offsets from_etext
and manually inspecting the binary.TODO or Help Wanted
N/A
Documentation Updated
/docs
, or no updates are required.Formatting
make prepush
.