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]

Re: Symbol versioning in dlopen modules


On Mon, Jun 03, 2002 at 04:13:17PM -0500, Zoltan Hidvegi wrote:
> H . J . Lu wrote:
> > 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.
> 
> I have used GNU ld version 2.12.90.0.7 20020423 Debian GNU/Linux from
> Debian unstable, ld-linux.so.2 from the Debian unstable glibc-2.2.5
> package, but it does not work, I attached the small example I have
> tried.  Just unpack it and run make, it will build main, lib1.so,
> lib2.so and lib3.so, and it will run main.  lib1.so and lib2.so are
> identical except that in the function names and messages lib1 is
> replaced by lib2.  main, lib1 and lib2 exports message with a version,
> and in lib3 I am trying to pick up the version of message from lib2,
> but it instead gets it from lib1.
> 
> I wish there were a way to link a dlopen module with a `fake' shared
> library, that has all the symbols expored by the main application with
> the right version number.  Linking against the fake library would
> allow the linker to pick up the symbol version from the lbrary, but
> the fake library would not actually appear as a dependency in the
> dynamic section, so it would not be loaded when I dlopen the module.
> The other nice feature is that this would allow the use of the
> --no-undefined linker flag, so that the linker could stop if there are
> any undefined references not resolved by the API exported from main.

You can't reference a versioned symbol without telling ld where that
versioned symbol comes from. Ld will drop the version in that case

# objdump --dynamic-sym lib3.so | grep message
00000000      D  *UND*  00000000              message

> 
> There are other things which seem to be real bugs.  If I remove the
> message definitions from lib1 and lib2, they will not load because the
> dynamic loader does not see the version of message defined in main.
> It looks like the @@ versions defined in main are not visible in the
> loaded modules.

Add -rdynamic to gcc.


H.J.


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