[binutils-gdb] aarch64: Fix %dtprel relocations size.
SRINATH PARVATHANENI via Binutils-cvs <[email protected]> Wed, 8 Jul 2026 21:30:26 +0000 (GMT)
| Newsgroups | gmane.comp.gnu.binutils.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=46709f190eb7ddf3888226feec6c1e13984cfcc9 commit 46709f190eb7ddf3888226feec6c1e13984cfcc9 Author: Srinath Parvathaneni <[email protected]> Date: Wed Jul 8 21:12:27 2026 +0000 aarch64: Fix %dtprel relocations size. The AArch64 ELF ABI [1] requires DTPREL relocations to be 8 bytes wide, so added a check to reject %dtprel when used with anything other than .xword. [1] https://github.com/ARM-software/abi-aa/blob/main/aaelf64/aaelf64.rst#5715dynamic-relocations Diff: --- gas/config/tc-aarch64.c | 7 +++++++ gas/testsuite/gas/aarch64/tls-debug-bad.d | 4 ++++ gas/testsuite/gas/aarch64/tls-debug-bad.l | 2 ++ gas/testsuite/gas/aarch64/tls-debug-bad.s | 7 +++++++ 4 files changed, 20 insertions(+) diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c index 2da5139d8af..6d412651354 100644 --- a/gas/config/tc-aarch64.c +++ b/gas/config/tc-aarch64.c @@ -2234,6 +2234,13 @@ s_aarch64_cons (int nbytes) expression (&exp); + if (nbytes != 8) + { + as_bad (_("%%dtprel relocation requires .xword or .dword")); + ignore_rest_of_line (); + return; + } + /* Ensure we have a closing parenthesis */ if (*input_line_pointer == ')') input_line_pointer++; diff --git a/gas/testsuite/gas/aarch64/tls-debug-bad.d b/gas/testsuite/gas/aarch64/tls-debug-bad.d new file mode 100644 index 00000000000..fb1af537d95 --- /dev/null +++ b/gas/testsuite/gas/aarch64/tls-debug-bad.d @@ -0,0 +1,4 @@ +#as: +#objdump: -r +#target: aarch64*-*-* +#error_output: tls-debug-bad.l diff --git a/gas/testsuite/gas/aarch64/tls-debug-bad.l b/gas/testsuite/gas/aarch64/tls-debug-bad.l new file mode 100644 index 00000000000..68e69ea0cdc --- /dev/null +++ b/gas/testsuite/gas/aarch64/tls-debug-bad.l @@ -0,0 +1,2 @@ +[^ :]+: Assembler messages: +[^ :]+:[0-9]+: Error: %dtprel relocation requires \.xword or \.dword diff --git a/gas/testsuite/gas/aarch64/tls-debug-bad.s b/gas/testsuite/gas/aarch64/tls-debug-bad.s new file mode 100644 index 00000000000..c4987bc3260 --- /dev/null +++ b/gas/testsuite/gas/aarch64/tls-debug-bad.s @@ -0,0 +1,7 @@ +.section .tdata,"awT",@progbits +.globl var +var: + .word 0 + +.section .debug_info,"",@progbits + .word %dtprel(var)