[PATCH v1] aarch64: Fix %dtprel relocations size.
Alice Carlotti
alice.carlotti@arm.com
Mon Jul 6 16:29:27 GMT 2026
On Mon, Jul 06, 2026 at 09:49:39AM +0000, srinath.parvathaneni@arm.com wrote:
> From: Srinath Parvathaneni <srinath.parvathaneni@arm.com>
>
> 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"));
.dword is also valid. Some suggestions:
"%%dtprel relocation requires .xword or .dword"
"%%dtprel relocation produces 64-bit values"
"%%dtprel relocation requires 64-bit values"
"%%dtprel relocation requires 64-bit values (.xword or .dword)"
Ok to merge in 48 hours with any of those suggestions, unless someone comes up
with a better idea first.
Alice
> + 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
>
More information about the Binutils
mailing list