]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[GOLD] Symbol flag for PowerPC64 localentry:0 tracking
authorAlan Modra <amodra@gmail.com>
Mon, 28 Aug 2017 06:57:33 +0000 (16:27 +0930)
committerAlan Modra <amodra@gmail.com>
Mon, 28 Aug 2017 06:57:33 +0000 (16:27 +0930)
This patch provides a flag for PowerPC64 ELFv2 use in class Symbol,
and modifies Sized_target::resolve to return whether the symbol has
been resolved.  If not, normal processing continues.  I use this for
PowerPC64 ELFv2 to keep track of whether a symbol has any definition
with non-zero localentry, in order to disable --plt-localentry for
that symbol.

PR 21847
* powerpc.cc (Target_powerpc::is_elfv2_localentry0): Test
non_zero_localentry.
(Target_powerpc::resolve): New function.
(powerpc_info): Set has_resolve for 64-bit.
* target.h (Sized_target::resolve): Return bool.
* resolve.cc (Symbol_table::resolve): Continue with normal
processing when target resolve returns false.
* symtab.h (Symbol::non_zero_localentry, set_non_zero_localentry):
New accessors.
(Symbol::non_zero_localentry_): New flag bit.
* symtab.cc (Symbol::init_fields): Init non_zero_localentry_.

gold/ChangeLog
gold/powerpc.cc
gold/resolve.cc
gold/symtab.cc
gold/symtab.h
gold/target.h

index 813b27f716fdf40e05467af13f7fbe8d6923996e..d612f1db6319a0a592961ef7857264c0688dc509 100644 (file)
@@ -1,3 +1,18 @@
+2017-08-28  Alan Modra  <amodra@gmail.com>
+
+       PR 21847
+       * powerpc.cc (Target_powerpc::is_elfv2_localentry0): Test
+       non_zero_localentry.
+       (Target_powerpc::resolve): New function.
+       (powerpc_info): Set has_resolve for 64-bit.
+       * target.h (Sized_target::resolve): Return bool.
+       * resolve.cc (Symbol_table::resolve): Continue with normal
+       processing when target resolve returns false.
+       * symtab.h (Symbol::non_zero_localentry, set_non_zero_localentry):
+       New accessors.
+       (Symbol::non_zero_localentry_): New flag bit.
+       * symtab.cc (Symbol::init_fields): Init non_zero_localentry_.
+
 2017-08-08  Romain Geissler  <romain.geissler@gmail.com>
            Alan Modra  <amodra@gmail.com>
 
@@ -39,6 +54,7 @@
 
 2017-07-31  Alan Modra  <amodra@gmail.com>
 
+       PR 21847
        * powerpc.cc (Target_powerpc::scan_relocs): Warn on --plt-localentry
        without ld.so checks.
 
index 6f610cbe8cb4c0f3eb3f83d9cad3679fadbffb6b..c29850b617aa6f3b07b9679bea122a91ba3bb4b5 100644 (file)
@@ -1026,7 +1026,8 @@ class Target_powerpc : public Sized_target<size, big_endian>
            && this->plt_localentry0()
            && gsym->type() == elfcpp::STT_FUNC
            && gsym->is_defined()
-           && gsym->nonvis() >> 3 == 0);
+           && gsym->nonvis() >> 3 == 0
+           && !gsym->non_zero_localentry());
   }
 
   bool
@@ -1051,6 +1052,22 @@ class Target_powerpc : public Sized_target<size, big_endian>
     return false;
   }
 
+  // Remember any symbols seen with non-zero localentry, even those
+  // not providing a definition
+  bool
+  resolve(Symbol* to, const elfcpp::Sym<size, big_endian>& sym, Object*,
+         const char*)
+  {
+    if (size == 64)
+      {
+       unsigned char st_other = sym.get_st_other();
+       if ((st_other & elfcpp::STO_PPC64_LOCAL_MASK) != 0)
+         to->set_non_zero_localentry();
+      }
+    // We haven't resolved anything, continue normal processing.
+    return false;
+  }
+
   int
   abiversion() const
   { return this->processor_specific_flags() & elfcpp::EF_PPC64_ABI; }
@@ -1603,7 +1620,7 @@ Target::Target_info Target_powerpc<64, true>::powerpc_info =
   true,                        // is_big_endian
   elfcpp::EM_PPC64,    // machine_code
   false,               // has_make_symbol
-  false,               // has_resolve
+  true,                        // has_resolve
   false,               // has_code_fill
   true,                        // is_default_stack_executable
   false,               // can_icf_inline_merge_sections
@@ -1631,7 +1648,7 @@ Target::Target_info Target_powerpc<64, false>::powerpc_info =
   false,               // is_big_endian
   elfcpp::EM_PPC64,    // machine_code
   false,               // has_make_symbol
-  false,               // has_resolve
+  true,                        // has_resolve
   false,               // has_code_fill
   true,                        // is_default_stack_executable
   false,               // can_icf_inline_merge_sections
index 8f4d2e333083b3d34939e0fc5fea3d9bbb4e2bca..7c2260680072c84da5b803a785adff889fd2508f 100644 (file)
@@ -266,8 +266,8 @@ Symbol_table::resolve(Sized_symbol<size>* to,
     {
       Sized_target<size, big_endian>* sized_target;
       sized_target = parameters->sized_target<size, big_endian>();
-      sized_target->resolve(to, sym, object, version);
-      return;
+      if (sized_target->resolve(to, sym, object, version))
+       return;
     }
 
   if (!object->is_dynamic())
index 43909ffeb8c2d16b976fb4328a08593b2d25fa98..7e0a3f80d2637dd987397970da3334484ef1e01e 100644 (file)
@@ -81,6 +81,7 @@ Symbol::init_fields(const char* name, const char* version,
   this->undef_binding_weak_ = false;
   this->is_predefined_ = false;
   this->is_protected_ = false;
+  this->non_zero_localentry_ = false;
 }
 
 // Return the demangled version of the symbol's name, but only
index 77552ae7ca867edf2fced51b8cc251f740b811cb..c371731b5ebf449fa74a901b0994518c5f4335c1 100644 (file)
@@ -883,6 +883,16 @@ class Symbol
   set_is_protected()
   { this->is_protected_ = true; }
 
+  // Return state of PowerPC64 ELFv2 specific flag.
+  bool
+  non_zero_localentry() const
+  { return this->non_zero_localentry_; }
+
+  // Set PowerPC64 ELFv2 specific flag.
+  void
+  set_non_zero_localentry()
+  { this->non_zero_localentry_ = true; }
+
  protected:
   // Instances of this class should always be created at a specific
   // size.
@@ -1084,6 +1094,8 @@ class Symbol
   // The visibility_ field will be STV_DEFAULT in this case because we
   // must treat it as such from outside the shared object.
   bool is_protected_  : 1;
+  // Used by PowerPC64 ELFv2 to track st_other localentry (bit 36).
+  bool non_zero_localentry_ : 1;
 };
 
 // The parts of a symbol which are size specific.  Using a template
index 5ca8435c5ba1a18e900db94208576733c47cc586..cf6d902310f9f5e22d2826fda37c87b0996ddb28 100644 (file)
@@ -852,7 +852,7 @@ class Sized_target : public Target
   // pre-existing symbol.  SYM is the new symbol, seen in OBJECT.
   // VERSION is the version of SYM.  This will only be called if
   // has_resolve() returns true.
-  virtual void
+  virtual bool
   resolve(Symbol*, const elfcpp::Sym<size, big_endian>&, Object*,
          const char*)
   { gold_unreachable(); }