[RISCV] Ignore addend in R_RISCV_GOT_HI20#1429
[RISCV] Ignore addend in R_RISCV_GOT_HI20#1429Jonathon Penix (jonathonpenix) wants to merge 4 commits into
Conversation
|
I did a bit of background research and it's likely all the other |
Thanks Sam Elliott (@lenary). Can we raise an issue to update the ABI ? |
Yes, I intend to. I just need to finish reading about how tls gd works in LLD to make sure my understanding is right. |
|
Thanks Sam for filing the issue in the psABI! As I don't think there's been movement in the psABI, does anyone have concerns about keeping this patch limited to just I'll update this PR as the GOT relaxations have since been merged (which, there's some interaction here I think), but waiting on #1428 to save some rebasing. But if we'd rather wait for further changes in the psABI, etc. I can put this on hold. |
This was recently changed in the psABI to require the addend be non-zero [1]. Handle this similarly to other relocations that must have zero addends by just ignoring the addend (setting it to zero) and producing a warning. Note that the calculation in `applyGOT` is left unchanged (the `+ A` is still there). `applyGOT` is shared with some other GOT-relative relocations that have no explicit zero addend requirement and eld/lld/bfd all seem to a) accept those addends b) honor those addends and c) not produce a diagnostic. So for now, I think it is a bit clearer to keep `R_RISCV_GOT_HI20` using `applyGOT` and just make sure we zero the addend ahead of time. [1] riscv-non-isa/riscv-elf-psabi-doc@eb794e8 Signed-off-by: Jonathon Penix <[email protected]>
Signed-off-by: Jonathon Penix <[email protected]>
1. Switch to asserts that the addends are 0 now that eld will 0 out these addends 2. Fix tests--since we zero out the non-zero addends, relaxation can happen. Signed-off-by: Jonathon Penix <[email protected]>
0b1aba8 to
1a92cae
Compare
|
Rebased to unstack after merging #1428 + added some fixups of some of the GOT relaxation stuff. |
Signed-off-by: Jonathon Penix <[email protected]>
This was recently changed in the psABI to require the addend be non-zero [1].
Handle this similarly to other relocations that must have zero addends by just
ignoring the addend (setting it to zero) and producing a warning.
Note that the calculation in
applyGOTis left unchanged (the+ Ais stillthere).
applyGOTis shared with some other GOT-relative relocations that haveno explicit zero addend requirement and eld/lld/bfd all seem to a) accept those
addends b) honor those addends and c) not produce a diagnostic.
So for now, I think it is a bit clearer to keep
R_RISCV_GOT_HI20usingapplyGOTand just make sure we zero the addend ahead of time.Since we're 0-ing the addend ahead of time, switch the GOT relaxations
to asserting on non-0 addends rather than returning. It's a bit unrelated,
but the assert was also extended to cover both the got_hi and pcrel_lo
(as both must have 0 addends).
[1] riscv-non-isa/riscv-elf-psabi-doc@eb794e8
Fixes: #1413