home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!ames!pacbell.com!tandem!zorch!hico2!sonyd1.Broadcast.Sony.COM!blilly.UUCP!bruce
- From: bruce@blilly.UUCP (Bruce Lilly)
- Newsgroups: comp.sys.3b1
- Subject: Re: Shared Libraries and mythical new releases
- Summary: It can be done (it already has been done).
- Message-ID: <1992Aug18.223926.5360@blilly.UUCP>
- Date: 18 Aug 92 22:39:26 GMT
- References: <l8rdpnINNdq4@skat.usc.edu> <Bt5D5u.KpG@hico2.westmark.com>
- Distribution: usa
- Organization: Bruce Lilly
- Lines: 123
-
- In article <Bt5D5u.KpG@hico2.westmark.com> kak@hico2.westmark.com (Kris A. Kugel) wrote:
- [ ... ]
- >I'm not a object code guru, so my comments may be misleading.
- >If so, could somebody out there who knows post a correction?
- >Maybe a certain amount of slack already exists in the shared libraries.
-
- In article <1212@icus.ICUS.COM> lenny@icus.ICUS.COM (Lenny Tropiano) wrote:
- [ ... ]
- Again, this is posted for Alex Crain, reply to him, not me. His postings
- never hit the "net-at-large", so I'm posting them on his behalf.
- [ ... ] [those who can't read lines beginning with 'X' can filter the rest through 'sed -e "s/^X//"']
- X.TH shlib 4 UNIX-PC "CTIX 3.51"
- X.SH NAME
- Xshlib - the system shared libraries
- X.SH SYNTAX
- Xld /lib/crt0s.o /lib/shlib.ifile
- X.SH DESCRIPTION
- XThe unixpc employees a single shared library to reduce the size of
- Xexecutable programs. As distributed, the shared library contains
- Xmuch (but not all) of
- X.I libc.a ,
- X.I libtermlib.a
- Xand
- X.I libcurses.a .
- XWhile useful in reducing the size of executables, using the shared library
- Xcan be frustrating to programmers because (a) it is not a complete library
- Xand (b) trying to link with the shared library
- X.I and
- Xthe regular libc.a is not a trivial task, in some instances.
- X
- XSpecifically, the shared library (/lib/shlib) is a compiled object that
- Xis mapped into a constant piece of
- X.I "virtual memory" .
- XThat is, the code in /lib/shlib appears at the same virtual address in every
- Xprogram that accesses it. Since this address space (0x300000-0x380000) is
- Xoutside of the space normally used by executing programs, it goes unnoticed
- Xif it is not referenced. Furthermore, this address range (like any other) is
- Xdemand paged, so the library code is swapped out if it is not used.
- X
- X.SH CONSTRUCTION
- XThe shared library is a normal 3 part (TEXT, DATA and BSS) object file.
- XThe DATA and BSS sections are continuous and begin at virtual address 0x300000.
- XThe TEXT area begins at virtual address 0x310000.
- XThe first object in the text area is a jump table, which indexes the other
- Xfunctions in the library. The presence of the jump table enables function
- Xaddresses to remain constant, even if the library is recompiled or reordered.
- X
- X.SH MODIFICATION
- XThe shared library is loaded on boot from the file /lib/shlib. This object
- Xcan be any non-relocatable object (created via /bin/ld).
- XFor backward compatibility, is is recommend that any modifications to the
- Xlibrary be in the form of additions to the existing library (This is so
- Xthat the existing software will continue to work).
- X
- XThe rules of thumb for modifying the library are:
- X.RS
- X.HP
- X(a) maintain 3 sections (TEXT, DATA and BSS) as there is no specification
- Xregarding non-standard sections.
- X.HP
- X(b) Always
- X.I append
- Xdata to sections. For compatibility, the new sections must overlay the old
- Xones perfectly, with new data overlaying previously unallocated space.
- X.RE
- X
- XAn example shared library is shown below:
- X.TS
- Xtab(@);
- Xcb cb
- Xc|l|l|
- Xc|l|l|
- Xc|l|l|
- Xc|l|l|
- Xc|l|l|
- Xc|l|l|
- Xc|l|l|
- Xc|l|l|
- Xc|l|l|
- Xc l
- Xc|l|l|.
- XAddress Range@Description@Section
- X@_@_
- X@New Text area@
- X0x330000@New Jump Table@
- X@_@
- X@*avail*@Text
- X@_@
- X@Old Text@
- X0x310000@Old Jump Table@
- X@_@_
- X@
- X@_@_
- X@New BSS@BSS
- X@_@_
- X@New Data@
- X@_@DATA
- X0x300000@Old DATA AND BSS@
- X@_@_
- X.TE
- X
- XNote that the old sections are aligned to the same addresses that they
- Xwere before, and that new sections have been fitted around them. This example
- Xuses a second jump table rather then appending to the first one because it
- Xassumes that source for the first library is unavailable. Having the second
- Xjump table (aligned at 0x330000 for neatness) means that further modification
- Xof the table is a trivial matter of adding indexes to the jump table and
- Xrecompiling.
- X
- X.SH FILES
- X.nf
- X/lib/shlib
- X/lib/shlib.ifile
- X.fi
- [ ... ]
- =============================================================
-
- See shlib.sh.Z on osu-cis or any other Unix-pc.sources archive
- site.
-
- --
- Bruce Lilly blilly!bruce@Broadcast.Sony.COM
- ...uunet!sonyusa!sonyd1!blilly!bruce
-