[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Shared libs.
> > > Because of these two demands, base relative addressing alone will not
> > > suffice: We can't dereference an external symbol without relocating
> > > the reference first, but since the text segment should be read-only
> > > (at least for shared libraries and shared text executables), we can't
> > > modify the text segment. Therefore we need an additional level of
> >
> > That's right. The pointer to the libraries data segment must live in
> > the executables data segment (and would be initialized at startup time
> > when the shared library is actually linked).
>
> Now tell me how do you want to load the new base pointer before
> accessing a shared library's data without compiler support?
>
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.
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.
Wolfgang
----
Wolfgang Lux
WZH Heidelberg, IBM Germany Internet: lux@heidelbg.ibm.com
+49-6221-59-4546 VNET: LUX at HEIDELBG
+49-6221-59-3200 (fax) EARN: LUX at DHDIBMIP