Re: Splitting up a library without breaking ABI?



On Wed, 2011-08-24 at 12:05 +0200, Stef Walter wrote:
> On 08/23/2011 07:35 PM, Josselin Mouette wrote:
> > And I really mean “at the moment”; in the future the dynamic linker
> > might stop automatically looking for symbols in indirect dependencies,
> > since AFAIK it is not part of its specification to do so.
> 
> Good to know. I had a vague suspicion that this was undefined behavior
> and very likely Linux specific.

It's not.  It's a mandatory part of ELF.  To quote section 5-19 of the
System V ABI spec:

"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), 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."

There are various mechanisms to allow you to override the search order,
and other object formats may have other semantics.  For example, newer
versions of Mach-O on OSX (since 10.1 iirc) have a default behaviour of
recording the providing object for each symbol and will not recursively
resolve.

- ajax

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]