Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Oct 1996 12:06:01 -0700 (MST)
From:      Terry Lambert <terry@lambert.org>
To:        sos@FreeBSD.org
Cc:        msmith@atrad.adelaide.edu.au, hackers@FreeBSD.org
Subject:   Re: Linux compat issue(s)
Message-ID:  <199610151906.MAA01321@phaeton.artisoft.com>
In-Reply-To: <199610150933.LAA13406@ra.dkuug.dk> from "sos@FreeBSD.org" at Oct 15, 96 11:33:42 am

next in thread | previous in thread | raw e-mail | index | archive | help
> > Should I assume that this is the "what static ELF binary is this" problem?
> 
> Exactly, the static ELF program is run as a FreeBSD native bin, there
> is no way to know better (yet).
> I guess we'll have to provide a solution for this shortcoming in
> ELF (WHO said ELF was "the way to go" *sigh*)
> I can do a "quick&dirty"(tm) little program that marks ELF bins so that
> we can distinguish them, but it breaks the ELF std. one way or another.

With respect, Linux distinguished the SVR4 vs. Linux ELF binaries.

It does this by looking for the ld.so reference (which it always
includes so it can use dlopen/etc.) and seeing the word "linux" in
the ld.so file name reference.  I think they also look at the crt0
startup code in the static binary case.

This is actually broken.  If you read the SVR4_EABI spec, there is
a large area before the first page mapping for the program start.

Page 0 is reserved, since SVR4 typically maps the page instead of
faulting on reference (UnixWare 2.x has an undocumented kernel
configuration ption to cause page zero references to always fault
-- bet you didn't know that).

Pages after 0 and before the program start are for mapping the ld.so.
The mapping is expected to be established by the kernel -- *NOT* by
the crt0.o.  The difference is "more than enough" space -- one of those
idiotic hard-coded "magic" numbers, like "640k".

In any case, the Linux "use the ld.so name" approach will fail in the
case of the loader always providing the local ld.so for any binary
with the right magic number.


					Terry Lambert
					terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199610151906.MAA01321>