diff options
| author | Shivam Gupta <shivam98.tkg@gmail.com> | 2026-04-08 15:45:38 +0530 |
|---|---|---|
| committer | Alice Carlotti <alice.carlotti@arm.com> | 2026-04-09 15:34:45 +0100 |
| commit | ed71fa9a44511cb8d933073f892ea041c3ff9107 (patch) | |
| tree | c10565c060f38f168ddb4aab32e563333dfe8a7c /bfd | |
| parent | d7e49fd331d5a9a66d467c7d5cb4b5fc156a1ee0 (diff) | |
| download | fsf-binutils-gdb-ed71fa9a44511cb8d933073f892ea041c3ff9107.tar.gz fsf-binutils-gdb-ed71fa9a44511cb8d933073f892ea041c3ff9107.tar.bz2 fsf-binutils-gdb-ed71fa9a44511cb8d933073f892ea041c3ff9107.zip | |
aarch64: Add support for %dtprel(var) and R_AARCH64_TLS_DTPREL64
This patch allows R_AARCH64_TLS_DTPREL64 relocations in non-allocated
sections, which is required for DWARF debug information when using
Thread Local Storage. This matches the behavior in LLD.
Also a new syntax to parse dtprel operator use to describe tls
location in debug information. Please see the reference 3 below.
References:
- https://github.com/llvm/llvm-project/pull/146572
[AArch64] Support TLS variables in debug info
- https://github.com/llvm/llvm-project/pull/183962
[LLD][AArch64] Handle R_AARCH64_TLS_DTPREL64 in non-alloc sections
- https://github.com/ARM-software/abi-aa/pull/330
[AAELF64] Allow R_AARCH64_TLS_DTPREL to be used statically.
bfd/
* elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Handle
BFD_RELOC_AARCH64_TLS_DTPREL.
gas/
* config/tc-aarch64.c (s_aarch64_cons): Parse %dtprel(var) syntax.
* testsuite/gas/aarch64/tls-debug.s: New test.
* testsuite/gas/aarch64/tls-debug.d: Run the test.
ld/
* testsuite/ld-aarch64/tls-debug.s: New test.
* testsuite/ld-aarch64/tls-debug.d: Run the test.
Bug: https://sourceware.org/PR28351
Signed-off-by: Shivam Gupta <shivam98.tkg@gmail.com>
Diffstat (limited to 'bfd')
| -rw-r--r-- | bfd/elfnn-aarch64.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c index 66049c81edf..117e149866c 100644 --- a/bfd/elfnn-aarch64.c +++ b/bfd/elfnn-aarch64.c @@ -6496,6 +6496,17 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto, *unresolved_reloc_p = false; break; + case BFD_RELOC_AARCH64_TLS_DTPREL: + if (input_section->flags & SEC_ALLOC) + return bfd_reloc_notsupported; + value -= dtpoff_base (info); + value += rel->r_addend; + + bfd_put_64 (output_bfd, value, contents + rel->r_offset); + + *unresolved_reloc_p = false; + break; + case BFD_RELOC_AARCH64_TLSDESC_OFF_G0_NC: case BFD_RELOC_AARCH64_TLSDESC_OFF_G1: if (globals->root.sgot == NULL) |
