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

Re: Shared libs.



Wolfgang Lux wrote:

> OK. Here's my proposal how shared libraries could be made working
> under MiNT. Shared libraries are implemented in executable file which
> can be loaded using Pexec mode 3. If the library is already marked as
> a shared text executable, we'll end up with only a single instance of
> the text section of the library. Pexec 3 will also give us the actual
> size of the data and bss sections of library which must be left
> allocated.
> This loading process will be done during the (modified) startup
> sequence of the program, not by the kernel. (Note: This is excatly
> like the original Sun proposal for shared libraries --- at least if
> I've read the paper in the 4.4 BSD source tree correctly). This
> startup code will know of exactly one variable for each loaded
> library, which is statically linked into the executable. This variable
> will contain the base pointer for the libraries data. 
> The functions from the shared library are then called via stub
> routines which are statically linked into the executable and do
> nothing more than forwarding the call to the function in the library
> (which can be done via a global offset table at the beginning of the
> libraries text section) and setup the base pointer from the
> appropriate base pointer.
> As in BSD we could make this into a two stage process: The startup
> code will just link with the dynamic loader shared library, which in
> turn will load all the other libraries.

This looks a lot like my original proposal in my article
<199511162020.VAA19478@irs.inf.tu-dresden.de>, just that I had
confused Pexec mode 3 with mode 4.  However, you still deserve the
credits for adding the missing pieces and making it sound as if it
actually was workable. :-)

> What still remainsw is the access to variables in the shared libraries
> from outside of the library. If these variables were referenced from
> the main program, the dynamic loader could just patch all references
> to those variables in the executable (however, only if the executable
> is not shared itself). Otherwise we end up in modifying the references
> to those variables into defines, which call a wrapper function to
> access the variable. I don't know whether this is feasible. It depends
> on how many such references exist.

I don't like both options.  Is there a way to transmogrify external
memory references into calls to automatically-generated wrappers at
link time?

(Please forgive me if this looks like I was somewhat ignorant about
what object files look like; this is only because I _am_ somewhat
ignorant about what object files look like!)

Michael
-- 
Email: hohmuth@inf.tu-dresden.de
WWW:   http://www.inf.tu-dresden.de/~mh1/