]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
aarch64: Fix %dtprel relocations size.
authorSrinath Parvathaneni <srinath.parvathaneni@arm.com>
Wed, 8 Jul 2026 21:12:27 +0000 (21:12 +0000)
committerSrinath Parvathaneni <srinath.parvathaneni@arm.com>
Wed, 8 Jul 2026 21:16:04 +0000 (21:16 +0000)
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

gas/config/tc-aarch64.c
gas/testsuite/gas/aarch64/tls-debug-bad.d [new file with mode: 0644]
gas/testsuite/gas/aarch64/tls-debug-bad.l [new file with mode: 0644]
gas/testsuite/gas/aarch64/tls-debug-bad.s [new file with mode: 0644]

index 2da5139d8afd95bfc5a9a417f54ede6f05de9d4a..6d412651354aa872faa1baebddc54703efe1092a 100644 (file)
@@ -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 (file)
index 0000000..fb1af53
--- /dev/null
@@ -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 (file)
index 0000000..68e69ea
--- /dev/null
@@ -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 (file)
index 0000000..c4987bc
--- /dev/null
@@ -0,0 +1,7 @@
+.section .tdata,"awT",@progbits
+.globl var
+var:
+  .word 0
+
+.section        .debug_info,"",@progbits
+  .word  %dtprel(var)