making shared libs

James Helman jim at baroque.Stanford.EDU
Tue Sep 25 06:50:21 AEST 1990


A while back, I thought about creating a shared library, but changed
my mind after looking in the "Building a Shared Library" part of the
Programmer's Guide.  It appears to be quite painful to create shared
libraries under IRIX.  In particular, as I understand it:

    1) Imported symbols cannot be referenced directly.  You need to
    get a pointer into the library's data and use indirection.  Calls
    are handled transparently through a branch table created in the
    shared library.

    2) If an external symbol moves, you must relink all a.out files
    that use that shared library.  (So you have to be sure to put all
    your externally visible static data in a separate file and archive
    it in first otherwise a new string literal or compiler generated
    switch table in another object file could move them.)

    3) Every application using a shared library, gets its own private
    copy of the entire library's data section, i.e. no copy-on-write.

    4) When a shared library imports symbols from another shared
    library, calls are no longer transparent.  They must be made
    through a pointer, e.g. (*_libc_malloc)(n), and the corresponding
    initialization, e.g.  _libc_malloc = &malloc, must be part of the
    staticly linked code.  This would affect any user generated shared
    library using libc_s.

    5) Shared libraries must be preallocated regions in memory.  If
    you give out a package with your own shared library, there's no
    guarantee that someone else hasn't already used that region!!!!

Please correct me if I'm wrong on any of this.

It looks MUCH easier under SunOS.  I believe that SVR4 has improved
shared library support, but I don't know if it's compatible with Sun's
(I hope so), OSF's (?, they must have one) or SGI's current offering.
Anyone care to clue us in to what the future holds for IRIX and shared
libs.  Will IRIX be tracking SVR4 or some other UN*X "standard" in
this regard?

Thanks,

Jim Helman
Department of Applied Physics			Durand 012
Stanford University				FAX: (415) 725-3377
(jim at KAOS.stanford.edu) 			Work: (415) 723-9127



More information about the Comp.sys.sgi mailing list