public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Symbol Visibility Problem in C Source File
@ 2010-11-26 18:31 Jeffrey Walton
  2010-11-26 18:35 ` Andrew Haley
  2010-11-30 18:54 ` Ian Lance Taylor
  0 siblings, 2 replies; 3+ messages in thread
From: Jeffrey Walton @ 2010-11-26 18:31 UTC (permalink / raw)
  To: gcc-help

Hi All,

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

I've read "How to use the new C++ visibility support" at
http://gcc.gnu.org/wiki/Visibility (even though this is a *C* source
file), and none of the following have helped:
    (a) declare with "extern"
    (b) visibility push/default/pop in the declaration
    (c) "__attribute__ ((visibility("default")))" on the definition.

I've also tried other Google top hits, such as the man pages,
http://linux.die.net/man/1/gcc, and
http://hirntier.blogspot.com/2008/09/gcc-visibility.html.

If this is a repeat of
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20297, what is the work
around? The bug seems kind of dated, but its being experienced in
2010.

Why is there no visibility("extern")? That seems like the hammer that
could smash this issue instead of all the juggling that's going on.

An ideas how to make the symbol external or public?

Jeff

[1] "Change symbol visibility in library (local -> external)", not yet
indexed from GCC mailing list.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Symbol Visibility Problem in C Source File
  2010-11-26 18:31 Symbol Visibility Problem in C Source File Jeffrey Walton
@ 2010-11-26 18:35 ` Andrew Haley
  2010-11-30 18:54 ` Ian Lance Taylor
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Haley @ 2010-11-26 18:35 UTC (permalink / raw)
  To: gcc-help

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Symbol Visibility Problem in C Source File
  2010-11-26 18:31 Symbol Visibility Problem in C Source File Jeffrey Walton
  2010-11-26 18:35 ` Andrew Haley
@ 2010-11-30 18:54 ` Ian Lance Taylor
  1 sibling, 0 replies; 3+ messages in thread
From: Ian Lance Taylor @ 2010-11-30 18:54 UTC (permalink / raw)
  To: noloader; +Cc: gcc-help

Jeffrey Walton <noloader@gmail.com> writes:

> Why is there no visibility("extern")? That seems like the hammer that
> could smash this issue instead of all the juggling that's going on.

visibility("default") is in essence the same.  Note that visibility only
applies to externally visible symbols--symbols that are not static.
What you are after is a way to change a static symbol to a non-static
one; there is no way to do that in the source code, short of not making
the symbol static.

Ian

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-11-30 18:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-26 18:31 Symbol Visibility Problem in C Source File Jeffrey Walton
2010-11-26 18:35 ` Andrew Haley
2010-11-30 18:54 ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).