public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Mathieu Lacage" <mathieu.lacage@gmail.com>
To: gcc-help@gcc.gnu.org
Subject: Re: visibility and -Wl,--version-script
Date: Sat, 19 Jul 2008 03:43:00 -0000	[thread overview]
Message-ID: <74fef6df0807182009k49d172c7s2ec89f4321694d8d@mail.gmail.com> (raw)
In-Reply-To: <488154A0.BB3F66BB@dessent.net>

On Fri, Jul 18, 2008 at 7:42 PM, Brian Dessent <brian@dessent.net> wrote:

>> The question, then, is whether or not what I am trying to do is
>> possible without having to define a large set of symbol aliases (I am
>> not even sure how to define a set of aliases for a class) which define
>> different visibility attributes for the original symbol and for the
>> alias symbol. The crux of the issue here is that what I am trying to
>> do is to make my library not use the GOT/PLT for any internal function
>> calls but to allow client programs to access all of the libraries'
>> public functions through the GOT/PLT. I understand that what I want to
>> do is likely to break some of the fine print of the C++ standard but,
>> I think I can live with that so, is there a way to do this ?
>
> You've read <http://people.redhat.com/drepper/dsohowto.pdf>, correct?

yes.

>
> You're confusing two things.  The version script can cause the linker to
> hide or expose symbols from the symbol table, but it does not alter
> their visibility.  Your Test::Do() and A() are still hidden and thus
> can't be exported as dynamic symbols.

yes, the output of my test program clearly shows that my expectations
were indeed invalid.

> If you want to use -fvisibility=hidden you need to arrange for default
> visibility for those symbols that you do want to export with
> __attribute__ ((visibility("default"))) or using #pragma GCC visibility
> push/pop.

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.

> But if you simply want to avoid PLT/GOT overhead for symbols not
> exported, why not just make those functions/variables static?  It has
> the same effect, and works with any compiler including gcc < 4.x which
> didn't have -fvisibility.  Of course this doesn't apply if you need to
> access the internal symbols from another object in the same library.

Yes.

Mathieu
-- 
Mathieu Lacage <mathieu.lacage@gmail.com>

  reply	other threads:[~2008-07-19  3:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-19  2:43 Mathieu Lacage
2008-07-19  3:10 ` Brian Dessent
2008-07-19  3:43   ` Mathieu Lacage [this message]
2008-07-19  7:25     ` Brian Dessent
2008-07-19 21:37       ` Mathieu Lacage

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=74fef6df0807182009k49d172c7s2ec89f4321694d8d@mail.gmail.com \
    --to=mathieu.lacage@gmail.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).