Symbol Visibility Problem in C Source File

Andrew Haley aph@redhat.com
Fri Nov 26 18:35:00 GMT 2010


On 11/26/2010 06:10 PM, Jeffrey Walton wrote:

> I've given up trying to change visibility [1] in favor of adding a
> thunk or wrapper for test purposes. The wrapper has extern visibility,
> while the [real] function of interest is declared static in the
> compilation unit. For the wrapper, dbg_my_function (public) simply
> calls my_function (private).
> 
> The test platform is Ubuntu 10.04 (x64) fully patched with GCC 4.4.3.
> Note that there is no header file - only a C source file. And the
> project uses automake and friends.
> 
> The static archive is exporting the symbol, while the shared object is
> not exporting the symbol. Below, a capitol "T" is a exported symbol in
> the text section; and a lower "t" is a local symbol in the text
> section.
> 
>     $ nm --defined ./lib/.libs/libmylibrary.a | grep my_function
>     00000000000003f8 T dbg_my_function
>     0000000000000000 t my_function
>     $ nm --defined ./lib/.libs/libmylibrary.so | grep my_function
>     000000000003356b t dbg_my_function
>     0000000000033120 t my_function

It would help tremendously if you produced a simple test case that
illustrates the problem.  I don't know what you're doing wrong.

Andrew.



More information about the Gcc-help mailing list