llvm-project/lld/ELF
Fangrui Song 210949a221 [ELF] Change GOT*_FROM_END (relative to end(.got)) to GOTPLT* (start(.got.plt))
Summary:
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.
* Simplify GotSection::empty and GotPltSection::empty by setting
  HasGotOffRel and HasGotPltOffRel according to GlobalOffsetTable 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.

Reviewers: ruiu, sivachandra, espindola

Subscribers: emaste, mehdi_amini, arichardson, dexonsmith, jdoerfert, llvm-commits

Tags: #llvm

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

llvm-svn: 356968
2019-03-25 23:46:19 +00:00
..
Arch [ELF] Change GOT*_FROM_END (relative to end(.got)) to GOTPLT* (start(.got.plt)) 2019-03-25 23:46:19 +00:00
AArch64ErrataFix.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
AArch64ErrataFix.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
CMakeLists.txt Fail early if an output file is not writable 2019-03-11 16:30:55 +00:00
CallGraphSort.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
CallGraphSort.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Config.h Reland "[Remarks] Add -foptimization-record-passes to filter remark emission" 2019-03-12 21:22:27 +00:00
DWARF.cpp [DWARF] Refactor RelocVisitor and fix computation of SHT_RELA-typed relocation entries 2019-03-22 02:43:17 +00:00
DWARF.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Driver.cpp [ELF] De-virtualize findOrphanPos, excludeLibs and handleARMTlsRelocation 2019-03-17 13:53:42 +00:00
Driver.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
DriverUtils.cpp Remove a function from header and move the implementation to a .cpp file. NFC. 2019-02-22 23:59:43 +00:00
EhFrame.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
EhFrame.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ICF.cpp COFF, ELF: ICF: Perform 2 rounds of relocation hash propagation. 2019-01-22 23:54:49 +00:00
ICF.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
InputFiles.cpp [ELF] Print a better error for an archive containing a non-ELF file. 2019-03-12 01:24:39 +00:00
InputFiles.h LLD/AMDGPU: Preserve ABI version during linking ELF for AMDGPU 2019-02-14 23:59:44 +00:00
InputSection.cpp [ELF] Change GOT*_FROM_END (relative to end(.got)) to GOTPLT* (start(.got.plt)) 2019-03-25 23:46:19 +00:00
InputSection.h ELF: Use bump pointer allocator for uncompressed section buffers. NFCI. 2019-03-12 20:32:30 +00:00
LTO.cpp Reland "[Remarks] Add -foptimization-record-passes to filter remark emission" 2019-03-12 21:22:27 +00:00
LTO.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
LinkerScript.cpp ELF: Simplify. NFCI. 2019-03-12 19:19:23 +00:00
LinkerScript.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
MapFile.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
MapFile.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
MarkLive.cpp Use a class instead of lambda-based callbacks to organize garbage collector. 2019-03-25 23:28:47 +00:00
MarkLive.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Options.td Reland "[Remarks] Add -foptimization-record-passes to filter remark emission" 2019-03-12 21:22:27 +00:00
OutputSections.cpp [ELF][ARM] Revert Redesign of .ARM.exidx handling to use a SyntheticSection 2019-03-21 17:17:54 +00:00
OutputSections.h [ELF] Delete unused forward declarations and unused DynamicReloc::getInputSec(). NFC 2019-03-15 07:16:39 +00:00
README.md Update the documents of the new LLD. 2016-03-12 06:06:40 +00:00
Relocations.cpp [ELF] Change GOT*_FROM_END (relative to end(.got)) to GOTPLT* (start(.got.plt)) 2019-03-25 23:46:19 +00:00
Relocations.h [ELF] Change GOT*_FROM_END (relative to end(.got)) to GOTPLT* (start(.got.plt)) 2019-03-25 23:46:19 +00:00
ScriptLexer.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ScriptLexer.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ScriptParser.cpp Recover elf32-bigmips and elf32-powerpc support in LLD 2019-02-13 18:51:15 +00:00
ScriptParser.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
SymbolTable.cpp [ELF] Support --{,no-}allow-shlib-undefined 2019-02-01 02:25:05 +00:00
SymbolTable.h [ELF] Support --{,no-}allow-shlib-undefined 2019-02-01 02:25:05 +00:00
Symbols.cpp [ELF] Emit weak-undef symbols in .dynsym of a PIE binary only if linked against shared libs. 2019-03-18 15:32:57 +00:00
Symbols.h [ELF] Delete unused forward declarations and unused DynamicReloc::getInputSec(). NFC 2019-03-15 07:16:39 +00:00
SyntheticSections.cpp [ELF] Change GOT*_FROM_END (relative to end(.got)) to GOTPLT* (start(.got.plt)) 2019-03-25 23:46:19 +00:00
SyntheticSections.h [ELF] Change GOT*_FROM_END (relative to end(.got)) to GOTPLT* (start(.got.plt)) 2019-03-25 23:46:19 +00:00
Target.cpp ELF: Write .eh_frame_hdr explicitly after writing .eh_frame. 2019-02-28 23:11:35 +00:00
Target.h [PPC64] Sort .toc sections accessed with small code model relocs. 2019-02-12 15:35:49 +00:00
Thunks.cpp [mips] Remove redundant setup of less-significant bit. NFC 2019-03-13 16:00:35 +00:00
Thunks.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Writer.cpp [ELF] Change GOT*_FROM_END (relative to end(.got)) to GOTPLT* (start(.got.plt)) 2019-03-25 23:46:19 +00:00
Writer.h [ELF] Delete unused forward declarations and unused DynamicReloc::getInputSec(). NFC 2019-03-15 07:16:39 +00:00

README.md

See docs/NewLLD.rst