gold Symbol::should_add_dynsym_entry

Alan Modra amodra@gmail.com
Wed Feb 6 00:17:00 GMT 2013


Seems to me that the following code in should_add_dynsym_entry() is
a duplicate of code setting is_defined_in_discarded_section_.
Unless is_section_included() and is_section_folded() can return
different results here than at Add_symbols time?

	* symtab.cc (Symbol::should_add_dynsym_entry): Make use of
	is_defined_in_discarded_section().  Remove unused param.  Update
	all uses.
	* symtab.h (Symbol::should_add_dynsym_entry): Update declaration.

Index: gold/symtab.cc
===================================================================
RCS file: /cvs/src/src/gold/symtab.cc,v
retrieving revision 1.168
diff -u -p -r1.168 symtab.cc
--- gold/symtab.cc	9 Sep 2012 03:43:51 -0000	1.168
+++ gold/symtab.cc	5 Feb 2013 10:18:21 -0000
@@ -335,7 +335,7 @@ Sized_symbol<size>::allocate_common(Outp
 // table.
 
 inline bool
-Symbol::should_add_dynsym_entry(Symbol_table* symtab) const
+Symbol::should_add_dynsym_entry() const
 {
   // If the symbol is only present on plugin files, the plugin decided we
   // don't need it.
@@ -352,16 +352,9 @@ Symbol::should_add_dynsym_entry(Symbol_t
   if (parameters->options().gc_sections() 
       && !parameters->options().shared()
       && this->source() == Symbol::FROM_OBJECT
-      && !this->object()->is_dynamic())
-    {
-      Relobj* relobj = static_cast<Relobj*>(this->object());
-      bool is_ordinary;
-      unsigned int shndx = this->shndx(&is_ordinary);
-      if (is_ordinary && shndx != elfcpp::SHN_UNDEF
-          && !relobj->is_section_included(shndx)
-          && !symtab->is_section_folded(relobj, shndx))
-        return false;
-    }
+      && !this->object()->is_dynamic()
+      && this->is_defined_in_discarded_section())
+    return false;
 
   // If the symbol was forced dynamic in a --dynamic-list file
   // or an --export-dynamic-symbol option, add it.
@@ -2378,7 +2371,7 @@ Symbol_table::set_dynsym_indexes(unsigne
       // some symbols appear more than once in the symbol table, with
       // and without a version.
 
-      if (!sym->should_add_dynsym_entry(this))
+      if (!sym->should_add_dynsym_entry())
 	sym->set_dynsym_index(-1U);
       else if (!sym->has_dynsym_index())
 	{
Index: gold/symtab.h
===================================================================
RCS file: /cvs/src/src/gold/symtab.h,v
retrieving revision 1.128
diff -u -p -r1.128 symtab.h
--- gold/symtab.h	18 Aug 2012 11:12:50 -0000	1.128
+++ gold/symtab.h	5 Feb 2013 10:18:21 -0000
@@ -297,7 +297,7 @@ class Symbol
   // Return whether this symbol should be added to the dynamic symbol
   // table.
   bool
-  should_add_dynsym_entry(Symbol_table*) const;
+  should_add_dynsym_entry() const;
 
   // Return whether this symbol has been seen in a regular object.
   bool

-- 
Alan Modra
Australia Development Lab, IBM



More information about the Binutils mailing list