Symbol versioning in dlopen modules

H . J . Lu hjl@lucon.org
Mon Jun 3 10:56:00 GMT 2002


On Mon, Jun 03, 2002 at 12:22:11PM -0500, Zoltan Hidvegi wrote:
> I have an application running on Linux which privides an API to
> clients that it loads using dlopen.  The problem is that this
> application itself is sometimes loaded dynamically in an environment
> where functions with the same name as my API functions may exist.  To
> avoid that, was trying to use symbol versioning:
> 
> void prefix_foo(int) { ... }
> __asm__(".symver prefix_foo, foo@@myapp1.0");
> 
> Normally versioning is used in shared libraries, and when the linker
> sees a shared library linked to a target, it will find out the symbol
> versions from the shared library and replaces references to the
> unversioned symbol to the versioned references.  The problem is that
> when I link dlopen client, I use -shared to create a dynamically
> loadable module, so the API is not linked in as a shared library,
> therefore the linker cannot set the version dependencies for the
> unefined symbols in my application.  Is there a way I can specify the
> required version in the header file?  I.e., when someone includes my
> header, I would like to add something in the header that tells the
> linker that I always want to bind foo to foo@@myapp1.0.  I tried
> 

Yes, it should work. It is similar to

http://sources.redhat.com/ml/libc-alpha/2000-11/msg00260.html
http://sources.redhat.com/ml/binutils/2000-11/msg00108.html

You may have to use my Linux binutils to do it.


H.J.



More information about the Binutils mailing list