On 1/13/2020 11:58 AM, Paul Winalski wrote:
When was symbol preemption when loading shared objects
first
implemented in Unix? Are there versions of Unix that don't do symbol
preemption?
The behavior described was in dynamic linking as introduced in SunOS
4.0. There had been a couple of earlier shared library implementations,
notably System V Shared Libraries but I couldn't speak to whether any of
them had the behavior.
The reason the behavior is present is to (try to) preserve the behavior
of an "ld" command line with respect to how the order of library
specification impacted which definition of a given symbol was used to
resolve references to it. With archive libraries the ordering could be
used to effect interposition in sometimes obscure and questionable ways
especially when archives were unordered. With shared objects, given that
the whole object is always present, the usual intent of the ordering of
libraries with respect to interposition is preserved by having the first
definition be used to resolve all references.
(And the reason "ld"'s behavior was relevant is that the idea was to
make link editing an ongoing process as code assembled rather than a one
time thing. So yes the run-time link-editor does it but that's because
it's conceptually the functionality of the static link-editor continuing
its work to knit together the still-assembling program.)
The evolution of link editors in Solaris eventually resulted in the
ability to effect more granular scoping and binding operations,
including shared objects whose references to internal symbols could not
be interposed upon and thus perhaps reflected the behavior of other
systems mentioned in the original question.
But the interposition / preemption behavior was the one which, at the
time dynamic linking was introduced, best satisfied the "Principle of
Least Surprise".
On 1/13/2020 12:46 PM, Rico Pajarola wrote:
I believe a good proxy for
finding anything that inherited from or was inspired by this is a linker
that recognizes LD_PRELOAD.
On 1/13/2020 2:20 PM, Larry McVoy wrote:
You could, and people did, make a shared lib that
overloaded
the default gethostbyname(3) that wanted to do YP, the lib would provide
a DNS based one instead.
Handling interposition in this way turned it into an explicit feature.
Once multiple definitions for a symbol could exist in a program (or,
definitions not yet referenced), devices to permit the navigation of the
interposition like LD_PRELOAD, or the Name Service Switch, or Pluggable
Authentication Modules became things that could be built around the
functionality.
On 1/13/2020 1:04 PM, Clem Cole wrote:
@ Rico I'm failing sure ELF came from AT&T
Summit, not Sun.
Yes, SunOS 4.0 rode the a.out object file format. ELF originated at
Summit and as others have noted was a vast improvement.