[GOLD] PowerPC64 inline plt sequences
authorAlan Modra <amodra@gmail.com>
Wed, 24 Nov 2021 13:30:50 +0000 (00:00 +1030)
committerAlan Modra <amodra@gmail.com>
Mon, 6 Dec 2021 11:46:46 +0000 (22:16 +1030)
commitf21dbd7c8038acee8ece4d57f2454083c37e98f6
treee7d3d9725fd59d0385bbdcbe1cdfcc8527c4e2e7
parent74044dc84074abca775c63462ecccc10a7900987
[GOLD] PowerPC64 inline plt sequences

The fixes gold failures to handle inline PLT sequences properly.
PowerPC gold was always turning these back into direct calls due to
gsym->use_plt_offset() returning false.  This is fixed for dynamic
linking by correcting get_reference_flags, and for static linking by
overriding use_plt_offset() in relocate().  The rest of the patch
revolves around needing to create PLT entries for inline PLT calls
when statically linking (for gcc -mlongcall).  The lplt section
handled that for local symbols, now it does globals too.

* powerpc.cc (Target_powerpc::plt_off): Return proper section
for static link.
(Target_powerpc::symval_for_branch): Make public.
(Target_powerpc::make_lplt_section): Add Symbol_table* param.
Adjust all calls.
(Target_powerpc::make_local_plt_entry): Likewise.
(Target_powerpc::make_local_plt_entry): New variant for global syms.
(Powerpc_relobj::do_relocate_sections): Don't write lplt contents.
(Output_data_plt_powerpc::do_write): Write lplt contents here.
(Output_data_plt_powerpc::Output_data_plt_powerpc): Save
symbol table pointer.  Adjust all uses.
(Output_data_plt_powerpc::add_entry): Add stash parameter.  Don't
do dynamic reloc handling when no reloc section.  Save symbol
for local plt entries.
(Output_data_plt_powerpc::add_local_entry): Save symbol.
(Output_data_plt_powerpc::Local_plt_ent): New class.
(Output_data_plt_powerpc::sym_ents_): New vector.
(Target_powerpc::Scan::get_reference_flags): Return
FUNCTION_CALL|RELATIVE_REF for inline plt relocs.
(Target_powerpc::Scan::global): Make entries in lplt for inline
plt call relocation symbols.
(Target_powerpc::Relocate::relocate): Rename has_plt_offset to
use_plt_offset.  Set use_plt_offset for inline plt relocs.
gold/powerpc.cc