gas/testsuite/
[deliverable/binutils-gdb.git] / gold / symtab.h
index 7d99cd52bb61303d002ad5760ee73d119beaefde..043fb50f2288c3e2930f96f268a65f651f3915fd 100644 (file)
@@ -577,6 +577,48 @@ class Symbol
     return false;
   }
 
+  // Whether we should use the PLT offset associated with a symbol for
+  // a relocation.  IS_NON_PIC_REFERENCE is true if this is a non-PIC
+  // reloc--the same set of relocs for which we would pass NON_PIC_REF
+  // to the needs_dynamic_reloc function.
+
+  bool
+  use_plt_offset(bool is_non_pic_reference) const
+  {
+    // If the symbol doesn't have a PLT offset, then naturally we
+    // don't want to use it.
+    if (!this->has_plt_offset())
+      return false;
+
+    // If we are going to generate a dynamic relocation, then we will
+    // wind up using that, so no need to use the PLT entry.
+    if (this->needs_dynamic_reloc(FUNCTION_CALL
+                                 | (is_non_pic_reference
+                                    ? NON_PIC_REF
+                                    : 0)))
+      return false;
+
+    // If the symbol is from a dynamic object, we need to use the PLT
+    // entry.
+    if (this->is_from_dynobj())
+      return true;
+
+    // If we are generating a shared object, and this symbol is
+    // undefined or preemptible, we need to use the PLT entry.
+    if (parameters->options().shared()
+       && (this->is_undefined() || this->is_preemptible()))
+      return true;
+
+    // If this is a weak undefined symbol, we need to use the PLT
+    // entry; the symbol may be defined by a library loaded at
+    // runtime.
+    if (this->is_weak_undefined())
+      return true;
+
+    // Otherwise we can use the regular definition.
+    return false;
+  }
+
   // Given a direct absolute static relocation against
   // the global symbol, where a dynamic relocation is needed, this
   // function returns whether a relative dynamic relocation can be used.
@@ -1086,14 +1128,16 @@ class Symbol_table
   // the symbol table.  SYMS is the symbols, SYMNDX_OFFSET is the
   // offset in the symbol table of the first symbol, SYM_NAMES is
   // their names, SYM_NAME_SIZE is the size of SYM_NAMES.  This sets
-  // SYMPOINTERS to point to the symbols in the symbol table.
+  // SYMPOINTERS to point to the symbols in the symbol table.  It sets
+  // *DEFINED to the number of defined symbols.
   template<int size, bool big_endian>
   void
   add_from_relobj(Sized_relobj<size, big_endian>* relobj,
                  const unsigned char* syms, size_t count,
                  size_t symndx_offset, const char* sym_names,
                  size_t sym_name_size,
-                 typename Sized_relobj<size, big_endian>::Symbols*);
+                 typename Sized_relobj<size, big_endian>::Symbols*,
+                 size_t* defined);
 
   // Add COUNT dynamic symbols from the dynamic object DYNOBJ to the
   // symbol table.  SYMS is the symbols.  SYM_NAMES is their names.
@@ -1105,7 +1149,9 @@ class Symbol_table
                  const unsigned char* syms, size_t count,
                  const char* sym_names, size_t sym_name_size,
                  const unsigned char* versym, size_t versym_size,
-                 const std::vector<const char*>*);
+                 const std::vector<const char*>*,
+                 typename Sized_relobj<size, big_endian>::Symbols*,
+                 size_t* defined);
 
   // Define a special symbol based on an Output_data.  It is a
   // multiple definition error if this symbol is already defined.
@@ -1288,8 +1334,7 @@ class Symbol_table
 
   template<int size, bool big_endian>
   void
-  resolve(Sized_symbol<size>* to, const Sized_symbol<size>* from,
-          const char* version);
+  resolve(Sized_symbol<size>* to, const Sized_symbol<size>* from);
 
   // Record that a symbol is forced to be local by a version script.
   void
This page took 0.03379 seconds and 4 git commands to generate.