llvm-project/lld/ELF
Fangrui Song c03fdd3403 [ELF] Fix the branch range computation when reusing a thunk
Notation: dst is `t->getThunkTargetSym()->getVA()`

On AArch64, when `src-0x8000000-r_addend <= dst < src-0x8000000`, the condition
`target->inBranchRange(rel.type, src, rel.sym->getVA(rel.addend))` may
incorrectly consider a thunk reusable.
`rel.addend = -getPCBias(rel.type)` resets the addend to 0 for AArch64/PPC
and the zero addend is used by `rel.sym->getVA(rel.addend)` to check
out-of-range relocations.

See the test for a case this computation is wrong:
`error: a.o:(.text_high+0x4): relocation R_AARCH64_JUMP26 out of range: -134217732 is not in [-134217728, 134217727]`
I have seen a real world case with r_addend=19960.

Reviewed By: peter.smith

Differential Revision: https://reviews.llvm.org/D117734
2022-01-24 09:03:21 -08:00
..
Arch Re-land [LLD] Remove global state in lldCommon 2022-01-20 14:53:26 -05:00
AArch64ErrataFix.cpp Re-land [LLD] Remove global state in lldCommon 2022-01-20 14:53:26 -05:00
AArch64ErrataFix.h [LLD][ELF] Optimize linker script filename glob pattern matching NFC 2020-09-16 10:26:11 +01:00
ARMErrataFix.cpp Re-land [LLD] Remove global state in lldCommon 2022-01-20 14:53:26 -05:00
ARMErrataFix.h [LLD][ELF] Optimize linker script filename glob pattern matching NFC 2020-09-16 10:26:11 +01:00
CMakeLists.txt [CMake] Make `intrinsics_gen` dependency unconditional. 2020-07-17 16:43:17 -07:00
CallGraphSort.cpp [ELF] Avoid referencing SectionBase::repl after ICF 2021-12-24 12:09:48 -08:00
CallGraphSort.h
Config.h [ELF] ScriptParser: change std::vector to SmallVector 2021-12-26 20:12:55 -08:00
DWARF.cpp [ELF] Add ELFFileBase::{elfShdrs,numELFShdrs} to avoid duplicate llvm::object::ELFFile::sections() 2021-12-24 17:10:38 -08:00
DWARF.h [ELF] --gdb-index: skip SHF_GROUP .debug_info 2020-08-13 09:11:01 -07:00
Driver.cpp Re-land [LLD] Remove global state in lldCommon 2022-01-20 14:53:26 -05:00
Driver.h [ELF][LTO] Call madvise(MADV_DONTNEED) on MemoryBuffer instances 2021-12-30 11:36:58 -08:00
DriverUtils.cpp Re-land [LLD] Remove global state in lldCommon 2022-01-20 14:53:26 -05:00
EhFrame.cpp [ELF] Simplify/optimize EhInputSection::split 2022-01-18 17:03:23 -08:00
EhFrame.h [ELF] Simplify/optimize EhInputSection::split 2022-01-18 17:03:23 -08:00
ICF.cpp [ELF] Simplify Symbol::includeInDynsym 2022-01-15 23:27:45 -08:00
ICF.h
InputFiles.cpp Re-land [LLD] Remove global state in lldCommon 2022-01-20 14:53:26 -05:00
InputFiles.h [ELF] Move SHT_REL/SHT_RELA handling from createInputSection to initializeSections 2022-01-18 23:31:51 -08:00
InputSection.cpp Re-land [LLD] Remove global state in lldCommon 2022-01-20 14:53:26 -05:00
InputSection.h [ELF] De-template InputSectionBase::getLocation. NFC 2022-01-18 17:33:58 -08:00
LTO.cpp [ELF] SymbolTable:🔣 don't filter out PlaceholderKind 2021-12-26 18:11:45 -08:00
LTO.h
LinkerScript.cpp Re-land [LLD] Remove global state in lldCommon 2022-01-20 14:53:26 -05:00
LinkerScript.h [ELF] Change some DenseMap<StringRef, *> to DenseMap<CachedHashStringRef, *>. NFC 2022-01-16 21:19:01 -08:00
MapFile.cpp [ELF] Change objectFiles to ELFFileBase * 2021-12-15 00:37:10 -08:00
MapFile.h [ELF] --cref: If -Map is specified, print to the map file 2021-11-29 14:14:53 -08:00
MarkLive.cpp Re-land [LLD] Remove global state in lldCommon 2022-01-20 14:53:26 -05:00
MarkLive.h
Options.td [ELF] Enforce double-dash form for --color-diagnostics/--rsp-quoting/--symbol-ordering-file 2022-01-06 01:02:14 -08:00
OutputSections.cpp [ELF] LinkerScript/OutputSection: change other std::vector members to SmallVector 2021-12-26 13:53:47 -08:00
OutputSections.h [ELF] LinkerScript/OutputSection: change other std::vector members to SmallVector 2021-12-26 13:53:47 -08:00
README.md
Relocations.cpp [ELF] Fix the branch range computation when reusing a thunk 2022-01-24 09:03:21 -08:00
Relocations.h Move STLFunctionalExtras out of STLExtras 2022-01-24 14:13:21 +01:00
ScriptLexer.cpp [ELF] Optimize ScriptLexer::getLineNumber by caching the previous line number and offset 2021-06-22 15:35:24 -07:00
ScriptLexer.h [ELF] Optimize ScriptLexer::getLineNumber by caching the previous line number and offset 2021-06-22 15:35:24 -07:00
ScriptParser.cpp Re-land [LLD] Remove global state in lldCommon 2022-01-20 14:53:26 -05:00
ScriptParser.h [ELF] Improve --export-dynamic-symbol performance by checking whether wildcard is really used 2020-06-17 17:12:10 -07:00
SymbolTable.cpp [lld] Add support for other demanglers other than Itanium 2022-01-05 03:25:41 +00:00
SymbolTable.h [ELF] Change some DenseMap<StringRef, *> to DenseMap<CachedHashStringRef, *>. NFC 2022-01-16 21:19:01 -08:00
Symbols.cpp [ELF] Remove !isLazy() condition from computeBinding 2022-01-15 23:58:15 -08:00
Symbols.h [ELF] Remove StringRefZ 2022-01-19 20:09:41 -08:00
SyntheticSections.cpp Re-land [LLD] Remove global state in lldCommon 2022-01-20 14:53:26 -05:00
SyntheticSections.h [ELF] Change std::vector<InputSectionBase *> to SmallVector 2022-01-17 10:25:07 -08:00
Target.cpp [ELF] De-template InputSectionBase::getLocation. NFC 2022-01-18 17:33:58 -08:00
Target.h [lld][ELF] Support adrp+ldr GOT optimization for AArch64 2022-01-10 05:20:37 +00:00
Thunks.cpp Re-land [LLD] Remove global state in lldCommon 2022-01-20 14:53:26 -05:00
Thunks.h [lld] Add missing includes (NFC) 2021-06-03 18:55:18 +02:00
Writer.cpp Re-land [LLD] Remove global state in lldCommon 2022-01-20 14:53:26 -05:00
Writer.h [ELF] Move getOutputSectionName from Writer.cpp to LinkerScript.cpp. NFC 2021-11-20 22:18:09 -08:00

README.md

See docs/NewLLD.rst