[PATCH] D155353: [llvm-readobj] Print <null> for relocation target with an empty name

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 14 20:07:01 PDT 2023


MaskRay created this revision.
MaskRay added reviewers: asb, jhenderson, jrtc27, kito-cheng.
Herald added subscribers: luke, frasercrmck, luismarques, apazos, sameer.abuasal, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, atanasyan, edward-jones, zzheng, niosHD, sabuasal, simoncook, johnrusso, rbar, arichardson, emaste.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added subscribers: llvm-commits, wangpc.
Herald added a project: LLVM.

For a relocation, we don't differentiate the two cases:

- the symbol index is 0
- the symbol index is non zero, the type is not STT_SECTION, and the name is empty. Clang generates such local symbols for RISC-V linker relaxation.

So we may print

      Offset             Info             Type               Symbol's Value  Symbol's Name + Addend
  000000000000001c  0000000100000039 R_RISCV_32_PCREL       0000000000000000 0
  
  // llvm-readobj
  0x1C R_RISCV_32_PCREL - 0x0

while GNU readelf prints "<null>", which is clearer. Let's match the GNU behavior.
Related to https://reviews.llvm.org/D81842

  000000000000001c  0000000100000039 R_RISCV_32_PCREL       0000000000000000 <null> + 0
  
  // llvm-readobj
  0x1C R_RISCV_32_PCREL <null> 0x0


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D155353

Files:
  lld/test/ELF/mips-eh_frame-pic.s
  llvm/test/CodeGen/RISCV/fixups-diff.ll
  llvm/test/DebugInfo/RISCV/dwarf-riscv-relocs.ll
  llvm/test/DebugInfo/RISCV/relax-debug-frame.ll
  llvm/test/MC/ELF/RISCV/gen-dwarf.s
  llvm/test/MC/RISCV/cfi-advance.s
  llvm/test/MC/RISCV/fde-reloc.s
  llvm/test/MC/RISCV/scoped-relaxation.s
  llvm/test/tools/llvm-readobj/ELF/reloc-zero-name-or-value.test
  llvm/test/tools/yaml2obj/ELF/symbol-name.yaml
  llvm/tools/llvm-readobj/ELFDumper.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155353.540626.patch
Type: text/x-patch
Size: 12740 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230715/eb4dff38/attachment.bin>


More information about the llvm-commits mailing list