mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-27 03:51:15 +08:00
3a3a4c1fe4
Supporting -static-pie on PowerPC64 requires the linker to properly treat SHN_ABS symbols for cases like glibc's _nl_current_LC_CTYPE_used absolute symbol. I've been slow to fix the linker on powerpc because there is some chance that this will break some shared libraries or PIEs. bfd/ * elf64-ppc.c (ppc64_elf_check_relocs): Consolidate local sym handling code. Don't count dyn relocs against non-dynamic absolute symbols. (dec_dynrel_count): Adjust to suit. (ppc64_elf_edit_toc): Don't remove entries for absolute symbols when pic. (allocate_got): Don't allocate space for got relocs against non-dynamic absolute syms. (ppc64_elf_layout_multitoc): Likewise. (got_and_plt_relr): Likewise. (ppc64_elf_size_dynamic_sections): Likewise for local got. (got_and_plt_relr_for_local_syms): Likewise. (ppc64_elf_size_stubs): Don't allocate space for relr either. (ppc64_elf_relocate_section): Don't write relocs against non-dynamic absolute symbols. Don't optimise got and toc code sequences loading absolute symbol entries. ld/ * testsuite/ld-powerpc/abs-reloc.s, * testsuite/ld-powerpc/abs-static.d, * testsuite/ld-powerpc/abs-static.r, * testsuite/ld-powerpc/abs-pie.d, * testsuite/ld-powerpc/abs-pie.r, * testsuite/ld-powerpc/abs-shared.d, * testsuite/ld-powerpc/abs-shared.r, * testsuite/ld-powerpc/abs-pie-relr.d, * testsuite/ld-powerpc/abs-pie-relr.r, * testsuite/ld-powerpc/abs-shared-relr.d, * testsuite/ld-powerpc/abs-shared-relr.r: New tests. * testsuite/ld-powerpc/powerpc.exp: Run them.
15 lines
696 B
R
15 lines
696 B
R
#source: abs-reloc.s
|
|
#as: -a64
|
|
#ld: -melf64ppc -shared --hash-style=sysv --defsym a=1 --defsym 'HIDDEN(b=2)' --defsym c=0x123456789abcdef0
|
|
#readelf: -rW
|
|
|
|
Relocation section '\.rela\.dyn' at offset .* contains 7 entries:
|
|
+Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend
|
|
0+10438 0+000000016 R_PPC64_RELATIVE +10438
|
|
0+10408 0+500000026 R_PPC64_ADDR64 0+1 a \+ 0
|
|
0+10430 0+500000014 R_PPC64_GLOB_DAT 0+1 a \+ 0
|
|
0+10440 0+500000026 R_PPC64_ADDR64 0+1 a \+ 0
|
|
0+10418 0+400000026 R_PPC64_ADDR64 123456789abcdef0 c \+ 0
|
|
0+10428 0+400000014 R_PPC64_GLOB_DAT 123456789abcdef0 c \+ 0
|
|
0+10450 0+400000026 R_PPC64_ADDR64 123456789abcdef0 c \+ 0
|