Shared libraries

Anton Rang rang at cs.wisc.edu
Fri May 3 11:53:08 AEST 1991


In article <1991May2.172740.11422 at mp.cs.niu.edu> rickert at mp.cs.niu.edu (Neil Rickert) writes:
>  Unfortunately it is not that simple.  The trouble is that the text segment
>of the module contains references to the data and bss, which will be different
>for each use of the shared routines.

  This is true; also, on some architectures, it's difficult or
impossible to generate fully position-independent code.  (If you map
the library into a different spot in your address space, you may need
to "patch up" some references it makes, which suddenly makes some
pages shared and some pages not, or else forces you to make the entire
text segment non-shared.)  Hopefully these architectures are few....

  Another point which shouldn't be too hard to get right, but does
require some thought, is that one shared library may refer to routines
from another one.

>  The proper way to do this is to design the shared library so that
>all modules in it have only text segments, and zero-length bss and
>data segments.

  Given an architecture with a shared data and instruction memory, a C
compiler which puts 'const' variables into the text segment would make
this fairly painless, I think.  (Personally, I don't like variables
which are initialized at compile time but aren't constants--they
offend my sense that everything should be re-entrant.  :-)

	Anton
   
+---------------------------+------------------+-------------+----------------+
| Anton Rang (grad student) | rang at cs.wisc.edu | UW--Madison | "VMS Forever!" |
+---------------------------+------------------+-------------+----------------+



More information about the Comp.unix.internals mailing list