[PATCH] D159082: [ELF][RISCV] Implement --emit-relocs with relaxation

Job Noorman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 4 01:42:17 PDT 2023


jobnoorman updated this revision to Diff 555688.
jobnoorman added a comment.

Emit R_RISCV_NONE instead of R_RISCV_ALIGN since the latter would be invalid
once padding nops are removed. This is also consistent with the behavior of GNU
ld.

Note that I set the addend of R_RISCV_NONE to zero since the addend doesn't have
any meaning here. However, this is //not// consistent with GNU ld, which has an
addend but its value is a bit mysterious to me (it's not the same as the
original R_RISCV_ALIGN).

Note that I would have liked to be able to implement this in RISC-V specific
code (e.g., in `riscvFinalizeRelax`). This proved problematic, however, since
with --no-relax, R_RISCV_RELAX relocations will not be added to
`InputSectionBase::relocations`. Since we still want to emit those relocations,
`copyRelocations` cannot use the `relocations` array when --no-relax is used but
instead has to copy them directly from the input section. Therefore, I ended up
changing R_RISCV_ALIGN to R_RISCV_NONE inside `copyRelocations`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D159082/new/

https://reviews.llvm.org/D159082

Files:
  lld/ELF/InputSection.cpp
  lld/ELF/InputSection.h
  lld/test/ELF/riscv-relax-emit-relocs.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D159082.555688.patch
Type: text/x-patch
Size: 8130 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230904/50fe226e/attachment.bin>


More information about the llvm-commits mailing list