From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16477 invoked by alias); 19 Aug 2008 15:37:52 -0000 Received: (qmail 16469 invoked by uid 22791); 19 Aug 2008 15:37:52 -0000 X-Spam-Check-By: sourceware.org Received: from gv-out-0910.google.com (HELO gv-out-0910.google.com) (216.239.58.184) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 19 Aug 2008 15:37:17 +0000 Received: by gv-out-0910.google.com with SMTP id i36so9058gve.10 for ; Tue, 19 Aug 2008 08:37:14 -0700 (PDT) Received: by 10.187.222.11 with SMTP id z11mr522267faq.60.1219160233095; Tue, 19 Aug 2008 08:37:13 -0700 (PDT) Received: by 10.187.203.18 with HTTP; Tue, 19 Aug 2008 08:37:12 -0700 (PDT) Message-ID: Date: Tue, 19 Aug 2008 16:12:00 -0000 From: Arindam To: gcc-help@gcc.gnu.org Subject: Restricting symbol binding within shared object MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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-08/txt/msg00169.txt.bz2 Hi, I am using a Linux 2.6 (SuSE 9) build machine with gcc 3.3.3 installed. I have two shared libraries linked to an executable. The executable calls two functions - say bar1() in one shared lib and bar2() in another. It so happens that both bar1 and bar2 internally call a function say foo(). There is a different version of foo defined in each shared object with same signature but different internal implementation. It so happens that when both shared libs are linked to my executable, both bar1 and bar2's calls resolve to the foo defined in shared object 1. I am trying to figure out a way to resolve each call "locally" within the shared object. I tried the -Bsymbolic switch for the linker but it did not work - perhaps because this is C++ code, although the functions in question are declared with C linkage (extern "C"). Please help! - Arindam PS: I tried a round-about way of restricting which symbols are exported from each shared object - using a linker version script. I hid the "foo" symbol from the shared objects and it worked the way I wanted. However, this is not an acceptable or convenient solution. -- ----------------- A. It messes the natural order in which we read. Q. What's with it? A. Top-Posting, Q. What is the most annoying thing on emails and posts?