Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 6 Feb 1997 15:07:27 -0700 (MST)
From:      Terry Lambert <terry@lambert.org>
To:        msmith@atrad.adelaide.edu.au (Michael Smith)
Cc:        StevenR362@aol.com, msmith@atrad.adelaide.edu.au, rcarter@consys.com, current@freebsd.org
Subject:   Re: linux ELF codine no go on 2.2 Gamma
Message-ID:  <199702062207.PAA18009@phaeton.artisoft.com>
In-Reply-To: <199702060627.QAA01550@genesis.atrad.adelaide.edu.au> from "Michael Smith" at Feb 6, 97 04:57:12 pm

next in thread | previous in thread | raw e-mail | index | archive | help
> >      I've been wondering if there is any way to abuse the filesystem to
> > identify
> > Linux, SCO, and BSDI binaries.  Why not make the assumption in the
> > kernel that any binary loaded from /compat/[linux,sco,bsdi] is an elf binary
> > of the type denoted by the subdirectory.  This would eliminate any need
> > to brand the binaries.  You would just install them under the appropriate
> > subdirectory of /compat.  This makes the implicit and reasonable assumption
> > that any elf binary not under /compat is a native FreeBSD one.
> 
> I've already proposed this; I was assuming that SOS had already done it.
> 
> If there's no major disagreement, I'll look at adding the code to
> imgact_elf.c at some point soonish.

% ln -s /compat/linux/.../somebinary ~/bin/somename
% rehash
% somename

... BOOM!

The "where's it from" inheritance can't work across symlinks because
the symlink lookup is implemented as two function buffer recursion
instead of as real recursion.

Also, if I type "foo", it doesn't look for "foo" in my path, then for
"foo" in the same path in the compat hierarchy using the subdirectories
of compat as virtual "/".  The reason "compat" works at all is that
it adulterates the path lookup using system calls *in the emulator's
system call table*.  If you aren't running the program from a Linux
binary (for instance, a Linux binary for your shell), then it won't
look in compat when trying to find the program to run it.

You *could* write a Linux-branded glue program that loaded a program
of the same name that wasn't itself, and link the glue program into
the regular path, linked as the name of the linux binary you wanted
to load.  Then you would load the glue program from the FreeBSD lookup,
and the glue program would look up again based on argv[ 0], and if it
found its name and it wasn't the glue program, it would exec the program
in question.  This would even work for symlinks.

But it's one mother of a kludge to get arough changing the ld program
with the patches that John Polstra already submitted to the Linux and
GNU people.  8-).


					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?199702062207.PAA18009>