Shared Libraries: Unique to Suns??

DaviD W. Sanderson dws at margay.cs.wisc.edu
Wed Mar 27 03:41:56 AEST 1991


In article <29682 at cs.yale.edu> yarvin-norman at cs.yale.edu (Norman Yarvin) writes:
>dws at margay.cs.wisc.edu (DaviD W. Sanderson) writes:
>>  The BIG disadvantage relative to dynamic shared libraries
>>is that source code maintenance is a headache if you want to create
>>a new version of the library that can be installed and used by
>>programs already linked with an older version of the library.
>
>The Unix PC ameliorates this difficulty using stub routines.  The address to
>which a call to a shared library function is linked is the address of a jump
>statement which jumps to the real function.  All these jump statements are
>grouped together at the start of the shared library.  Thus programs compiled
>under any version of the Unix PC shared library run under any other version.

Yes, it is relatively easy to deal with functions in static shared
libraries.  However, persistent data is a different story.  There is no
(supported) equivalent concept of a "junk table" allowing an
indirection in access to data (that is transparent to the source
code).  You have to guarantee that your new data structures sit at the
same place in memory and have the *same size* as in the earlier
versions of the library.  One concrete example where this comes up is
upgrading the stdio part of libc (or any other part that uses
persistent data).  It was a real pain (so I heard, I didn't do it) to
upgrade the shared libc to handle multibyte characters (and thus
multibyte pushback) for ANSI C support, because the composition of the
existing _iob[] array could not be changed.

In order to make the guarantees about the external data you have to
separate out all the declarations of *any* persistent data into source
files separate from where the functions are defined, so that you can
group the corresponding object files at the beginning of the static
shared library.  Then whenever you add new persistent data you add the
corresponding object file onto the end of the existing data object
files.  You cannot alter the composition of the preexisting persistent
data without risking breaking compatibility with older versions of the
library.

Dynamic shared libraries impose none of these silly source code
conventions.
-- 
       ___
      / __\  U N S H I N E	           DaviD W. Sanderson
     |  |  | I N E			    dws at cs.wisc.edu
_____|  |  |_____  ________
\      / \   |__/ /////__	Fusion Powered Locomotives Made to Order
 \____/   \__|_/  \\\\\______	 (TARDIS model available at extra cost)



More information about the Comp.unix.wizards mailing list