llvm-project/lld
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
..
COFF Re-land [LLD] Remove global state in lldCommon 2022-01-20 14:53:26 -05:00
Common Re-land [LLD] Remove global state in lldCommon 2022-01-20 14:53:26 -05:00
ELF [ELF] Fix the branch range computation when reusing a thunk 2022-01-24 09:03:21 -08:00
MachO [lld][macho] Stop grouping symbols by sections in mapfile. 2022-01-20 12:16:37 -08:00
MinGW Re-land [LLD] Remove global state in lldCommon 2022-01-20 14:53:26 -05:00
cmake/modules [CMake] Factor out config prefix finding logic 2022-01-07 20:16:18 +00:00
docs [ELF] Update help messages to prefer canonical name for some long options 2022-01-06 00:43:46 -08:00
include/lld Re-land [LLD] Remove global state in lldCommon 2022-01-20 14:53:26 -05:00
test [ELF] Fix the branch range computation when reusing a thunk 2022-01-24 09:03:21 -08:00
tools/lld Re-land [LLD] Remove global state in lldCommon 2022-01-20 14:53:26 -05:00
utils
wasm [lld][WebAssembly] Remove redundant config setting 2022-01-20 15:21:56 -08:00
.clang-format
.clang-tidy NFC: .clang-tidy: Inherit configs from parents to improve maintainability 2021-06-08 08:25:59 -07:00
.gitignore
CMakeLists.txt [cmake] Make include(GNUInstallDirs) always below project(..) 2022-01-20 18:59:17 +00:00
CODE_OWNERS.TXT Add code owners of new MachO port 2020-09-02 19:32:12 -07:00
LICENSE.TXT
README.md [doc] Place sha256 in lld/README.md into backticks 2021-01-12 10:19:40 -08:00

README.md

LLVM Linker (lld)

This directory and its subdirectories contain source code for the LLVM Linker, a modular cross platform linker which is built as part of the LLVM compiler infrastructure project.

lld is open source software. You may freely distribute it under the terms of the license agreement found in LICENSE.txt.

Benchmarking

In order to make sure various developers can evaluate patches over the same tests, we create a collection of self contained programs.

It is hosted at https://s3-us-west-2.amazonaws.com/linker-tests/lld-speed-test.tar.xz

The current sha256 is 10eec685463d5a8bbf08d77f4ca96282161d396c65bd97dc99dbde644a31610f.