Re: Restricting symbol binding within shared object

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Arindam <arindam.mukerjee@xxxxxxxxx> writes:

> 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").

-Bsymbolic should have worked.  Note that you have to use it when
linking the shared libraries.

With a newer version of gcc you can use visibility attributes.  That
is probably your best approach here.

http://gcc.gnu.org/onlinedocs/gcc-4.3.0/gcc/Function-Attributes.html#Function-Attributes

search for
    visibility ("visibility_type")

Ian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux