Linker version script turning weak symbols into strong symbols
Kevin P. Fleming
kpfleming@digium.com
Tue May 26 17:54:00 GMT 2009
More information about the Binutils mailing list
Tue May 26 17:54:00 GMT 2009
- Previous message (by thread): Linker version script turning weak symbols into strong symbols
- Next message (by thread): Linker version script turning weak symbols into strong symbols
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Dave Korn wrote: > 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. That's not really the problem being solved; test3 *does* export foo, as it is the module providing the implementation of foo(). What I'm trying to achieve is that test2 can be loaded with or without test3 already being loaded, and be able to take proper action based on that, by being able to inspect the value of 'foo' and determine whether the test3 module is actually available or not. If that works, then we can go a step further and provide a local (to test2) implementation of foo() and push off the 'test whether foo is present or not' to the linker by using a weak alias. Then the code in test2 does not even need to take into account whether test3 is loaded or not, it just calls foo() and gets back success or failure. If test3 is not loaded, it will of course always receive 'failure', but that's fine. However, your assumption may very well be valid: if I define foo() as a non-aliased, non-weak symbol in test2, and repeat the test, the call to foo() from test2 *still* resolves to the foo() implementation in test3, since it was loaded first and this fits the C ODR. In spite of that, if I change test2 to not provide an alias for foo(), but instead use a plain weak symbol, then re-run the test, during the first phase (when test3 is not loaded), 'foo' in test2 is NULL, since it is a undefined weak symbol at that point. Loading test3 does not change that, as the symbol resolution for test2 has already been performed. Changing the order results in my expected behavior; test2's 'foo' now points to the implementation in test3, so the weakness of test2's 'foo' symbol is in fact being taking into account by the dynamic linker. -- Kevin P. Fleming Digium, Inc. | Director of Software Technologies 445 Jan Davis Drive NW - Huntsville, AL 35806 - USA skype: kpfleming | jabber: kpfleming@digium.com Check us out at www.digium.com & www.asterisk.org
- Previous message (by thread): Linker version script turning weak symbols into strong symbols
- Next message (by thread): Linker version script turning weak symbols into strong symbols
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list