OSDN Git Service

Enable to track git://github.com/monaka/binutils.git
[pf3gnuchains/pf3gnuchains3x.git] / gold / symtab.h
index 544712d..f79fc8d 100644 (file)
@@ -205,6 +205,14 @@ class Symbol
   type() const
   { return this->type_; }
 
+  // Return true for function symbol.
+  bool
+  is_func() const
+  {
+    return (this->type_ == elfcpp::STT_FUNC
+           || this->type_ == elfcpp::STT_GNU_IFUNC);
+  }
+
   // Return the symbol visibility.
   elfcpp::STV
   visibility() const
@@ -253,7 +261,9 @@ class Symbol
   needs_dynsym_entry() const
   {
     return (this->needs_dynsym_entry_
-            || (this->in_reg() && this->in_dyn()));
+            || (this->in_reg()
+               && this->in_dyn()
+               && this->is_externally_visible()));
   }
 
   // Mark this symbol as needing an entry in the dynamic symbol table.
@@ -468,10 +478,10 @@ class Symbol
   bool
   is_common() const
   {
-    if (this->type_ == elfcpp::STT_COMMON)
-      return true;
     if (this->source_ != FROM_OBJECT)
       return false;
+    if (this->type_ == elfcpp::STT_COMMON)
+      return true;
     bool is_ordinary;
     unsigned int shndx = this->shndx(&is_ordinary);
     return !is_ordinary && Symbol::is_common_shndx(shndx);
@@ -543,7 +553,7 @@ class Symbol
 
     return (!parameters->doing_static_link()
            && !parameters->options().pie()
-            && this->type() == elfcpp::STT_FUNC
+            && this->is_func()
             && (this->is_from_dynobj()
                 || this->is_undefined()
                 || this->is_preemptible()));
@@ -734,7 +744,7 @@ class Symbol
     return (!parameters->options().shared()
            && parameters->options().copyreloc()
            && this->is_from_dynobj()
-           && this->type() != elfcpp::STT_FUNC);
+           && !this->is_func());
   }
 
  protected:
@@ -1168,6 +1178,31 @@ class Warnings
 class Symbol_table
 {
  public:
+  // The different places where a symbol definition can come from.
+  enum Defined
+  {
+    // Defined in an object file--the normal case.
+    OBJECT,
+    // Defined for a COPY reloc.
+    COPY,
+    // Defined on the command line using --defsym.
+    DEFSYM,
+    // Defined (so to speak) on the command line using -u.
+    UNDEFINED,
+    // Defined in a linker script.
+    SCRIPT,
+    // Predefined by the linker.
+    PREDEFINED,
+  };
+
+  // The order in which we sort common symbols.
+  enum Sort_commons_order
+  {
+    SORT_COMMONS_BY_SIZE_DESCENDING,
+    SORT_COMMONS_BY_ALIGNMENT_DESCENDING,
+    SORT_COMMONS_BY_ALIGNMENT_ASCENDING
+  };
+
   // COUNT is an estimate of how many symbosl will be inserted in the
   // symbol table.  It's ok to put 0 if you don't know; a correct
   // guess will just save some CPU by reducing hashtable resizes.
@@ -1249,7 +1284,7 @@ class Symbol_table
   // Define a special symbol based on an Output_data.  It is a
   // multiple definition error if this symbol is already defined.
   Symbol*
-  define_in_output_data(const char* name, const char* version,
+  define_in_output_data(const char* name, const char* version, Defined,
                        Output_data*, uint64_t value, uint64_t symsize,
                        elfcpp::STT type, elfcpp::STB binding,
                        elfcpp::STV visibility, unsigned char nonvis,
@@ -1258,7 +1293,7 @@ class Symbol_table
   // Define a special symbol based on an Output_segment.  It is a
   // multiple definition error if this symbol is already defined.
   Symbol*
-  define_in_output_segment(const char* name, const char* version,
+  define_in_output_segment(const char* name, const char* version, Defined,
                           Output_segment*, uint64_t value, uint64_t symsize,
                           elfcpp::STT type, elfcpp::STB binding,
                           elfcpp::STV visibility, unsigned char nonvis,
@@ -1267,7 +1302,7 @@ class Symbol_table
   // Define a special symbol with a constant value.  It is a multiple
   // definition error if this symbol is already defined.
   Symbol*
-  define_as_constant(const char* name, const char* version,
+  define_as_constant(const char* name, const char* version, Defined,
                     uint64_t value, uint64_t symsize, elfcpp::STT type,
                     elfcpp::STB binding, elfcpp::STV visibility,
                     unsigned char nonvis, bool only_if_ref,
@@ -1486,12 +1521,12 @@ class Symbol_table
   // Whether we should override a symbol, based on flags in
   // resolve.cc.
   static bool
-  should_override(const Symbol*, unsigned int, Object*, bool*);
+  should_override(const Symbol*, unsigned int, Defined, Object*, bool*);
 
   // Report a problem in symbol resolution.
   static void
   report_resolve_problem(bool is_error, const char* msg, const Symbol* to,
-                        Object* object);
+                        Defined, Object* object);
 
   // Override a symbol.
   template<int size, bool big_endian>
@@ -1504,7 +1539,7 @@ class Symbol_table
   // Whether we should override a symbol with a special symbol which
   // is automatically defined by the linker.
   static bool
-  should_override_with_special(const Symbol*);
+  should_override_with_special(const Symbol*, Defined);
 
   // Override a symbol with a special symbol.
   template<int size>
@@ -1527,7 +1562,8 @@ class Symbol_table
   // Define a symbol in an Output_data, sized version.
   template<int size>
   Sized_symbol<size>*
-  do_define_in_output_data(const char* name, const char* version, Output_data*,
+  do_define_in_output_data(const char* name, const char* version, Defined,
+                          Output_data*,
                           typename elfcpp::Elf_types<size>::Elf_Addr value,
                           typename elfcpp::Elf_types<size>::Elf_WXword ssize,
                           elfcpp::STT type, elfcpp::STB binding,
@@ -1538,7 +1574,7 @@ class Symbol_table
   template<int size>
   Sized_symbol<size>*
   do_define_in_output_segment(
-    const char* name, const char* version, Output_segment* os,
+    const char* name, const char* version, Defined, Output_segment* os,
     typename elfcpp::Elf_types<size>::Elf_Addr value,
     typename elfcpp::Elf_types<size>::Elf_WXword ssize,
     elfcpp::STT type, elfcpp::STB binding,
@@ -1549,7 +1585,7 @@ class Symbol_table
   template<int size>
   Sized_symbol<size>*
   do_define_as_constant(
-    const char* name, const char* version,
+    const char* name, const char* version, Defined,
     typename elfcpp::Elf_types<size>::Elf_Addr value,
     typename elfcpp::Elf_types<size>::Elf_WXword ssize,
     elfcpp::STT type, elfcpp::STB binding,
@@ -1575,13 +1611,13 @@ class Symbol_table
   // Allocate the common symbols, sized version.
   template<int size>
   void
-  do_allocate_commons(Layout*, Mapfile*);
+  do_allocate_commons(Layout*, Mapfile*, Sort_commons_order);
 
   // Allocate the common symbols from one list.
   template<int size>
   void
   do_allocate_commons_list(Layout*, Commons_section_type, Commons_type*,
-                          Mapfile*);
+                          Mapfile*, Sort_commons_order);
 
   // Implement detect_odr_violations.
   template<int size, bool big_endian>