Fix build failure in inf-ptrace.c.
[binutils-gdb.git] / gold / symtab.h
index 2beece8035f7d8ad2eec9cbc1e82e2e170a98a29..f79fc8d26533ea2def468abb4f2d475b4de5e267 100644 (file)
@@ -220,8 +220,8 @@ class Symbol
 
   // Set the visibility.
   void
-  set_visibility(elfcpp::STV vis)
-  { this->visibility_ = vis; }
+  set_visibility(elfcpp::STV visibility)
+  { this->visibility_ = visibility; }
 
   // Override symbol visibility.
   void
@@ -261,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.
@@ -368,15 +370,15 @@ class Symbol
   unsigned int
   got_offset(unsigned int got_type) const
   {
-    unsigned int got_off = this->got_offsets_.get_offset(got_type);
-    gold_assert(got_off != -1U);
-    return got_off;
+    unsigned int got_offset = this->got_offsets_.get_offset(got_type);
+    gold_assert(got_offset != -1U);
+    return got_offset;
   }
 
   // Set the GOT offset of this symbol.
   void
-  set_got_offset(unsigned int got_type, unsigned int got_off)
-  { this->got_offsets_.set_offset(got_type, got_off); }
+  set_got_offset(unsigned int got_type, unsigned int got_offset)
+  { this->got_offsets_.set_offset(got_type, got_offset); }
 
   // Return whether this symbol has an entry in the PLT section.
   bool
@@ -393,10 +395,10 @@ class Symbol
 
   // Set the PLT offset of this symbol.
   void
-  set_plt_offset(unsigned int plt_off)
+  set_plt_offset(unsigned int plt_offset)
   {
     this->has_plt_offset_ = true;
-    this->plt_offset_ = plt_off;
+    this->plt_offset_ = plt_offset;
   }
 
   // Return whether this dynamic symbol needs a special value in the
@@ -432,10 +434,10 @@ class Symbol
     bool is_ordinary;
     if (this->source_ != FROM_OBJECT)
       return this->source_ != IS_UNDEFINED;
-    unsigned int sec_shndx = this->shndx(&is_ordinary);
+    unsigned int shndx = this->shndx(&is_ordinary);
     return (is_ordinary
-           ? sec_shndx != elfcpp::SHN_UNDEF
-           : !Symbol::is_common_shndx(sec_shndx));
+           ? shndx != elfcpp::SHN_UNDEF
+           : !Symbol::is_common_shndx(shndx));
   }
 
   // Return true if this symbol is from a dynamic object.
@@ -476,13 +478,13 @@ 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 sec_shndx = this->shndx(&is_ordinary);
-    return !is_ordinary && Symbol::is_common_shndx(sec_shndx);
+    unsigned int shndx = this->shndx(&is_ordinary);
+    return !is_ordinary && Symbol::is_common_shndx(shndx);
   }
 
   // Return whether this symbol can be seen outside this object.
@@ -1004,14 +1006,14 @@ class Sized_symbol : public Symbol
 
   // Set the symbol size.  This is used when resolving common symbols.
   void
-  set_symsize(Size_type symsz)
-  { this->symsize_ = symsz; }
+  set_symsize(Size_type symsize)
+  { this->symsize_ = symsize; }
 
   // Set the symbol value.  This is called when we store the final
   // values of the symbols into the symbol table.
   void
-  set_value(Value_type val)
-  { this->value_ = val; }
+  set_value(Value_type value)
+  { this->value_ = value; }
 
   // Allocate a common symbol by giving it a location in the output
   // file.
@@ -1176,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.
@@ -1184,8 +1211,8 @@ class Symbol_table
   ~Symbol_table();
 
   void
-  set_icf(Icf* _icf)
-  { this->icf_ = _icf;}
+  set_icf(Icf* icf)
+  { this->icf_ = icf;}
 
   Icf*
   icf() const
@@ -1196,8 +1223,8 @@ class Symbol_table
   is_section_folded(Object* obj, unsigned int shndx) const;
 
   void
-  set_gc(Garbage_collection* garbage)
-  { this->gc_ = garbage; }
+  set_gc(Garbage_collection* gc)
+  { this->gc_ = gc; }
 
   Garbage_collection*
   gc() const
@@ -1257,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,
@@ -1266,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,
@@ -1275,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,
@@ -1494,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>
@@ -1512,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>
@@ -1535,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,
@@ -1546,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,
@@ -1557,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,
@@ -1583,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>