This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Linker exposing private symbols


On Mon, Aug 27, 2018 at 12:02:58PM -0400, Jeffrey Walton wrote:
> On Mon, Aug 27, 2018 at 11:44 AM, Michael Matz <matz@suse.de> wrote:
> > Hi,
> >
> > On Mon, 27 Aug 2018, Jeffrey Walton wrote:
> >
> >> > That one is confusing compiling and linking.
> >>
> >> Yeah, we need to see the compile and link command. To hazard a guess, he
> >> is adding -fvisibility=hidden but after the compiler drives link he is
> >> getting unwanted symbols in the shared object. The toolchain is not
> >> doing what the user expect.
> >
> > Because the expectations are wrong.  -fvisibility=hidden is a compile time
> > option, no link time option.  It has no effect whatsoever while linking.
> >
> >> The common theme is the user explicitly requests all symbols to be
> >> private with -fvisibility=hidden
> >
> > The user might wish that that option is requesting this, but that doesn't
> > make it true.  I'm not sure what you're trying to get at.
> 
> What I am stating is the shared object does not meet expectations.
> When the compiler drives link we expect the everything to be hidden
> except what is explicitly marked public/default.

You have been told once by me and twice by Michael that the visibility
options you are passing to gcc affect code generation, not linking.

We're telling you this in the hope that it might educate you, but if
you wish to hold on to your expectations you're free to do that.  Just
don't complain when your belief that you can walk through walls
results in a sore nose.

> Here is the GCC man page on it
> (https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html):

Take note of the section.

>     -fvisibility=[default|internal|hidden|protected]
> 
>     Set the default ELF image symbol visibility to the specified
>     option—all symbols are marked with this unless overridden
>     within the code...
> 
> The compiler docs clearly state all symbols are private when the
> private option is used.
> 
> Jeff

-- 
Alan Modra
Australia Development Lab, IBM


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]