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

Shared Libs for Mint



With X11 in mind I spent some thoughts on whether and how shared libraries
could be implemented for Mint.

My first thought was to compile the library -mbaserel and generate a stub
out of it that is linked to the binary instead of the whole library.

The stub functions would then (when first called) somehow create BSS and DATA
segments for the to be loaded lib.

The code segment of the library would be shared between applications using
the same library. That of cause requires the stub functions to fiddle around
with the basepointer in a4 so the library code accesses the right DATA/BSS
segment.

But problems arise if the shared library calls functions (passed as pointers
to the shared library routine) that are part of the text segment of the
application that is compiled -mbaserel. (One prominent candidat is the qsort
function). Then when the comparision function that is passed to qsort is
called the base pointer would still point to the DATA/BSS segment of the
library where the application code expects it to point to the app's own
DATA/BSS segment.

Any solutions or better concepts? (How do for instance Windows DLL's work?
They haven't got a virtual memory managment system either. As far as I
remeber you must tell the compiler to load the DS segment register (which
points to the data segment) on every function call...?)

One drawback of this idea is that the libary cannot contain DATA/BSS segments
greater than 64k. I don't know whether this would be still useful for things
like libXt or libX? How large are their DATA/BSS segments?


Kay.