This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: .symtab behaviour query


Hi bd1976,

> I have a question about binutils behaviour w.r.t the binding of symbols in
> the .symtab section in a linked elf.

I am sorry that your question has gone unanswered for so long.

> I was trying to understand the rationale behind the properties of the
> symbols in the .symtab in a linked elf. Gold and GNU-ld change the binding
> of symbols to STB_LOCAL when symbols have been resolved as having hidden
> visibility. The Gold behaviour was added in:
> https://sourceware.org/bugzilla/show_bug.cgi?id=9836, based off the
> original GNU ld behaviour added in:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=17089. I found a reference to
> this in the sun linker guide which states " A hidden symbol contained in a
> relocatable object is either removed or converted to STB_LOCAL binding when
> the object is included in an executable file or shared object. " see:
> https://docs.oracle.com/cd/E19120-01/open.solaris/819-0690/chapter6-79797/index.html
> 
> As far as I know the symbols in the .symtab section for a linked elf are
> really only there to convey debugging information to binary tools and
> debuggers.

Actually this is not true.  Other tools also examine the symbol information,
one of the most important of which is the dynamic loader (ld.so).  Also the
program itself can look at its own symbol table.  Plus you have things like
plugins and modules and dynamically loaded libraries, all of which can and do
access a program's symbol table.


> My question is: what is the rationale for the linkers behaviour
> here?

OK, so the problem is that you have a hidden symbol, which is not supposed
by reference by anything outside of its "component".  (For which you can
read "compilation unit").  But when it is linked with other files, the symbol 
tables are going to be combined.  So the hidden symbol must either be discarded,
or the symbol's type changed to STB_LOCAL, so that anyone/anything reading the
symbol table will know that this symbol is not globally visible.

Does that make sense ?

Cheers
  Nick






Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]