[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
MagiC shared libraries
Hi,
we have had a lot of discussions about shared libraries in the past.
We've
been talking about the technically best scheme, but in the end nothing
was implemented.
As far as I understand, the scheme that Howard Chu has been talking
about
would allow for shared libs to access their caller's memory, without any
need for shared-library aware code.
The main drawback of this scheme is that it requires special compilers
and linkers, and there are lots of people who don't want to stop using
compilers like Pure-C just because of that advantage.
To make things clear: if somebody is able to implement such an advanced
shared library scheme in MiNT, go ahead.
In the meantime, I have checked out MagiC's shared lib mechanism. The
results are:
1) It's simple to use
Meaning that Andreas Kromke has ignored all the issues with memory
accesses
from the library to the caller's memory.
At first, this really sounds bad. However, I've tried and succeeded to
move big parts of the C library I am using (mostly PureC's pdstdlib.lib)
into a shared library, by linking to a stub library.
Calling a shared lib function takes around 32+ bytes (depending on the
number of arguments), so only long functions qualify for this.
Using stubs allows to keep the changes transparent to the program code,
I simply link a special object file with the stubs before any other
library.
Even the ARGV parsing code has been moved into the library.
To give an example:
size c:\usr\bin\cat.ttp d:\pure-c\tools\cat.ttp
Text + Data + BSS = Dez (Hex) Name
10286 7680 16498 34464 86a0 c:\usr\bin\cat.ttp
4156 3436 16486 24078 5e0e
d:\pure-c\tools\cat.ttp
The main difference is that vsprintf and all related functions have been
moved into the shared lib.
2) It's simple to implement
Prove: I've spent parts of this weekend to integrate this shared library
scheme into MetaDOS. The code is running as an overlay loaded from
MetaDOS's CONFIG.SYS, thus I have been able to minimize the impact on
MetaDOS itself. I am using MetaDOS because it conveniently hooks into
GEMDOS anyway.
size c:\auto\slbload.ovl
Text + Data + BSS = Dez (Hex) Name
1656 384 114 2154 86a c:\auto\slbload.ovl
I will make the code for this overlay available as soon as it has been
tested by more people (I will be happy to supply a beta version to
anybody
already using the MagiC shared lib scheme).
The integration into MiNT should then be trivial.
3) It's there
It's here and it's working. Let's use it.
regards, jr