[PATCH] AArch64 gas: Block section relative symbols in GOT relocations [PR30788]
Richard Earnshaw (foss)
Richard.Earnshaw@arm.com
Wed May 27 12:02:25 GMT 2026
On 26/05/2026 19:37, Wilco Dijkstra wrote:
>
> By default, GAS changes GOT relocations of local symbols into section relative.
> This is incorrect since GOT relocations do not support offsets. Update
> aarch64_fix_adjustable() to explicitly disallow this for GOT relocations.
> This fixes PR30788.
>
> ---
>
> diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c
> index fb58bcca9b1059e5d4d831a0a8ea9a33d05deaba..9632a5b2a015b38f2d35fa2f569093b9b52790f9 100644
> --- a/gas/config/tc-aarch64.c
> +++ b/gas/config/tc-aarch64.c
> @@ -10389,6 +10389,19 @@ aarch64_fix_adjustable (fixS *fixp)
> if (symbol_get_bfdsym (fixp->fx_addsy)->flags & BSF_FUNCTION)
> return false;
>
> + /* GOT relocations cannot have an offset or use section-relative symbols. */
> + if (fixp->fx_r_type == BFD_RELOC_AARCH64_ADR_GOT_PAGE
> + || fixp->fx_r_type == BFD_RELOC_AARCH64_GOT_LD_PREL19
> + || fixp->fx_r_type == BFD_RELOC_AARCH64_LD_GOT_LO12_NC
> + || fixp->fx_r_type == BFD_RELOC_AARCH64_LD32_GOT_LO12_NC
> + || fixp->fx_r_type == BFD_RELOC_AARCH64_LD32_GOTPAGE_LO14
> + || fixp->fx_r_type == BFD_RELOC_AARCH64_LD64_GOTOFF_LO15
> + || fixp->fx_r_type == BFD_RELOC_AARCH64_LD64_GOTPAGE_LO15
> + || fixp->fx_r_type == BFD_RELOC_AARCH64_LD64_GOT_LO12_NC
> + || fixp->fx_r_type == BFD_RELOC_AARCH64_MOVW_GOTOFF_G0_NC
> + || fixp->fx_r_type == BFD_RELOC_AARCH64_MOVW_GOTOFF_G1)
> + return false;
> +
> return true;
> }
>
The Arm equivalent of this function also has checks for TLS and VTABLE relocs as well. Do we need something similar here?
R.
> diff --git a/gas/testsuite/gas/aarch64/reloc-insn.d b/gas/testsuite/gas/aarch64/reloc-insn.d
> index dc73bd2832a2e802fa93b99f733752ee453d9826..3fcb28dce3c2b864643f5a189b8cd4fadb91b64f 100644
> --- a/gas/testsuite/gas/aarch64/reloc-insn.d
> +++ b/gas/testsuite/gas/aarch64/reloc-insn.d
> @@ -159,9 +159,9 @@ Disassembly of section \.text:
> 18c: 39400001 ldrb w1, \[x0\]
> 190: d65f03c0 ret
> 194: f94001bc ldr x28, \[x13\]
> - 194: R_AARCH64_LD64_GOTPAGE_LO15 \.data
> + 194: R_AARCH64_LD64_GOTPAGE_LO15 dummy
> 198: f9400000 ldr x0, \[x0\]
> - 198: R_AARCH64_LD64_GOTOFF_LO15 .data
> + 198: R_AARCH64_LD64_GOTOFF_LO15 dummy
>
> 000000000000019c <llit>:
> 19c: deadf00d \.word 0xdeadf00d
>
More information about the Binutils
mailing list