Ensuring symbol resolution order at runtime
Kevin P. Fleming
kpfleming@digium.com
Fri Jan 20 23:01:00 GMT 2012
On 01/20/2012 04:57 PM, Cary Coutant wrote:
>>> As long as the runtime loader sees the same libraries that the linker
>>> saw, yes, there is a guarantee. However, if lib1.so is replaced with a
>>> library that does not define "foo", then the dynamic loader will bind
>>> "foo" to the definition in lib2.so without any complaint.
>>
>> So, to be as specific as I can, not only will the runtime loader see those
>> same libraries, but it will look at them in the *same order* that the static
>> linker did (presumably because the static linker will list them in the
>> linked executable in the order it processed them, and the dynamic linker
>> follows that order).
>
> Yes. The ABI requires that:
>
> "When the dynamic linker creates the memory segments for an object
> file, the dependencies (recorded in DT_NEEDED entries of the dynamic
> structure) tell what shared objects are needed to supply the program's
> services. By repeatedly connecting referenced shared objects and their
> dependencies, the dynamic linker builds a complete process image. When
> resolving symbolic references, the dynamic linker examines the symbol
> tables with a breadth-first search. That is, it first looks at the
> symbol table of the executable program itself, then at the symbol
> tables of the DT_NEEDED entries (in order), and then at the second
> level DT_NEEDED entries, and so on. Shared object files must be
> readable by the process; other permissions are not required." [from
> http://www.sco.com/developers/gabi/latest/ch5.dynamic.html#shobj_dependencies
> ]
Thank you very much for the help; the ABI documentation reference is
especially helpful.
--
Kevin P. Fleming
Digium, Inc. | Director of Software Technologies
Jabber: kfleming@digium.com | SIP: kpfleming@digium.com | Skype: kpfleming
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at www.digium.com & www.asterisk.org
More information about the Binutils
mailing list