From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21218 invoked by alias); 19 Jul 2008 02:43:07 -0000 Received: (qmail 21205 invoked by uid 22791); 19 Jul 2008 02:43:06 -0000 X-Spam-Check-By: sourceware.org Received: from dessent.net (HELO dessent.net) (69.60.119.225) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 19 Jul 2008 02:42:43 +0000 Received: from localhost.localdomain ([127.0.0.1] helo=dessent.net) by dessent.net with esmtp (Exim 4.50) id 1KK2PA-0000bN-Oo; Sat, 19 Jul 2008 02:42:40 +0000 Message-ID: <488154A0.BB3F66BB@dessent.net> Date: Sat, 19 Jul 2008 03:10:00 -0000 From: Brian Dessent Reply-To: gcc-help@gcc.gnu.org X-Mailer: Mozilla 4.79 [en] (Windows NT 5.0; U) MIME-Version: 1.0 To: Mathieu Lacage CC: gcc-help@gcc.gnu.org Subject: Re: visibility and -Wl,--version-script References: <74fef6df0807181837k7f0bd0a7s247a570b316ed864@mail.gmail.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2008-07/txt/msg00228.txt.bz2 Mathieu Lacage wrote: > g++ -L. -ltest -o maintest maintest.o It's not related to your issue, but this is wrong. The order that you specify things on the link command line matters, and -ltest needs to come after objects that reference symbols in libtest.so. In your specific situation you can get away with it, but not in other situations such as if -ltest was a static archive, or with shared libraries on non-Linux systems. > 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 , correct? 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. 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. 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. Brian