Shared Libraries

Don Eastman deastman at pilot.njin.net
Sat Nov 18 05:35:29 AEST 1989


In article <656 at augean.OZ>, idall at augean.OZ (Ian Dall) writes:
> 
> Share libraries seem to me a really neat idea. The implimentation,
> however, also seems non trivial. I was wondering how they could be
> implimented and had a look at the SunOs 4 man page for ld(1). They

I might be able to offer a modicum of insight into how SunOS is handling
shared libraries.  Much of my understanding comes from reading
between the widely-spaced lines of various man pages, which includes
acres of unexplained details.  So, if anyone can point out the
cracks in the ice beneath my feet, I'd appreciate it.

At start-up, crt0.o checks __DYNAMIC symbol to determine if execution-
time linking is required.  If __DYNAMIC is defined, crt0.o mmap()'s
/usr/lib/ld.so into the program's address space and begins executing
at the first text address in ld.so. 

The first step is to execute a small bootstrap routine which performs
the relocations need for ld.so.  It then proceeds to mmap() and mark
copy-on-write all required objects (libraries) named by the __DYNAMIC struct.
(This was established by ld;  see man pages for a.out & link.)

It is then in a position to relocate any remaining symbols.  (If a
.sa file exists, those initialized externs are statically linked by ld.)
Unresolved functions are resolved during first invocation, at which time,
ld.so intervenes and binds references to absolute addresses and updates
the linkage table for future calls.

>  Ian Dall           life (n). A sexually transmitted disease which afflicts
>                               some people more severely than others.
language (n). A virus from outer space.   William Burroughs

Don Eastman  deastman at pilot.njin.net or ...!rutgers!pilot.njin.net!deastman
"If you lick it and it tastes sweet, perhaps it's candy."



More information about the Comp.unix.wizards mailing list