This is the mail archive of the 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: Ensuring symbol resolution order at runtime

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 is replaced with a
library that does not define "foo", then the dynamic loader will bind
"foo" to the definition in 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: | SIP: | Skype: kpfleming
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at &

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