forked from OSchip/llvm-project
6fa1343bb3
The location of a TLS variable is encoded as a DW_OP_const4u/DW_OP_const8u followed by a DW_OP_push_tls_address (or DW_OP_GNU_push_tls_address https://sourceware.org/bugzilla/show_bug.cgi?id=11616 ). This change follows up to D81784 and makes relocations types generalized as R_DTPREL (e.g. R_X86_64_DTPOFF{32,64}, R_PPC64_DTPREL64) use -1 as the tombstone value as well. This works for both TLS Variant I and Variant II architectures. * arm: .long tls(tlsldo) # not working currently (R_ARM_TLS_LDO32 is R_ABS) * mips64: .dtpreldword tls+32768 * ppc64: .quad tls@DTPREL+0x8000 * riscv: neither GCC nor clang has implemented DW_AT_location. It is likely .long/.quad tls@dtprel+0x800 * x86-32: .long tls@DTPOFF * x86-64: .long tls@DTPOFF; .quad tls@DTPOFF tls has a non-negative st_value, so such relocations (st_value+addend) never resolve to -1 in a normal (not discarded) case. ``` // clang -fuse-ld=lld -g -ffunction-sections a.c -Wl,--gc-sections // foo and tls will be discarded by --gc-sections. // DW_AT_location [DW_FORM_exprloc] (DW_OP_const8u 0xffffffffffffffff, DW_OP_GNU_push_tls_address) thread_local int tls; int foo() { return ++tls; } int main() {} ``` Also, drop logic added in D26201 intended to address PR30793. It added a test (gc-debuginfo-tls.s) using a non-SHF_ALLOC section and a local symbol, which does not reflect the intended scenario: a relocation in a SHF_ALLOC section referencing a discarded non-local symbol. For such a non .debug_* section, just emit an error. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D82899 |
||
---|---|---|
.. | ||
COFF | ||
Common | ||
ELF | ||
MachO | ||
MinGW | ||
cmake/modules | ||
docs | ||
include/lld | ||
lib | ||
test | ||
tools/lld | ||
unittests | ||
utils | ||
wasm | ||
.clang-format | ||
.clang-tidy | ||
.gitignore | ||
CMakeLists.txt | ||
CODE_OWNERS.TXT | ||
LICENSE.TXT | ||
README.md |
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.