Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!ux1.cso.uiuc.edu!deimos.cis.ksu.edu!rutgers!njin!deastman From: deastman@pilot.njin.net (Don Eastman) Newsgroups: comp.unix.wizards Subject: Re: Shared Libraries Summary: A few details on SunOS Shared Libraries. Message-ID: Date: 17 Nov 89 18:35:29 GMT References: <656@augean.OZ> Organization: NJ InterCampus Network, New Brunswick, N.J. Lines: 34 In article <656@augean.OZ>, idall@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@pilot.njin.net or ...!rutgers!pilot.njin.net!deastman "If you lick it and it tastes sweet, perhaps it's candy."