Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1a 7/7/83; site rlgvax.UUCP Path: utzoo!linus!decvax!harpo!seismo!rlgvax!guy From: guy@rlgvax.UUCP (Guy Harris) Newsgroups: net.unix-wizards Subject: Re: Shared system routines Message-ID: <886@rlgvax.UUCP> Date: Sun, 24-Jul-83 04:22:53 EDT Article-I.D.: rlgvax.886 Posted: Sun Jul 24 04:22:53 1983 Date-Received: Sun, 24-Jul-83 10:13:54 EDT References: <392@alberta.UUCP> Organization: CCI Office Systems Group, Reston, VA Lines: 36 There was some discussion of shared libraries in UNIX a while ago. Many other operating systems do support them, and they probably do cut down on the physical memory requirements of the programs that use them. The main tricky part is that they cannot call routines outside the shared library except through an indirect pointer of some sort. If they called them using the standard subroutine call instruction provided on most machines, the address of the routine would be hardcoded into the code of the routine itself. However, this address may be different in different programs which include this routine. Furthermore, if they reference any globals they would also have to reference them through such a pointer. Some current routines might have to be modified. Another alternative is to have two data segments; one for globals referenced by the library, and one for others. The globals referenced by the library must be DEFINED (not just referenced) by the library routine; the size must be assigned at the time the library is built, not the time the program using the library is built. Also, the shared library routines must either be position-independent code (which the PDP-11 C compiler does not generate) or must always appear at the exact same place in the virtual address space in all processes. As long as the shared library routines always appeared at the same address in all programs' virtual address spaces, the exact placement wouldn't be a problem; put it wherever your machines' memory mapping hardware wants you to. I suspect the various debuggers wouldn't care too much where they appeared, except that UNIX prefers that the data segments appear before the stack segment in virtual address space - but this can probably be gotten around if necessary (I'm sure there's at least ONE machine out there that makes this difficult). I suspect it's feasible, but it'll take a lot of work. Cooperative hardware and compilers would help; you may also want to impose or use certain coding conventions within shared library routines (use of pointers to variables passed as arguments rather than global variables, for example). Guy Harris {seismo,mcnc,we13,brl-bmd,allegra}!rlgvax!guy