* gdb.base/default.exp (show version): Update the version text.
[binutils-gdb.git] / gold / symtab.cc
index 5b61152652d568abacd90cc708a25ef2b8b8ef32..68ce3b1efeeaae6287d9a3d3cc3e430775206b0e 100644 (file)
@@ -31,6 +31,7 @@ Symbol::init_fields(const char* name, const char* version,
   this->symtab_index_ = 0;
   this->dynsym_index_ = 0;
   this->got_offset_ = 0;
+  this->plt_offset_ = 0;
   this->type_ = type;
   this->binding_ = binding;
   this->visibility_ = visibility;
@@ -39,8 +40,10 @@ Symbol::init_fields(const char* name, const char* version,
   this->is_def_ = false;
   this->is_forwarder_ = false;
   this->needs_dynsym_entry_ = false;
+  this->in_reg_ = false;
   this->in_dyn_ = false;
   this->has_got_offset_ = false;
+  this->has_plt_offset_ = false;
   this->has_warning_ = false;
 }
 
@@ -57,6 +60,7 @@ Symbol::init_base(const char* name, const char* version, Object* object,
   // FIXME: Handle SHN_XINDEX.
   this->u_.from_object.shndx = sym.get_st_shndx();
   this->source_ = FROM_OBJECT;
+  this->in_reg_ = !object->is_dynamic();
   this->in_dyn_ = object->is_dynamic();
 }
 
@@ -72,6 +76,7 @@ Symbol::init_base(const char* name, Output_data* od, elfcpp::STT type,
   this->u_.in_output_data.output_data = od;
   this->u_.in_output_data.offset_is_from_end = offset_is_from_end;
   this->source_ = IN_OUTPUT_DATA;
+  this->in_reg_ = true;
 }
 
 // Initialize the fields in the base class Symbol for a symbol defined
@@ -86,6 +91,7 @@ Symbol::init_base(const char* name, Output_segment* os, elfcpp::STT type,
   this->u_.in_output_segment.output_segment = os;
   this->u_.in_output_segment.offset_base = offset_base;
   this->source_ = IN_OUTPUT_SEGMENT;
+  this->in_reg_ = true;
 }
 
 // Initialize the fields in the base class Symbol for a symbol defined
@@ -98,6 +104,7 @@ Symbol::init_base(const char* name, elfcpp::STT type,
 {
   this->init_fields(name, NULL, type, binding, visibility, nonvis);
   this->source_ = CONSTANT;
+  this->in_reg_ = true;
 }
 
 // Initialize the fields in Sized_symbol for SYM in OBJECT.
@@ -260,6 +267,10 @@ Symbol_table::resolve(Sized_symbol<size>* to, const Sized_symbol<size>* from,
   esym.put_st_other(from->visibility(), from->nonvis());
   esym.put_st_shndx(from->shndx());
   Symbol_table::resolve(to, esym.sym(), from->object(), version);
+  if (from->in_reg())
+    to->set_in_reg();
+  if (from->in_dyn())
+    to->set_in_dyn();
 }
 
 // Add one symbol from OBJECT to the symbol table.  NAME is symbol
@@ -996,7 +1007,10 @@ Symbol_table::set_dynsym_indexes(const General_options* options,
       // some symbols appear more than once in the symbol table, with
       // and without a version.
 
-      if (!sym->needs_dynsym_entry())
+      if (!sym->needs_dynsym_entry()
+          && (!options->export_dynamic()
+              || !sym->in_reg()
+              || !sym->is_externally_visible()))
        sym->set_dynsym_index(-1U);
       else if (!sym->has_dynsym_index())
        {
@@ -1078,6 +1092,14 @@ Symbol_table::sized_finalize(unsigned index, off_t off, Stringpool* pool)
       if (sym->has_symtab_index())
        continue;
 
+      if (!sym->in_reg())
+       {
+         gold_assert(!sym->has_symtab_index());
+         sym->set_symtab_index(-1U);
+         gold_assert(sym->dynsym_index() == -1U);
+         continue;
+       }
+
       typename Sized_symbol<size>::Value_type value;
 
       switch (sym->source())