Unlike R_RISCV_RELAX, which is a linker hint, R_RISCV_ALIGN requires the
support of the linker even when ignoring all R_RISCV_RELAX relocations.
This is because the compiler emits as many NOPs as may be required for
the requested alignment, more than may be required pre-relaxation, to
allow for the target becoming more unaligned after relaxing earlier
sequences. This means that the target is often not initially aligned in
the object files, and so the R_RISCV_ALIGN relocations cannot just be
ignored. Since we do not support linker relaxation, we must turn these
into errors.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
lld/ELF/Arch/RISCV.cpp | ||
---|---|---|
240–247 | I think R_HINT is not useful, so I created D71822. | |
245 | If you think there are needs (which I think so) to test lld on existing R_RISCV_ALIGN relocations, | |
443 | Full stop, though the examples above and below (they are inconsistent with other places) do not use it... | |
lld/test/ELF/riscv-reloc-align.s | ||
4 | -unknown-elf is implied, I think. | |
5 | -o /dev/null |
lld/ELF/Arch/RISCV.cpp | ||
---|---|---|
240–247 | It might be if LLD learns RISC-V's linker relaxations, although that could instead be a new R_RELAX (or RISC-V specific type). I can rebase if your patch is going to land first. | |
245 | I guess it does no harm, given --noinhibit-exec is a debugging option rather than intended for users (for whom this should definitely be an error). | |
443 | Even for phrases that aren't complete sentences? | |
lld/test/ELF/riscv-reloc-align.s | ||
4 | Yeah, not that it even matters which is used; the tests are inconsistent and I copied from one that happened to spell it in full. Will make shorter. |
I see you've already committed the RISC-V parts of that, so the dependency no longer exists.
If you think there are needs (which I think so) to test lld on existing R_RISCV_ALIGN relocations,
use errorOrWarn so that errors can be downgraded to warnings with --noinhibit-exec.