This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Restricting symbol binding within shared object
- From: Arindam <arindam dot mukerjee at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Tue, 19 Aug 2008 21:07:12 +0530
- Subject: Restricting symbol binding within shared object
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?