mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-15 04:31:49 +08:00
2d7ad24e87
Necessary if gcc is to use PLT16 relocs to implement -mlongcall, and there isn't a good technical reason why local symbols should be excluded from PLT16 support. Non-ifunc local symbol PLT entries go in a separate section to other PLT entries. In a fixed position executable they won't need to be relocated, and in a PIE or shared library I chose to not implement lazy relocation. bfd/ * elf64-ppc.c (LOCAL_PLT_ENTRY_SIZE): Define. (struct ppc_stub_hash_entry): Add symtype field. (PLT_KEEP): Define. (struct ppc_link_hash_table): Add pltlocal and relpltlocal. (create_linkage_sections): Create pltlocal and relpltlocal. (ppc64_elf_check_relocs): Allow PLT relocs on local symbols. Set PLT_KEEP. (ppc64_elf_adjust_dynamic_symbol): Keep PLT entries for inline calls. (allocate_dynrelocs): Allocate pltlocal and relpltlocal. (ppc64_elf_size_dynamic_sections): Size pltlocal and relpltlocal. Keep PLT entries for inline calls against locals. (ppc_build_one_stub): Use pltlocal as appropriate. (ppc_size_one_stub): Likewise. (ppc64_elf_size_stubs): Set symtype. (build_global_entry_stubs_and_plt): Init pltlocal and write relpltlocal for globals. (write_plt_relocs_for_local_syms): Likewise for local syms. (ppc64_elf_relocate_section): Support PLT for local syms. * elf32-ppc.c (PLT_KEEP): Define. (struct ppc_elf_link_hash_table): Add pltlocal and relpltlocal. (ppc_elf_create_glink): Create pltlocal and relpltlocal. (ppc_elf_check_relocs): Allow PLT relocs on local symbols. Set PLT_KEEP. Adjust update_local_sym_info call. (ppc_elf_adjust_dynamic_symbol): Keep PLT entries for inline calls. (allocate_dynrelocs): Allocate pltlocal and relpltlocal. (ppc_elf_size_dynamic_sections): Size pltlocal and relpltlocal. (ppc_elf_relocate_section): Support PLT16 relocs for local syms. (write_global_sym_plt): Init pltlocal and write relpltlocal. (ppc_finish_symbols): Likewise for locals. ld/ * emulparams/elf32ppc.sh (OTHER_RELRO_SECTIONS_2): Add .branch_lt. (OTHER_GOT_RELOC_SECTIONS): Add .rela.branch_lt. * testsuite/ld-powerpc/elfv2so.d: Update for symbol/stub reordering. * testsuite/ld-powerpc/relbrlt.d: Likewise. * testsuite/ld-powerpc/relbrlt.s: Likewise. * testsuite/ld-powerpc/tlsso.r: Likewise. * testsuite/ld-powerpc/tlstocso.r: Likewise. gold/ * powerpc.cc (Target_powerpc::lplt_): New variable. (Target_powerpc::lplt_section): Associated accessor. (Target_powerpc::plt_off): Handle local non-ifunc symbols. (Target_powerpc::make_lplt_section): New function. (Target_powerpc::make_local_plt_entry): New function. (Powerpc_relobj::do_relocate_sections): Write out lplt. (Output_data_plt_powerpc::first_plt_entry_offset): Zero for lplt. (Output_data_plt_powerpc::add_local_entry): New function. (Output_data_plt_powerpc::do_write): Ignore lplt. (Target_powerpc::make_iplt_section): Make lplt first. (Target_powerpc::make_brlt_section): Make .branch_lt relro. (Target_powerpc::Scan::local): Handle PLT16 relocs.
31 lines
1.2 KiB
Bash
31 lines
1.2 KiB
Bash
# If you change this file, please also look at files which source this one:
|
|
# elf32lppcnto.sh elf32lppc.sh elf32ppclinux.sh elf32ppcnto.sh
|
|
# elf32ppcsim.sh
|
|
|
|
. ${srcdir}/emulparams/elf32ppccommon.sh
|
|
. ${srcdir}/emulparams/plt_unwind.sh
|
|
# Yes, we want duplicate .got and .plt sections. The linker chooses the
|
|
# appropriate one magically in ppc_after_open
|
|
DATA_GOT=
|
|
SDATA_GOT=
|
|
SEPARATE_GOTPLT=0
|
|
BSS_PLT=
|
|
GOT=".got ${RELOCATING-0} : SPECIAL { *(.got) }"
|
|
GOTPLT=".plt ${RELOCATING-0} : SPECIAL { *(.plt) }"
|
|
PLT=".plt ${RELOCATING-0} : SPECIAL { *(.plt) }
|
|
.iplt ${RELOCATING-0} : { *(.iplt) }"
|
|
OTHER_TEXT_SECTIONS="*(.glink)"
|
|
OTHER_GOT_RELOC_SECTIONS="
|
|
.rela.branch_lt ${RELOCATING-0} : { *(.rela.branch_lt) }"
|
|
OTHER_RELRO_SECTIONS_2="
|
|
.branch_lt ${RELOCATING-0} :${RELOCATING+ ALIGN(4)} { *(.branch_lt) }"
|
|
EXTRA_EM_FILE=ppc32elf
|
|
if grep -q 'ld_elf32_spu_emulation' ldemul-list.h; then
|
|
# crt1.o defines data_start and __data_start. Keep them first.
|
|
# Next put all the .data.spehandle sections, with a trailing zero word.
|
|
DATA_START_SYMBOLS="${RELOCATING+*crt1.o(.data .data.* .gnu.linkonce.d.*)
|
|
PROVIDE (__spe_handle = .);
|
|
*(.data.spehandle)
|
|
. += 4 * (DEFINED (__spe_handle) || . != 0);}"
|
|
fi
|