Open hjl-tools opened 7 years ago
mentioned in issue llvm/llvm-bugzilla-archive#48621
mentioned in issue llvm/llvm-bugzilla-archive#48621
mentioned in issue llvm/llvm-bugzilla-archive#37257
Bug llvm/llvm-bugzilla-archive#37257 has been marked as a duplicate of this bug.
see pr37257.
This has been noticed in the wild.
Also, fixing this might prove a memory saving optimization as no symbol would be both at the .got and .plt.got and we would not need to keep both indexes.
We are not going to implement this, according to comments at D37333 review page.
Posted draft WIP version of fix here: https://reviews.llvm.org/D37333
Bug llvm/llvm-project#28346 has been marked as a duplicate of this bug.
OK. Mine was GNU ld (GNU Binutils for Ubuntu) 2.24.
Actually I got the same result with ld.bfd. What am I missing?
$ /ssd/clang/bin/clang -fpic -c -o x.o x.c $ ld.bfd --shared -o x.so x.o $ readelf -r x.so
Relocation section '.rela.dyn' at offset 0x220 contains 1 entries: Offset Info Type Sym. Value Sym. Name + Addend 000000200408 000400000006 R_X86_64_GLOB_DAT 0000000000000000 foo + 0
Relocation section '.rela.plt' at offset 0x238 contains 1 entries: Offset Info Type Sym. Value Sym. Name + Addend 000000200428 000400000007 R_X86_64_JUMP_SLO 0000000000000000 foo + 0
Which ld.bfd were you using? Please try binutils 2.28.
Actually I got the same result with ld.bfd. What am I missing?
$ /ssd/clang/bin/clang -fpic -c -o x.o x.c $ ld.bfd --shared -o x.so x.o $ readelf -r x.so
Relocation section '.rela.dyn' at offset 0x220 contains 1 entries: Offset Info Type Sym. Value Sym. Name + Addend 000000200408 000400000006 R_X86_64_GLOB_DAT 0000000000000000 foo + 0
Relocation section '.rela.plt' at offset 0x238 contains 1 entries: Offset Info Type Sym. Value Sym. Name + Addend 000000200428 000400000007 R_X86_64_JUMP_SLO 0000000000000000 foo + 0
What is your lld version? I cannot reproduce the issue.
$ readelf -r x.so
Relocation section '.rela.dyn' at offset 0x240 contains 1 entries: Offset Info Type Sym. Value Sym. Name + Addend 0000000030d0 000100000006 R_X86_64_GLOB_DAT 0000000000000000 foo + 0
Relocation section '.rela.plt' at offset 0x258 contains 1 entries: Offset Info Type Sym. Value Sym. Name + Addend 000000002018 000100000007 R_X86_64_JUMP_SLO 0000000000000000 foo + 0
There is 2 dynamic relocations against the same symbol, foo, for 2 GOT entries. Only one GOT entry and one dynamic relocation are required.
What is your lld version? I cannot reproduce the issue.
$ readelf -r x.so
Relocation section '.rela.dyn' at offset 0x240 contains 1 entries: Offset Info Type Sym. Value Sym. Name + Addend 0000000030d0 000100000006 R_X86_64_GLOB_DAT 0000000000000000 foo + 0
Relocation section '.rela.plt' at offset 0x258 contains 1 entries: Offset Info Type Sym. Value Sym. Name + Addend 000000002018 000100000007 R_X86_64_JUMP_SLO 0000000000000000 foo + 0
Extended Description
[hjl@gnu-6 lld-2]$ cat x.c extern void foo (void);
void * foo_p () { foo (); return foo; } [hjl@gnu-6 lld-2]$ make ./clang -fpic -c -o x.o x.c ./ld.lld --shared -o x.so x.o [hjl@gnu-6 lld-2]$ readelf -r x.so
Relocation section '.rela.dyn' at offset 0x240 contains 1 entries: Offset Info Type Sym. Value Sym. Name + Addend 0000000030d0 000100000006 R_X86_64_GLOB_DAT 0000000000000000 foo + 0
Relocation section '.rela.plt' at offset 0x258 contains 1 entries: Offset Info Type Sym. Value Sym. Name + Addend 000000002018 000100000007 R_X86_64_JUMP_SLO 0000000000000000 foo + 0 [hjl@gnu-6 lld-2]$ ld --shared -o x.so x.o [hjl@gnu-6 lld-2]$ readelf -r x.so
Relocation section '.rela.dyn' at offset 0x240 contains 1 entries: Offset Info Type Sym. Value Sym. Name + Addend 000000200ff8 000300000006 R_X86_64_GLOB_DAT 0000000000000000 foo + 0 [hjl@gnu-6 lld-2]$