Simplify and make the pair-wise relocation more precise. If either of
the symbol references are textual, the relocation must be delayed. If
the difference is across sections, delay it as well which partially
matches the behaviour of gas. We unfortunately do not handle the case
where the difference references a symbol that is not yet defined. In
such a case, we simply fail to resolve the difference, which should
hopefully not be too onerous (particularly since no other target
supports cross-section references and it is not clear if this was
intentional on the part of RISCV).
Details
- Reviewers
MaskRay - Commits
- rG519a73111b40: RISCV: adjust relocation emission
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Is this patch ready for review? Is there any more background on the need for this change?
llvm/test/MC/RISCV/riscv64-64b-pcrel.s | ||
---|---|---|
1 | You can guard negative tests with macros so that the positive tests can use llvm-mc return code of 0. llvm-mc supports --defsym. I have added some tests using --defsym ERR=1. |
It would've been nice if you asked for review once this was ready... as far as we're concerned it was still parked and not ready for review
The description says
We unfortunately do not handle the case where the difference references a symbol that is not yet defined. In such a case, we simply fail to resolve the difference, which should hopefully not be too onerous ...
Android riscv64 nterp: Fix "oat" code size calculation. is an instance to work around suppressed R_RISCV_ADD32/R_RISCV_SUB32. It reduces to:
# Both end and begin are not defined yet. We decide ADD/SUB relocations upfront and don't know they will be needed. .4byte end-begin begin: call foo end:
I have elaborated this in my notes (https://maskray.me/blog/2021-03-14-the-dark-side-of-riscv-linker-relaxation "Label differences related to text section symbols") and will think about improvements in my free time.
D145474: Ideally we should delay the decision of PC-relative ...
You can guard negative tests with macros so that the positive tests can use llvm-mc return code of 0.
llvm-mc supports --defsym. I have added some tests using --defsym ERR=1.