This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Symbol versioning in dlopen modules


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

void foo(int);
__asm__(".symver foo,foo@myapp1.0");

This compiles and links, and nm shows that it wants to use
foo@myapp1.0, but it still picks up the wrong version.

Please CC me any replies, as I do not subscribe to this list.

Thanks in advance,

Zoli


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]