https://sourceware.org/bugzilla/show_bug.cgi?id=31848
Bug ID: 31848 Summary: aarch64: incorrect relative relocation for ABS symbols Product: binutils Version: unspecified Status: NEW Severity: normal Priority: P2 Component: ld Assignee: unassigned at sourceware dot org Reporter: nsz at gcc dot gnu.org Target Milestone: --- relative relocation against an abs symbol is wrong, the GOT entry should be initialized to the abs symbol value without dynamic relocation for it. $ cat abs-got.s .text .global _start _start: adrp x0, :got:sym_global_abs ldr x0, [x0, :got_lo12:sym_global_abs] adrp x0, :got:sym_weak_abs ldr x0, [x0, :got_lo12:sym_weak_abs] adrp x0, :got:sym_hidden_abs ldr x0, [x0, :got_lo12:sym_hidden_abs] adrp x0, :got:sym_forced_local_abs ldr x0, [x0, :got_lo12:sym_forced_local_abs] adrp x0, :got:sym_local_abs ldr x0, [x0, :got_lo12:sym_local_abs] .global sym_global_abs .set sym_global_abs, 42 .weak sym_weak_abs .set sym_weak_abs, 42 .global sym_hidden_abs .hidden sym_hidden_abs .set sym_hidden_abs, 42 .global sym_forced_local_abs .set sym_forced_local_abs, 42 .set sym_local_abs, 42 $ cat abs-got.lds { local: sym_forced_local_abs; }; $ aarch64-linux-gnu-as -o abs-got.o abs-got.s $ aarch64-linux-gnu-ld -pie --version-script=abs-got.lds abs-got.o $ aarch64-linux-gnu-readelf -rW a.out Relocation section '.rela.dyn' at offset 0x220 contains 5 entries: Offset Info Type Symbol's Value Symbol's Name + Addend 000000000001ffc0 0000000000000403 R_AARCH64_RELATIVE 2a 000000000001ffc8 0000000000000403 R_AARCH64_RELATIVE 2a 000000000001ffd0 0000000000000403 R_AARCH64_RELATIVE 2a 000000000001ffd8 0000000000000403 R_AARCH64_RELATIVE 2a 000000000001ffe0 0000000000000403 R_AARCH64_RELATIVE 2a $ aarch64-linux-gnu-readelf -sW a.out |grep sym_ 13: 000000000000002a 0 NOTYPE LOCAL DEFAULT ABS sym_local_abs 16: 000000000000002a 0 NOTYPE LOCAL DEFAULT ABS sym_forced_local_abs 18: 000000000000002a 0 NOTYPE GLOBAL HIDDEN ABS sym_hidden_abs 24: 000000000000002a 0 NOTYPE GLOBAL DEFAULT ABS sym_global_abs 28: 000000000000002a 0 NOTYPE WEAK DEFAULT ABS sym_weak_abs $ aarch64-linux-gnu-ld -z pack-relative-relocs -pie --version-script=abs-got.lds abs-got.o $ aarch64-linux-gnu-readelf -rW a.out Relocation section '.rela.dyn' at offset 0x220 contains 4 entries: Offset Info Type Symbol's Value Symbol's Name + Addend 0000000000000000 0000000000000000 R_AARCH64_NONE 0 0000000000000000 0000000000000000 R_AARCH64_NONE 0 0000000000000000 0000000000000000 R_AARCH64_NONE 0 0000000000000000 0000000000000000 R_AARCH64_NONE 0 Relocation section '.relr.dyn' at offset 0x280 contains 1 entry which relocates 1 location: Index: Entry Address Symbolic Address 0000: 000000000001ffc0 000000000001ffc0 _GLOBAL_OFFSET_TABLE_ + 0x8 -- You are receiving this mail because: You are on the CC list for the bug.