Re: rtld + static linking

From: Marcel Moolenaar <marcel_at_xcllnt.net>
Date: Wed, 26 Nov 2003 09:30:04 -0800
On Wed, Nov 26, 2003 at 04:16:06AM -0800, Terry Lambert wrote:
> > 
> > Dynamic linking works because the kernel loads and runs the dynamic
> > linker when it sees that the executable defines an interpeter.
> 
> Since I have patches to make dlopen work with static binaries, and
> it doesn't work this way, I must conclude you have not really looked
> deeply into solving the problem.

True. I did not look at aout.

> In any case, I point you to /usr/src/lib/csu/i386/crt0.c, which
> contains these lines of code:

This is aout specific code, not ELF code.

> Ether way, you still need to deal with the linker changes necessary
> to export the symbol set for all statically linked objects, and to
> force the inclusion of all archive members when statically linking,
> if one of the linked libraries is libdl, if you wanted a full
> implementation.

I think the cure is worse than the decease in this case. You don't
want the full libc linked into a static sh, simply because we need
to be able to load a shared library at runtime.

If you can get gcc and binutils to add the necessary support, then
we can talk further. Until then it's academic.

> BTW: IEEE 1003.1-2003 requires a full implementation of dlopen, and
> does not permit an exception for statically linked binaries:
> 
> http://www.opengroup.org/onlinepubs/007904975/functions/dlopen.html

Yes it does:

\begin{quote}
... Implementations may also impose specific constraints on the
construction of programs that can employ dlopen() and its related
services.
\end{quote}

> I'll also point out that the ELF specification does not define static
> linking *at all*.

I think that's because it doesn't need any special mention.

Note that staticly linked executables can be in violation of platform
runtime specifications.

-- 
 Marcel Moolenaar	  USPA: A-39004		 marcel_at_xcllnt.net
Received on Wed Nov 26 2003 - 08:30:14 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:31 UTC