[all-commits] [llvm/llvm-project] 82b436: [llvm-readobj] Print <null> for relocation target ...

Fangrui Song via All-commits all-commits at lists.llvm.org
Thu Jul 20 00:42:52 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 82b4368f7f89e2b16b9eb09787b7a7af07e3b7cd
      https://github.com/llvm/llvm-project/commit/82b4368f7f89e2b16b9eb09787b7a7af07e3b7cd
  Author: Fangrui Song <i at maskray.me>
  Date:   2023-07-20 (Thu, 20 Jul 2023)

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

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

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
```

Reviewed By: jhenderson, kito-cheng

Differential Revision: https://reviews.llvm.org/D155353




More information about the All-commits mailing list