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: Linker version script turning weak symbols into strong symbols


Kevin P. Fleming wrote:

> Compiling this with "gcc -shared -o test2.so test2.c" results in the
> 'foo' symbol appearing in the symbol table as weak (nm reports 'W') as
> expected.
> 
> However, if I use this linker version script:
> 
>> {
>> 	local:
>> 		*;
>> };
> 
> in this way: "gcc -shared -o test2.so test2.c
> -Wl,--version-script,default.exports"
> 
> then the 'foo' symbol is turned into a text-section ('t') symbol and is
> no longer weak. Is this expected behavior? 

  IIUC, the effect of placing a symbol in the local: section is that you've
made it private, i.e. as if it had been declared 'static' in the C source file.

> If so, is there some
> reasonable method to avoid it? We use this version-script method to
> ensure that modules that are built for Asterisk do not accidentally
> expose any symbols to the global namespace unless explicitly allowed,
> but it appears to be interfering with our use of weak symbols.

  If you've made it local so that it isn't exposed in the namespace, isn't it
not going to be able to satisfy any undefined references anyway?  So does it
matter if it's not weak?

    cheers,
      DaveK


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