hanchenye-llvm-project/lld/ELF
Fangrui Song 82442adfc0 [PPC32] Improve the 32-bit PowerPC port
Many -static/-no-pie/-shared/-pie applications linked against glibc or musl
should work with this patch. This also helps FreeBSD PowerPC64 to migrate
their lib32 (PR40888).

* Fix default image base and max page size.
* Support new-style Secure PLT (see below). Old-style BSS PLT is not
  implemented, so it is not suitable for FreeBSD rtld now because it doesn't
  support Secure PLT yet.
* Support more initial relocation types:
  R_PPC_ADDR32, R_PPC_REL16*, R_PPC_LOCAL24PC, R_PPC_PLTREL24, and R_PPC_GOT16.
  The addend of R_PPC_PLTREL24 is special: it decides the call stub PLT type
  but it should be ignored for the computation of target symbol VA.
* Support GNU ifunc
* Support .glink used for lazy PLT resolution in glibc
* Add a new thunk type: PPC32PltCallStub that is similar to PPC64PltCallStub.
  It is used by R_PPC_REL24 and R_PPC_PLTREL24.

A PLT stub used in -fPIE/-fPIC usually loads an address relative to
.got2+0x8000 (-fpie/-fpic code uses _GLOBAL_OFFSET_TABLE_ relative
addresses).
Two .got2 sections in two object files have different addresses, thus a PLT stub
can't be shared by two object files. To handle this incompatibility,
change the parameters of Thunk::isCompatibleWith to
`const InputSection &, const Relocation &`.

PowerPC psABI specified an old-style .plt (BSS PLT) that is both
writable and executable. Linkers don't make separate RW- and RWE segments,
which causes all initially writable memory (think .data) executable.
This is a big security concern so a new PLT scheme (secure PLT) was developed to
address the security issue.

TLS will be implemented in D62940.

glibc older than ~2012 requires .rela.dyn to include .rela.plt, it can
not handle the DT_RELA+DT_RELASZ == DT_JMPREL case correctly. A hack
(not included in this patch) in LinkerScript.cpp addOrphanSections() to
work around the issue:

    if (Config->EMachine == EM_PPC) {
      // Older glibc assumes .rela.dyn includes .rela.plt
      Add(In.RelaDyn);
      if (In.RelaPlt->isLive() && !In.RelaPlt->Parent)
        In.RelaDyn->getParent()->addSection(In.RelaPlt);
    }

Reviewed By: ruiu

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

llvm-svn: 362721
2019-06-06 17:03:00 +00:00
..
Arch [PPC32] Improve the 32-bit PowerPC port 2019-06-06 17:03:00 +00:00
AArch64ErrataFix.cpp Use llvm::stable_sort 2019-04-23 02:42:06 +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 Use llvm::stable_sort 2019-04-23 02:42:06 +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 Read .note.gnu.property sections and emit a merged .note.gnu.property section. 2019-06-05 03:04:46 +00:00
DWARF.cpp Reland D61583 [ELF] Error on relocations to STT_SECTION symbols if the sections were discarded 2019-05-28 14:34:28 +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 [lld] Explicitly ignore comdat groups when parsing LTO object(s) 2019-06-05 17:39:37 +00:00
Driver.h Move SymbolTable::addCombinedLTOObject() to LinkerDriver. 2019-05-23 09:26:27 +00:00
DriverUtils.cpp [ELF] Implement Dependent Libraries Feature 2019-05-17 03:44:15 +00:00
EhFrame.cpp [ELF][MachO][wasm] Simplify range-style std::find{,_if} with STLExtras.h utilities. NFC 2019-03-29 16:21:16 +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 ELF: Add basic partition data structures and behaviours. 2019-05-29 03:55:20 +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 [lld] Explicitly ignore comdat groups when parsing LTO object(s) 2019-06-05 17:39:37 +00:00
InputFiles.h [PPC32] Improve the 32-bit PowerPC port 2019-06-06 17:03:00 +00:00
InputSection.cpp [PPC32] Improve the 32-bit PowerPC port 2019-06-06 17:03:00 +00:00
InputSection.h ELF: Add basic partition data structures and behaviours. 2019-05-29 03:55:20 +00:00
LTO.cpp Use SymbolTable::insert() to implement --trace. 2019-05-28 06:33:06 +00:00
LTO.h [ELF] Reorder BitcodeFiles.empty() to call thinLTOCreateEmptyIndexFiles() in only one place 2019-05-07 10:40:26 +00:00
LinkerScript.cpp ELF: Introduce a separate bit for tracking whether an output section has ever had an input section added to it. NFCI. 2019-06-03 20:14:25 +00:00
LinkerScript.h [ELF] Deleted unused forward declarations. NFC 2019-05-24 09:25:47 +00:00
MapFile.cpp ELF: Add basic partition data structures and behaviours. 2019-05-29 03:55:20 +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 ELF: Add basic partition data structures and behaviours. 2019-05-29 03:55:20 +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 [PPC32] Improve the 32-bit PowerPC port 2019-06-06 17:03:00 +00:00
OutputSections.cpp ELF: Introduce a separate bit for tracking whether an output section has ever had an input section added to it. NFCI. 2019-06-03 20:14:25 +00:00
OutputSections.h ELF: Introduce a separate bit for tracking whether an output section has ever had an input section added to it. NFCI. 2019-06-03 20:14:25 +00:00
README.md
Relocations.cpp [PPC32] Improve the 32-bit PowerPC port 2019-06-06 17:03:00 +00:00
Relocations.h [PPC32] Improve the 32-bit PowerPC port 2019-06-06 17:03:00 +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 [ELF] Full support for -n (--nmagic) and -N (--omagic) via common page 2019-05-13 16:01:26 +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: Add basic partition data structures and behaviours. 2019-05-29 03:55:20 +00:00
SymbolTable.h Use SymbolTable::insert() to implement --trace. 2019-05-28 06:33:06 +00:00
Symbols.cpp [ELF] Delete GotEntrySize and GotPltEntrySize 2019-05-31 10:35:45 +00:00
Symbols.h [ELF] Implement Local Dynamic style TLSDESC for x86-64 2019-05-30 10:00:20 +00:00
SyntheticSections.cpp [PPC32] Improve the 32-bit PowerPC port 2019-06-06 17:03:00 +00:00
SyntheticSections.h [PPC32] Improve the 32-bit PowerPC port 2019-06-06 17:03:00 +00:00
Target.cpp [PPC64] toc-indirect to toc-relative relaxation 2019-05-07 04:26:05 +00:00
Target.h [PPC32] Improve the 32-bit PowerPC port 2019-06-06 17:03:00 +00:00
Thunks.cpp [PPC32] Improve the 32-bit PowerPC port 2019-06-06 17:03:00 +00:00
Thunks.h [PPC32] Improve the 32-bit PowerPC port 2019-06-06 17:03:00 +00:00
Writer.cpp [PPC32] Improve the 32-bit PowerPC port 2019-06-06 17:03:00 +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