shared libraries

Matt Atterbury matt at bacchus.esa.oz.au
Wed Sep 5 17:23:18 AEST 1990


Sorry if this is the 'wrong' newsgroup, but ...

    I have been thinking about shared libraries, and specifically how
    difficult it might be to implement them in a BSD4.3 'standard'
    (:-) environment using shared memory - mmap(2) i guess.

    The basic idea would be:
        take a library compiled with the equivalent of -pic (position
            independent code? - i don't actually use SUNs) (1)
        work out where we are going to locate the shared code (2)
        scan each routine
            if it uses static memory
                stick the whole routine into the stubs .a
            else
                'link' the routine into the shared code file so that it
                    is callable
                create a stub for the routine & stick it in the stubs .a (3)
        stick all the global data in the stubs .a (4)

    (1) needed so that the routine can use global data which is not
        yet 'linked' (ie. positioned).
    (2) maybe a command line arg - no need to get too sophisticated
    (3) the stub would load the register pointing to the base of the
        global data then jump to the known address for the routine

    when linking with the library, the crt0 routine (before or after
    calling _main?) would be hacked to call the initialisation routine
    for all linked shared libraries.

    when running, the shared library initialization routine(s) would
    mmap the shared code file into the fixed address.

    anyone got any other steps that would have to be performed?
    anyone got any idea what effort would be involved?
    anyone got any idea if gcc can/could do this (position independent
        code, calling initialization routines)?
    anyone got any ideas on the subject?


--
-------------------------------------------------------------------------------
Matt Atterbury [matt at bacchus.esa.oz.au]   Expert Solutions Australia, Melbourne
UUCP: ...!uunet!munnari!matt at bacchus.esa.oz.au            "klaatu barada nikto"
ARPA: matt%bacchus.esa.oz.AU at uunet.UU.NET  "life? don't talk to me about life!"



More information about the Comp.unix.internals mailing list