Shared system routines
Guy Harris
guy at rlgvax.UUCP
Sun Jul 24 18:22:53 AEST 1983
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
More information about the Comp.unix.wizards
mailing list