Building shared Libraries

Jim Herson herson at erg.sri.com
Sat Jan 12 05:42:25 AEST 1991


A few questions about building shared libraries. In particular I'm
confused on how to build the .sa files.

It seems that it's important to separate out shared/read-write data from
shared/read-only text. If you mix the two much of the library won't be
shared. 

Initialized exported (C global) variables need to be broken out into a
separate .c file. This file is compiled/linked into both the .so and .sa
files. Question: why do the globals  need to go into both files? Why
aren't un-initialized exported variables handled in the same way? How are
initialized and uninitialized static variables handled within a procedure
and within a module?

There also seems to be an efficient way to allocate string constants.
That is to make strings read-only data. xstr() yanks out all source code
strings and replaces it with a reference to a (newly created) global
string table called xstr[]. Then a file sx.c is produced with the
definition and initialization of this xstr[] global string table.
Question: how should this sx.c file be compiled? Should the -R (read-only
initialization data) compile flag be set for xs.c? Should the -R flag be
set for all modules within the library? Does the xs.o file go into the .so
library only or both the .so and .sa libraries?

Finally, is there anyway to get a link map inorder to verify the
efficiency of the shared library? Which variables are read-only. Which
procedures share the same physical page etc. 

The only documentation I've been able to locate is the ld() man page and 
chapter one of the Programming Utilities and Libraries manual. Are there
any other references out there?


Thanks,
Jim Herson <HERSON at ERG.SRI.COM>



More information about the Comp.sys.sun mailing list