llvm-project/lld/ELF
Peter Smith e208208a31 [ELF][AArch64] Support for BTI and PAC
Branch Target Identification (BTI) and Pointer Authentication (PAC) are
architecture features introduced in v8.5a and 8.3a respectively. The new
instructions have been added in the hint space so that binaries take
advantage of support where it exists yet still run on older hardware. The
impact of each feature is:

BTI: For executable pages that have been guarded, all indirect branches
must have a destination that is a BTI instruction of the appropriate type.
For the static linker, this means that PLT entries must have a "BTI c" as
the first instruction in the sequence. BTI is an all or nothing
property for a link unit, any indirect branch not landing on a valid
destination will cause a Branch Target Exception.

PAC: The dynamic loader encodes with PACIA the address of the destination
that the PLT entry will load from the .plt.got, placing the result in a
subset of the top-bits that are not valid virtual addresses. The PLT entry
may authenticate these top-bits using the AUTIA instruction before
branching to the destination. Use of PAC in PLT sequences is a contract
between the dynamic loader and the static linker, it is independent of
whether the relocatable objects use PAC.

BTI and PAC are independent features that can be combined. So we can have
several combinations of PLT:
- Standard with no BTI or PAC
- BTI PLT with "BTI c" as first instruction.
- PAC PLT with "AUTIA1716" before the indirect branch to X17.
- BTIPAC PLT with "BTI c" as first instruction and "AUTIA1716" before the
  first indirect branch to X17.
    
The use of BTI and PAC in relocatable object files are encoded by feature
bits in the .note.gnu.property section in a similar way to Intel CET. There
is one AArch64 specific program property GNU_PROPERTY_AARCH64_FEATURE_1_AND
and two target feature bits defined:
- GNU_PROPERTY_AARCH64_FEATURE_1_BTI
-- All executable sections are compatible with BTI.
- GNU_PROPERTY_AARCH64_FEATURE_1_PAC
-- All executable sections have return address signing enabled.

Due to the properties of FEATURE_1_AND the static linker can tell when all
input relocatable objects have the BTI and PAC feature bits set. The static
linker uses this to enable the appropriate PLT sequence.
Neither -> standard PLT
GNU_PROPERTY_AARCH64_FEATURE_1_BTI -> BTI PLT
GNU_PROPERTY_AARCH64_FEATURE_1_PAC -> PAC PLT
Both properties -> BTIPAC PLT

In addition to the .note.gnu.properties there are two new command line
options:
--force-bti : Act as if all relocatable inputs had
GNU_PROPERTY_AARCH64_FEATURE_1_BTI and warn for every relocatable object
that does not.
--pac-plt : Act as if all relocatable inputs had
GNU_PROPERTY_AARCH64_FEATURE_1_PAC. As PAC is a contract between the loader
and static linker no warning is given if it is not present in an input.

Two processor specific dynamic tags are used to communicate that a non
standard PLT sequence is being used.
DTI_AARCH64_BTI_PLT and DTI_AARCH64_BTI_PAC.

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

llvm-svn: 362793
2019-06-07 13:00:17 +00:00
..
Arch [ELF][AArch64] Support for BTI and PAC 2019-06-07 13:00:17 +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 [ELF][AArch64] Support for BTI and PAC 2019-06-07 13:00:17 +00:00
DWARF.cpp Revert "Revert "Reland D61583 [ELF] Error on relocations to STT_SECTION symbols if the sections were discarded"" 2019-06-06 20:16:53 +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][AArch64] Support for BTI and PAC 2019-06-07 13:00:17 +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 [ELF][AArch64] Support for BTI and PAC 2019-06-07 13:00:17 +00:00
InputFiles.h [PPC32] Improve the 32-bit PowerPC port 2019-06-06 17:03:00 +00:00
InputSection.cpp Revert "Revert "[ELF] Suppress "STT_SECTION symbol should be defined" on .eh_frame, .debug*, .zdebug* and .gcc_except_table"" 2019-06-06 20:16:59 +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 [ELF][AArch64] Support for BTI and PAC 2019-06-07 13:00:17 +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 Update the documents of the new LLD. 2016-03-12 06:06:40 +00:00
Relocations.cpp [ELF] Delete R_PPC64_CALL_PLT from isRelExpr() 2019-06-07 11:09:33 +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 [ELF][AArch64] Support for BTI and PAC 2019-06-07 13:00:17 +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] Support GD/LD/IE/LE TLS models and their relaxations 2019-06-06 17:03:10 +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 Revert [ELF] Simplify the condition to create .interp 2019-06-06 23:23:14 +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