[all-commits] [llvm/llvm-project] 42e496: [ELF] Don't create copy relocation/canonical PLT e...

Fangrui Song via All-commits all-commits at lists.llvm.org
Tue Dec 12 10:14:49 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 42e4967140e345923a43f809ba69be57200f46ae
      https://github.com/llvm/llvm-project/commit/42e4967140e345923a43f809ba69be57200f46ae
  Author: Fangrui Song <i at maskray.me>
  Date:   2023-12-12 (Tue, 12 Dec 2023)

  Changed paths:
    M lld/ELF/Relocations.cpp
    M lld/test/ELF/got32-i386.s
    M lld/test/ELF/got32x-i386.s
    M lld/test/ELF/x86-64-dyn-rel-error.s

  Log Message:
  -----------
  [ELF] Don't create copy relocation/canonical PLT entry for a defined symbol (#75095)

Copy relocations and canonical PLT entries are for symbols defined in a
DSO. Currently we create them even for a `Defined`, possibly leading to
an output that won't work at run-time (e.g. R_X86_64_JUMP_SLOT
referencing a null symbol).
```
% cat a.s
.globl _start, main
.type main, @function
_start: main: ret

.rodata
.quad main
% clang -fuse-ld=lld -pie -nostdlib a.s
% readelf -Wr a.out

Relocation section '.rela.plt' at offset 0x290 contains 1 entry:
    Offset             Info             Type               Symbol's Value  Symbol's Name + Addend
00000000000033b8  0000000000000007 R_X86_64_JUMP_SLOT                        12b0
```

Report an error instead for the default `-z text` mode. GNU ld reports
an error in `-z text` mode as well.




More information about the All-commits mailing list