This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Linker version script turning weak symbols into strong symbols
- From: "Kevin P. Fleming" <kpfleming at digium dot com>
- To: binutils at sourceware dot org
- Date: Tue, 26 May 2009 11:25:12 -0500
- Subject: Linker version script turning weak symbols into strong symbols
- Openpgp: id=05FB8DB2
I'm debugging a build issue in Asterisk, and have tracked down the
problem to this small example:
==== test2.c =====
> #include <stdio.h>
>
> static void __foo_internal(void)
> {
> printf("Test2\n");
> }
>
> void __attribute__((weak, alias("__foo_internal"))) foo(void);
>
> void test2(void)
> {
> printf("2\n");
> foo();
> }
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? 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.
--
Kevin P. Fleming
Digium, Inc. | Director of Software Technologies
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
skype: kpfleming | jabber: kpfleming@digium.com
Check us out at www.digium.com & www.asterisk.org