Bug 30788 - gas aarch64: GOT relocations referencing a local symbol should not be changed to reference STT_SECTION
Summary: gas aarch64: GOT relocations referencing a local symbol should not be changed...
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gas (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: 2.47
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-08-23 03:33 UTC by Fangrui Song
Modified: 2026-06-17 03:09 UTC (History)
4 users (show)

See Also:
Host:
Target: aarch64*-*
Build:
Last reconfirmed:
Project(s) to access:
ssh public key:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fangrui Song 2023-08-23 03:33:47 UTC
Extracted from https://github.com/llvm/llvm-project/issues/63418

```
cat > a.s <<EOF
ldr     x1, [x1, :got_lo12:x]  // converted to .data+0
ldr     x1, [x1, :got_lo12:y]  // converted to .data+4

.data
// .globl x, y  would suppress STT_SECTION conversion
x:
.zero 4
y:
.long 42
aarch64-linux-gnu-gcc -c a.s
```

The two R_AARCH64_LD64_GOT_LO12_NC relocations are converted to reference the STT_SECTION symbol .data .
After linking, they will share the same GOT entry (GNU ld and ld.lld use just the symbol to decide an entry, not symbol plus addend), which is not expected.

I think this is a neglection for AArch64. For most targets (including AArch32,
x86, PowerPC, and RISC-V) local symbol to STT_SECTION conversion is suppressed
for GOT-generating relocations.

https://github.com/ARM-software/abi-aa/issues/217 is created to decide how we should create GOT entries, GDAT(S+A) vs GDAT(S).
If the decision is to respect existing linker behaviors and allow the same GOT entry for :got_lo12:(.data+0) and :got_lo12:(.data+4),
this assembler change is IMO a prerequisite.
Comment 1 Wilco 2026-06-16 15:58:19 UTC
Fixed by:

commit 8c72efa0bf7aea5a59c2f677b5c2a2d134cf0463 (HEAD -> master, origin/master, origin/HEAD)
Author: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
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.