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

Job Noorman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 2 05:35:14 PDT 2023


jobnoorman marked 3 inline comments as done.
jobnoorman added a comment.

In D159082#4635795 <https://reviews.llvm.org/D159082#4635795>, @MaskRay wrote:

> GNU ld changes `R_RISCV_RELAX` to `R_RISCV_NONE`. I think keeping `R_RISCV_RELAX` is better. Projects depending on the relocation type should be aware.

GNU ld seems to keep `R_RISCV_RELAX` but changes `R_RISCV_ALIGN` to `R_RISCV_NONE`:

  $ riscv64-linux-gnu-gcc -nostdlib -Wl,--emit-relocs,-Ttext=0x10000 lld/test/ELF/riscv-relax-emit-relocs.s
  $ riscv64-linux-gnu-objdump -dr a.out
  
  a.out:     file format elf64-littleriscv
  
  
  Disassembly of section .text:
  
  0000000000010000 <_start>:
     10000:	008000ef          	jal	ra,10008 <f>
  			10000: R_RISCV_JAL	f
  			10000: R_RISCV_RELAX	*ABS*
     10004:	004000ef          	jal	ra,10008 <f>
  			10004: R_RISCV_JAL	f
  			10004: R_RISCV_RELAX	*ABS*
  
  0000000000010008 <f>:
     10008:	8082                	ret
  			10008: R_RISCV_NONE	*ABS*+0x6

I can see the logic of removing `R_RISCV_ALIGN` since it doesn't make too much sense anymore once the padding nops are removed. Do you think we should follow this behavior? The current version of the patch keeps it which at least allows analysis tools to recover the original alignment requirements.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159082



More information about the llvm-commits mailing list