[PATCH] D59594: [ELF] Change GOT*_FROM_END (relative to end(.got)) to GOTPLT* (start(.got.plt))
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 20 03:15:42 PDT 2019
MaskRay created this revision.
MaskRay added reviewers: ruiu, sivachandra.
Herald added subscribers: llvm-commits, jdoerfert, dexonsmith, arichardson, mehdi_amini, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.
This should address remaining issues discussed in PR36555.
Currently R_GOT*_FROM_END are exclusively used by x86 and x86_64 to
express relocations types relative to the GOT base. We have
_GLOBAL_OFFSET_TABLE_ (GOT base) = start(.got.plt) but end(.got) !=
start(.got.plt)
This can have problems when _GLOBAL_OFFSET_TABLE_ is used as a symbol, e.g.
glibc dl_machine_dynamic assumes _GLOBAL_OFFSET_TABLE_ is start(.got.plt),
which is not true.
extern const ElfW(Addr) _GLOBAL_OFFSET_TABLE_[] attribute_hidden;
return _GLOBAL_OFFSET_TABLE_[0]; // R_X86_64_GOTPC32
In this patch, we
- Change all GOT*_FROM_END to GOTPLT* to fix the problem.
- Add HasGotPltOffRel to denote whether .got.plt should be kept even if the section is empty.
- Simply GotSection::empty and GotPltSection::empty a bit by setting HasGotOffRel and HasGotPltOffRel early.
The change of R_386_GOTPC makes X86::writePltHeader simpler as we don't
have to compute the offset start(.got.plt) - Ebx (it is constant 0).
We still diverge from ld.bfd (at least in most cases) and gold in that
.got.plt and .got are not adjacent, but the advantage doing that is
unclear.
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D59594
Files:
ELF/Arch/X86.cpp
ELF/Arch/X86_64.cpp
ELF/InputSection.cpp
ELF/Relocations.cpp
ELF/Relocations.h
ELF/SyntheticSections.cpp
ELF/SyntheticSections.h
ELF/Writer.cpp
test/ELF/got-i386.s
test/ELF/i386-gotoff-shared.s
test/ELF/i386-gotpc-dynamic.s
test/ELF/i386-gotpc.s
test/ELF/i386-retpoline-pic-linkerscript.s
test/ELF/i386-retpoline-pic.s
test/ELF/plt-i686.s
test/ELF/relocation-i686.s
test/ELF/shared.s
test/ELF/tls-dynamic-i686.s
test/ELF/x86-64-reloc-gotoff64.s
test/ELF/x86-64-reloc-gotpc64.s
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59594.191466.patch
Type: text/x-patch
Size: 25538 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190320/838e6aec/attachment.bin>
More information about the llvm-commits
mailing list