This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC 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: visibility and -Wl,--version-script


Mathieu Lacage wrote:

> Right, but if I do that, gcc will use GOT/PLT lookups to access these
> symbols even when doing accesses from within the library and that is
> precisely what I would like to avoid.

In that case you need to create a second alias of the symbol with hidden
visibility for internal use within the library.  The Drepper paper
explains how to do this in section 2.2.7.

The problem with doing this in C++ code is that the alias declaration
needs the assembler name of the function which includes the mangling,
and there's no way to automatically generate that short of compiling a
testcase and looking at the assembly output.  You could arrange for this
to be done automatically with some kind of multi-pass compilation scheme
with tons of macro magic: first run g++ -S over the source, then use a
perl/awk/whatever script to extract the mangled names of exported
functions and substitute them back into a second compilation of the same
file with the alias declarations added.  To me that sounds like a
fragile and complicated way of achieving a modest optimization.  The
wrapper function approach mentioned in that same section is probably the
best way to go in the face of C++.

Brian


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