Subject: CVS commit: src/sys
To: None <source-changes@NetBSD.org>
From: Emmanuel Dreyfus <manu@netbsd.org>
List: source-changes
Date: 10/19/2003 07:52:23
Module Name:	src
Committed By:	manu
Date:		Sun Oct 19 07:52:23 UTC 2003

Modified Files:
	src/sys/compat/darwin: darwin_exec.c
	src/sys/kern: exec_conf.c exec_macho.c
	src/sys/sys: exec_macho.h

Log Message:
Support Darwin static binaries (I should say: support the only Darwin
static binary: otool). Dynamic binaires have a pointer to the Mach-O
header on the top of the stack, static binaries don't have this, and
having it produced a crash.

One bugfix: the EXEC_MACHO code assumes that entry = NULL means that
the entry point has not been found in the load commands seen so far.
Therefore we need to initialized entry to NULL if we want a static binary
to discover it. (dynamic binaries were forced to iscover it because when
the intepreter load command is found, entry is updated whatever its
value was before).

One hack: Both COMPAT_MACH and COMPAT_DARWIN are willing to run Mach-O
binaries. COMPAT_MACH fails for dynamic binaries because it cannot find
the interpreter in /emul/mach. For static binaires, it will accept them
(and for Darwin static binaries, this will cause a failure). Until we
rite a test for matchinf Darwin static binaries, just swap the order of
COMPAT_MACH and COMPAT_DARWIN in the exec switch so that COMPAT_DARWIN
is tried first (this will have the advantage of speeding up program
startup). EXECSW_PRIO_{FIRST_LAST} does not seem to work...


To generate a diff of this commit:
cvs rdiff -r1.20 -r1.21 src/sys/compat/darwin/darwin_exec.c
cvs rdiff -r1.83 -r1.84 src/sys/kern/exec_conf.c
cvs rdiff -r1.27 -r1.28 src/sys/kern/exec_macho.c
cvs rdiff -r1.13 -r1.14 src/sys/sys/exec_macho.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.