public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Symbols in .so even when using fvisibility=hidden
@ 2010-03-15 17:15 Robert Wohlrab
  2010-03-16 15:21 ` Ian Lance Taylor
  0 siblings, 1 reply; 5+ messages in thread
From: Robert Wohlrab @ 2010-03-15 17:15 UTC (permalink / raw)
  To: gcc-help

Hi,

I have the problem that I have a shared object which is mostly c with a
relative small part C++. It is compiled with -fvisibility=hidden and only some
small parts are exported. I noticed today that non-exported C++ symbols were
also exported. This is quite mysterious because they are 5 functions from
templates (looks related to std::vector with allocator stuff to me). The
shared object is generated by source files from mupen64plus-core (can be
found on bitbucket) using `make -C projects/unix/ all`.

Is there any way to disable that symbols? The vector is not used outside that
shared object and the interface of the shared object should be as clean as
possible. I tried already with -fvisibility-inlines-hidden but without
success.

On a Debian squeeze i386 with
gcc version 4.4.3 20100108 (prerelease) (Debian 4.4.2-9)
libstdc++6-4.4-dev 4.4.2-9

I tried to attach the list of symbols, but your filters always drop the mail 
when I send it inside the mail.
-- 
Robert Wohlrab

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

* Re: Symbols in .so even when using fvisibility=hidden
  2010-03-15 17:15 Symbols in .so even when using fvisibility=hidden Robert Wohlrab
@ 2010-03-16 15:21 ` Ian Lance Taylor
  2010-03-17  0:26   ` Robert Wohlrab
  0 siblings, 1 reply; 5+ messages in thread
From: Ian Lance Taylor @ 2010-03-16 15:21 UTC (permalink / raw)
  To: Robert Wohlrab; +Cc: gcc-help

Robert Wohlrab <robert.wohlrab@gmx.de> writes:

> I have the problem that I have a shared object which is mostly c with a
> relative small part C++. It is compiled with -fvisibility=hidden and only some
> small parts are exported. I noticed today that non-exported C++ symbols were
> also exported. This is quite mysterious because they are 5 functions from
> templates (looks related to std::vector with allocator stuff to me). The
> shared object is generated by source files from mupen64plus-core (can be
> found on bitbucket) using `make -C projects/unix/ all`.
>
> Is there any way to disable that symbols? The vector is not used outside that
> shared object and the interface of the shared object should be as clean as
> possible. I tried already with -fvisibility-inlines-hidden but without
> success.

In general this should not happen.  Can you provide a small standalone
test case which shows the problem?

Ian

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

* Re: Symbols in .so even when using fvisibility=hidden
  2010-03-16 15:21 ` Ian Lance Taylor
@ 2010-03-17  0:26   ` Robert Wohlrab
  2010-03-18 10:39     ` Ian Lance Taylor
  0 siblings, 1 reply; 5+ messages in thread
From: Robert Wohlrab @ 2010-03-17  0:26 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-help

[-- Attachment #1: Type: Text/Plain, Size: 1900 bytes --]

Ian Lance Taylor wrote:
> Robert Wohlrab <robert.wohlrab@gmx.de> writes:
> > I have the problem that I have a shared object which is mostly c with a
> > relative small part C++. It is compiled with -fvisibility=hidden and only
> > some small parts are exported. I noticed today that non-exported C++
> > symbols were also exported. This is quite mysterious because they are 5
> > functions from templates (looks related to std::vector with allocator
> > stuff to me). The shared object is generated by source files from
> > mupen64plus-core (can be found on bitbucket) using `make -C
> > projects/unix/ all`.
> >
> > Is there any way to disable that symbols? The vector is not used outside
> > that shared object and the interface of the shared object should be as
> > clean as possible. I tried already with -fvisibility-inlines-hidden but
> > without success.
> 
> In general this should not happen.  Can you provide a small standalone
> test case which shows the problem?

I am not sure what the problem really is - so it is a little bit hard to make 
a test case. I tried to create one by stripping of some files and functions. 
It also includes a debian directory because I used dpkg-gensymbols to check 
for exported symbols. debian/libtest0.symbols says that no function is 
exported (I wrote it because it is what the source says - it is not 
autogenerated), but dpkg-gensymbols will then report that 5 other functions 
were exported by libtest.so.0.

The Makefile says that visibility is hidden and the test.cpp doesn't say that 
anything should be exported.

As far as I know dpkg-gensymbols uses `objdump -T` do generate a list of 
exported functions. See debian/control for a list of symbols it reports. In my 
tests I just `tar xvf test_0.tar.gz && cd test-0 && debuild`

I tested it using binutils-gold and normal binutils, but that doesn't seem to 
change anything.
-- 
Robert Wohlrab

[-- Attachment #2: test_0.tar.gz --]
[-- Type: application/x-compressed-tar, Size: 1342 bytes --]

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

* Re: Symbols in .so even when using fvisibility=hidden
  2010-03-17  0:26   ` Robert Wohlrab
@ 2010-03-18 10:39     ` Ian Lance Taylor
  2010-03-18 11:40       ` Robert Wohlrab
  0 siblings, 1 reply; 5+ messages in thread
From: Ian Lance Taylor @ 2010-03-18 10:39 UTC (permalink / raw)
  To: Robert Wohlrab; +Cc: gcc-help

Robert Wohlrab <robert.wohlrab@gmx.de> writes:

> Ian Lance Taylor wrote:
>> Robert Wohlrab <robert.wohlrab@gmx.de> writes:
>> > I have the problem that I have a shared object which is mostly c with a
>> > relative small part C++. It is compiled with -fvisibility=hidden and only
>> > some small parts are exported. I noticed today that non-exported C++
>> > symbols were also exported. This is quite mysterious because they are 5
>> > functions from templates (looks related to std::vector with allocator
>> > stuff to me). The shared object is generated by source files from
>> > mupen64plus-core (can be found on bitbucket) using `make -C
>> > projects/unix/ all`.
>> >
>> > Is there any way to disable that symbols? The vector is not used outside
>> > that shared object and the interface of the shared object should be as
>> > clean as possible. I tried already with -fvisibility-inlines-hidden but
>> > without success.
>> 
>> In general this should not happen.  Can you provide a small standalone
>> test case which shows the problem?
>
> I am not sure what the problem really is - so it is a little bit hard to make 
> a test case. I tried to create one by stripping of some files and functions. 
> It also includes a debian directory because I used dpkg-gensymbols to check 
> for exported symbols. debian/libtest0.symbols says that no function is 
> exported (I wrote it because it is what the source says - it is not 
> autogenerated), but dpkg-gensymbols will then report that 5 other functions 
> were exported by libtest.so.0.
>
> The Makefile says that visibility is hidden and the test.cpp doesn't say that 
> anything should be exported.

Thanks for the test case.  I see what is happening.  Your class and
its functions are hidden.  What is not hidden is the standard library
template functions which your code instantiates.

Template instantations are a tricky case for visibility.  It's
possible to pass template objects from one shared library to another,
so the instantiations all have to be compatible.  And they aren't
symbols that you are defining yourself, so it's not clear whether
-fvisibility=hidden should apply to them.  So I don't know what the
right behaviour is here.

To really get what you want--to hide all the symbols, even the
implicit template instantiations--you will need to pass a version
script to the linker.  You may also want to consider
-fno-implicit-templates and -fno-implicit-inline-templates, although
then you will have to ensure that some other object instantiates the
required templates.

Ian

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

* Re: Symbols in .so even when using fvisibility=hidden
  2010-03-18 10:39     ` Ian Lance Taylor
@ 2010-03-18 11:40       ` Robert Wohlrab
  0 siblings, 0 replies; 5+ messages in thread
From: Robert Wohlrab @ 2010-03-18 11:40 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-help

Ian Lance Taylor wrote:
[..]
> Thanks for the test case.  I see what is happening.  Your class and
> its functions are hidden.  What is not hidden is the standard library
> template functions which your code instantiates.
> 
> Template instantations are a tricky case for visibility.  It's
> possible to pass template objects from one shared library to another,
> so the instantiations all have to be compatible.  And they aren't
> symbols that you are defining yourself, so it's not clear whether
> -fvisibility=hidden should apply to them.  So I don't know what the
> right behaviour is here.
> 
> To really get what you want--to hide all the symbols, even the
> implicit template instantiations--you will need to pass a version
> script to the linker.  You may also want to consider
> -fno-implicit-templates and -fno-implicit-inline-templates, although
> then you will have to ensure that some other object instantiates the
> required templates.

Thanks. I just saw that someone else already done that with ld's -version-
script
-- 
Robert Wohlrab

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

end of thread, other threads:[~2010-03-18 10:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-15 17:15 Symbols in .so even when using fvisibility=hidden Robert Wohlrab
2010-03-16 15:21 ` Ian Lance Taylor
2010-03-17  0:26   ` Robert Wohlrab
2010-03-18 10:39     ` Ian Lance Taylor
2010-03-18 11:40       ` Robert Wohlrab

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).