This is the mail archive of the binutils@sourceware.org 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: Linker version script turning weak symbols into strong symbols


Kevin P. Fleming wrote:

> document... but in spite of that, if I don't use the linker version
> script it actually works exactly as I wanted it to. I can dlopen()
> test2, call into it, and get the test2-local flavor of the function,
> then dlclose() test2/dlopen() both test2 and test3, and when I call into
> test2, I get the test3 version of the function.

> To recap:
> 
> Main executable (normal, no static linking or anything fancy) has no
> definition of 'foo' at all
> 
> Shared object number 1 has a weak symbol for 'foo', aliased to
> 'foo_internal' which is a static function in that object
> 
> Shared object number 2 has a normal symbol for foo and provides the
> implementation of foo
> 
> If the main executable dlopen()s shared object number 2 followed by
> shared object number 1, the calls to foo() from object number 1 resolve
> to the implementation in object number 2. This is all true if and only
> if I don't tell the linker to make all symbols from shared object number
> 1 'local'; doing so make the weak symbol in that object become strong.

  I think that the weakness of the symbol is probably irrelevant here, and
this is all just the dynamic loader/linker doing standard ELF symbol
interposition, isn't it?  I think the solution is probably just to allow foo
to be exported and have done with it.

    cheers,
      DaveK


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