Subject: Re: Emulation question
To: Frode Vatvedt Fjeld <>
From: Eric Haszlakiewicz <>
List: tech-kern
Date: 07/13/2000 08:08:46
On Thu, Jul 13, 2000 at 02:59:44PM +0200, Frode Vatvedt Fjeld wrote:
> Could someone who knows please tell me how the kernel determines that
> an executable file is (for example) a linux binary, and provides
> emulation accordingly?
> Is this information somehow encoded in the file, or is it based on the
> process' behavior, like detecting a linux-type syscall or some such.
	It's encoded in the file.  Take a look at, for example, 
exec_elf32.c around line 600 or so, in the makecmds function.  The
probe function for each emulation type is called and when one decides
that the executable is one of it's kind we use that emulation.  This
hasn't always worked quite right since it's sometimes difficult to tell
what kind of binary we're looking at.  If you're interested specifically
in linux binaries you might want to take a look at the linux,probe
function in sys/compat/linux/common/linux_exec_elf32.c.  It has a couple
different ways to figure out if something is a linux binary.  (neither
of which is really the best)