[binutils-gdb] AArch64 gas: Block section relative symbols in GOT relocations [PR30788]
Richard Earnshaw via Binutils-cvs <[email protected]> Tue, 16 Jun 2026 13:11:36 +0000 (GMT)
| Newsgroups | gmane.comp.gnu.binutils.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8c72efa0bf7aea5a59c2f677b5c2a2d134cf0463 commit 8c72efa0bf7aea5a59c2f677b5c2a2d134cf0463 Author: Wilco Dijkstra <[email protected]> Date: Tue May 26 18:37:58 2026 +0000 AArch64 gas: Block section relative symbols in GOT relocations [PR30788] 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: --- gas/config/tc-aarch64.c | 13 +++++++++++++ gas/testsuite/gas/aarch64/reloc-insn.d | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c index fb58bcca9b1..9632a5b2a01 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; } diff --git a/gas/testsuite/gas/aarch64/reloc-insn.d b/gas/testsuite/gas/aarch64/reloc-insn.d index dc73bd2832a..3fcb28dce3c 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