[GOLD] PowerPC64 tocsave
authorAlan Modra <amodra@gmail.com>
Fri, 23 Jun 2017 11:07:34 +0000 (20:37 +0930)
committerAlan Modra <amodra@gmail.com>
Fri, 23 Jun 2017 11:07:34 +0000 (20:37 +0930)
commit7e57d19e48f94ff9a19a9413cf25d1887e3a7f52
treeaf0f7843a53e5a1458a73e358666df04257f316f
parent0e158763b0c5671cd40cdd2faee48d6659489ddd
[GOLD] PowerPC64 tocsave

This adds support to gold for the tocsave relocs already supported by
ld.bfd.  R_PPC64_TOCSAVE relocs are part of a scheme to move r2 saves
to the prologue of a function rather than in each plt call stub.  We
don't want a compiler to always emit the r2 save, as this would be
wasted if the calls turned out to be local.  See the tocsave*.s in
ld/testsuite/ld-powerpc/.

* powerpc.cc (Target_powerpc::tocsave_loc_): New var.
(Target_powerpc::mark_pltcall, add_tocsave, tocsave_loc): New functions.
(Target_powerpc::Branch_info::tocsave_): New var.
(Target_powerpc::Branch_info::mark_pltcall): New function.
(Target_powerpc::Branch_info::make_stub): Pass tocsave_ to
add_plt_call_entry.
(Stub_table::Plt_stub_ent): Make public.  Add r2save_.
(Stub_table::add_plt_call_entry): Add bool tocsave_ param.  Set
r2save_.
(Stub_table::find_plt_call_entry): Return Plt_stub_ent*.  Adjust
use throughout.
(Stub_table::do_write): Conditionally output r2 save in plt stubs.
(Target_powerpc::Scan::local): Handle R_PPC64_TOCSAVE.
(Target_powerpc::Scan::global): Likewise.
(Target_powerpc::Relocate::relocate): Skip r2 save in plt call stub
with tocsave reloc.  Replace header tocsave nop with r2 save.
* symtab.h (struct Symbol_location_hash): Make public.
gold/ChangeLog
gold/powerpc.cc
gold/symtab.h