From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5622 invoked by alias); 28 Jul 2006 01:21:32 -0000 Received: (qmail 5609 invoked by uid 22791); 28 Jul 2006 01:21:31 -0000 X-Spam-Check-By: sourceware.org Received: from smtp112.sbc.mail.mud.yahoo.com (HELO smtp112.sbc.mail.mud.yahoo.com) (68.142.198.211) by sourceware.org (qpsmtpd/0.31) with SMTP; Fri, 28 Jul 2006 01:21:27 +0000 Received: (qmail 50938 invoked from network); 28 Jul 2006 01:21:25 -0000 Received: from unknown (HELO lucon.org) (hjjean@sbcglobal.net@71.146.93.16 with login) by smtp112.sbc.mail.mud.yahoo.com with SMTP; 28 Jul 2006 01:21:25 -0000 Received: by lucon.org (Postfix, from userid 1000) id 778E363EE2; Thu, 27 Jul 2006 18:21:24 -0700 (PDT) Date: Fri, 28 Jul 2006 01:21:00 -0000 From: "H. J. Lu" To: Geoffrey Keating Cc: binutils@sources.redhat.com, gcc@gcc.gnu.org Subject: Re: ld -shared -Bsymbolic and C++ shared library Message-ID: <20060728012124.GA17552@lucon.org> References: <20060716172604.GB29871@lucon.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.1i Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2006-07/txt/msg00345.txt.bz2 On Thu, Jul 27, 2006 at 03:37:33PM -0700, Geoffrey Keating wrote: > "H. J. Lu" writes: > > > ld -shared -Bsymbolic will reduce number of dynamic relocations in > > a shared library. Unfortunately, it won't work correctly with C++ > > exception and maybe other language features. > > > > However, I think it is possible to make -shared -Bsymbolic to work > > for C++ by providing a way to specify a list of symbols which must > > be dynamic. We then can do > > > > # g++ -Wl,-Bsymbolic -shared -xxx "list of dynamic symbols" -o libfoo.so ... > > > > and libfoo.so written in C++ will work correctly with much fewer dynamic > > relocations. > > You may find this would be easier to use if you just had a flag which > made -Bsymbolic apply only to non-weak symbols. It doesn't work since 1. There are weak function symbols, which we do want to bind locally. 2. Weak symbols aren't required for comdat group. BTW, -Wl,-Bsymbolic can't be used since it will add DF_SYMBOLIC to shared library, which will cause dynamic linker to resolve symbols locally. H.J.