[PATCH v1] aarch64: Fix %dtprel relocations size.

<[email protected]>
Newsgroups gmane.comp.gnu.binutils
Message-ID <[email protected]>
From: Srinath Parvathaneni <[email protected]>

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/pull/330

Regression tested on aarch64-linux-gnu and found no regressions.

Ok for master?

Regards,
Srinath
---
 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(+)
 create mode 100644 gas/testsuite/gas/aarch64/tls-debug-bad.d
 create mode 100644 gas/testsuite/gas/aarch64/tls-debug-bad.l
 create mode 100644 gas/testsuite/gas/aarch64/tls-debug-bad.s

diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c
index 2da5139d8af..43baead03e7 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"));
+		  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..34f24e3aa47
--- /dev/null
+++ b/gas/testsuite/gas/aarch64/tls-debug-bad.l
@@ -0,0 +1,2 @@
+[^ :]+: Assembler messages:
+[^ :]+:[0-9]+: Error: %dtprel relocation requires \.xword
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)
-- 
2.43.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.