Bug 6859 - Symbols specified as -u <symbol> may erroneously get added to the dynsym table
Summary: Symbols specified as -u <symbol> may erroneously get added to the dynsym table
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gold (show other bugs)
Version: 2.19
: P2 normal
Target Milestone: ---
Assignee: Ian Lance Taylor
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-08-26 14:08 UTC by Kris Van Hees
Modified: 2008-08-28 14:57 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kris Van Hees 2008-08-26 14:08:14 UTC
Gold handles explicitly undefined symbols (-u <symbol>) differently from      
how the old GNU linker handles then.  With gold, if the symbol does not       
appear defined in any input object, it is added to both the symtab (symbol    
table) and the dynsym (dynamic symbol table) as an undefined symbol.  The     
old linker only adds the symbol to the symtab in that case.  It works fine if
the symbol gets defined in an input object.                     
                                                                                
The reason for this problem turns out to be the fact that during input object 
processing, "-u" symbols are checked as symbol tables are processed.  Then,   
all "-u" symbols are added as undefined symbols unless they were already      
seen (i.e. it adds all symbols that didn't appear in input object symbol      
tables).                                                                      
                                                                                
The fix for this problem turns out to be very easy: mark the "-u" symbols     
that are added after input object processing as not needing dynsym entries.

Index: gold/symtab.cc
===================================================================
RCS file: /cvs/src/src/gold/symtab.cc,v
retrieving revision 1.107
diff -r1.107 symtab.cc
176a177
>   this->dynsym_index_ = -1;
Comment 1 Kris Van Hees 2008-08-28 14:57:13 UTC
Patch commited:

2008-08-28  Kris Van Hees  <kris.van.hees@oracle.com>

        PR gold/6858
        * options.cc (General_options::finalize): Allow undefined symbols
        in shlibs if linking -shared.

        PR gold/6859
        * symtab.cc (Symbol::init_base_undefined): Mark explicitly undefined
        symbols as not needing a dynsym entry.