This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Linker version script turning weak symbols into strong symbols
- From: Dave Korn <dave dot korn dot cygwin at googlemail dot com>
- To: "Kevin P. Fleming" <kpfleming at digium dot com>
- Cc: binutils at sourceware dot org
- Date: Tue, 26 May 2009 18:01:42 +0100
- Subject: Re: Linker version script turning weak symbols into strong symbols
- References: <4A1C17E8.9070602@digium.com>
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