From 7e57d19e48f94ff9a19a9413cf25d1887e3a7f52 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Fri, 23 Jun 2017 20:37:34 +0930 Subject: [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/symtab.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'gold/symtab.h') diff --git a/gold/symtab.h b/gold/symtab.h index 46c7fce..77552ae 100644 --- a/gold/symtab.h +++ b/gold/symtab.h @@ -1273,6 +1273,16 @@ struct Symbol_location } }; +// A map from symbol name (as a pointer into the namepool) to all +// the locations the symbols is (weakly) defined (and certain other +// conditions are met). This map will be used later to detect +// possible One Definition Rule (ODR) violations. +struct Symbol_location_hash +{ + size_t operator()(const Symbol_location& loc) const + { return reinterpret_cast(loc.object) ^ loc.offset ^ loc.shndx; } +}; + // This class manages warnings. Warnings are a GNU extension. When // we see a section named .gnu.warning.SYM in an object file, and if // we wind using the definition of SYM from that object file, then we @@ -1695,16 +1705,6 @@ class Symbol_table typedef Unordered_map Symbol_table_type; - // A map from symbol name (as a pointer into the namepool) to all - // the locations the symbols is (weakly) defined (and certain other - // conditions are met). This map will be used later to detect - // possible One Definition Rule (ODR) violations. - struct Symbol_location_hash - { - size_t operator()(const Symbol_location& loc) const - { return reinterpret_cast(loc.object) ^ loc.offset ^ loc.shndx; } - }; - typedef Unordered_map > Odr_map; -- cgit v1.1