Ensuring symbol resolution order at runtime
Kevin P. Fleming
kpfleming@digium.com
Fri Jan 20 22:47:00 GMT 2012
On 01/20/2012 03:52 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).
> I'd think a better approach would be to use a static variable in the
> initialization function to protect it from being called twice. Even
> better would be to have libssl's initialization functions actually
> marked as initialization functions so that they run automatically when
> the library is loaded.
No argument here; unfortunately the maintainers of OpenSSL have not seen
fit to do that, even though this problem has been known about for quite
some time. We are not the first project to have to work around the
problem in our own code, and even other projects that use OpenSSL and
produce their own libraries for consumption (PostgreSQL, for example)
have made accommodations in their libraries to allow the eventual
application using the combined libraries to be able to avoid this
complication. Unfortunately not every library that uses OpenSSL has made
these accommodations, so we need a 'belt and suspenders' approach that
we can rely on.
--
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