gdb/
[binutils-gdb.git] / gold / symtab.cc
index 984843863e8ab7f925ac94ec6a5e8855d611e8ae..c2a811f19c0be84cb5b45b56ee6e176551a1dd9d 100644 (file)
@@ -59,24 +59,23 @@ Symbol::init_fields(const char* name, const char* version,
   this->symtab_index_ = 0;
   this->dynsym_index_ = 0;
   this->got_offsets_.init();
-  this->plt_offset_ = 0;
+  this->plt_offset_ = -1U;
   this->type_ = type;
   this->binding_ = binding;
   this->visibility_ = visibility;
   this->nonvis_ = nonvis;
-  this->is_target_special_ = false;
   this->is_def_ = false;
   this->is_forwarder_ = false;
   this->has_alias_ = false;
   this->needs_dynsym_entry_ = false;
   this->in_reg_ = false;
   this->in_dyn_ = false;
-  this->has_plt_offset_ = false;
   this->has_warning_ = false;
   this->is_copied_from_dynobj_ = false;
   this->is_forced_local_ = false;
   this->is_ordinary_shndx_ = false;
   this->in_real_elf_ = false;
+  this->is_defined_in_discarded_section_ = false;
 }
 
 // Return the demangled version of the symbol's name, but only
@@ -1070,10 +1069,14 @@ Symbol_table::add_from_relobj(
 
       // A symbol defined in a section which we are not including must
       // be treated as an undefined symbol.
+      bool is_defined_in_discarded_section = false;
       if (st_shndx != elfcpp::SHN_UNDEF
          && is_ordinary
          && !relobj->is_section_included(st_shndx))
-       st_shndx = elfcpp::SHN_UNDEF;
+       {
+         st_shndx = elfcpp::SHN_UNDEF;
+         is_defined_in_discarded_section = true;
+       }
 
       // In an object file, an '@' in the name separates the symbol
       // name from the version name.  If there are two '@' characters,
@@ -1110,11 +1113,13 @@ Symbol_table::add_from_relobj(
              // The symbol name did not have a version, but the
              // version script may assign a version anyway.
              std::string version;
-             if (this->version_script_.get_symbol_version(name, &version))
+             bool is_global;
+             if (this->version_script_.get_symbol_version(name, &version,
+                                                          &is_global))
                {
-                 // The version can be empty if the version script is
-                 // only used to force some symbols to be local.
-                 if (!version.empty())
+                 if (!is_global)
+                   is_forced_local = true;
+                 else if (!version.empty())
                    {
                      ver = this->namepool_.add_with_length(version.c_str(),
                                                            version.length(),
@@ -1123,8 +1128,6 @@ Symbol_table::add_from_relobj(
                      is_default_version = true;
                    }
                }
-             else if (this->version_script_.symbol_is_local(name))
-               is_forced_local = true;
            }
        }
 
@@ -1190,6 +1193,9 @@ Symbol_table::add_from_relobj(
       if (is_forced_local)
        this->force_local(res);
 
+      if (is_defined_in_discarded_section)
+       res->set_is_defined_in_discarded_section();
+
       (*sympointers)[i] = res;
     }
 }
@@ -1226,11 +1232,13 @@ Symbol_table::add_from_pluginobj(
           // The symbol name did not have a version, but the
           // version script may assign a version anyway.
           std::string version;
-          if (this->version_script_.get_symbol_version(name, &version))
+         bool is_global;
+          if (this->version_script_.get_symbol_version(name, &version,
+                                                      &is_global))
             {
-              // The version can be empty if the version script is
-              // only used to force some symbols to be local.
-              if (!version.empty())
+             if (!is_global)
+               is_forced_local = true;
+             else if (!version.empty())
                 {
                   ver = this->namepool_.add_with_length(version.c_str(),
                                                         version.length(),
@@ -1239,8 +1247,6 @@ Symbol_table::add_from_pluginobj(
                   is_default_version = true;
                 }
             }
-          else if (this->version_script_.symbol_is_local(name))
-            is_forced_local = true;
         }
     }
 
@@ -1560,14 +1566,16 @@ Symbol_table::define_special_symbol(const char** pname, const char** pversion,
   bool is_default_version = false;
   if (*pversion == NULL)
     {
-      if (this->version_script_.get_symbol_version(*pname, &v))
+      bool is_global;
+      if (this->version_script_.get_symbol_version(*pname, &v, &is_global))
        {
-         if (!v.empty())
-           *pversion = v.c_str();
-
-         // If we get the version from a version script, then we are
-         // also the default version.
-         is_default_version = true;
+         if (is_global && !v.empty())
+           {
+             *pversion = v.c_str();
+             // If we get the version from a version script, then we
+             // are also the default version.
+             is_default_version = true;
+           }
        }
     }