[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Dynamic Linking



OK, I've downloaded the source to dld, the GNU dynamic linker.  Its
a true dynamic linker - it caan load and link object and library files
at run-time, and can also unlink and unload the same.  It does it at
run-time, not load time.  Its a neat library.

It has already beeen ported to the Atari ST, however, it seems some
special calls are needed to utilize it.  Here is an idea I have to
utilize this library with some extra benefits.

  1 - Convert header files so all functions call a trap, passing a
structure to the trap function.  This structure contains the function
name, the filename where the function can be found, a specific base
register (which the called function can use to allocate data storage,
which is moveable and specific to  the app).  

  2 - The trap calls the dld program to link code into the program.  Code
is shared, and allocated from global shared memory, data areas are allocated
and a pointer to them is saved in the passed structure - the data belongs
to the application, and is free'd when the app exits, the code can be
free'd any time, even when an application that uses it is still running.  The
data segments may be moved to defrag memory (if needed).

  3 - When memory gets low, the libraries can be unloaded.  This allows all
the features of dld, plus the programmer never needs to be concerned with
when to load or unload a library, and never needs to call any init functions.
In  fact, most code should compile "out of the box".  It's almost like a
virtual memory system that makes best use of shared code and shared libs.
Just think - only 1 copy of any function in memory at any once time, and
no unused functions will ever take up memory.  

There would be a run-time penalty for this that using the regular dld would
not have, but it doesn't look like dld can share libraries.  I was curious
on everyone's comments and suggestions to this idea.  It looks doable, just
encapsulate existing code into a shareable trap interface.

CYA,
Evan Langlois
ekl@beastie.bighub.org