1 /* $NetBSD: freebsd_exec_aout.c,v 1.8 2007/12/08 18:35:58 dsl Exp $ */
4 * Copyright (c) 1993, 1994 Christopher G. Demetriou
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Christopher G. Demetriou.
18 * 4. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include <sys/cdefs.h>
34 __KERNEL_RCSID(0, "$NetBSD: freebsd_exec_aout.c,v 1.8 2007/12/08 18:35:58 dsl Exp $");
36 #include <sys/param.h>
37 #include <sys/systm.h>
40 #include <sys/exec_aout.h>
43 #define EXEC_AOUT /* to get a.out specific stuff */
46 #include <compat/freebsd/freebsd_exec.h>
49 * exec_aout_makecmds(): Check if it's an a.out-format executable.
51 * Given a lwp pointer and an exec package pointer, see if the referent
52 * of the epp is in a.out format. First check 'standard' magic numbers for
53 * this architecture. If that fails, try a CPU-dependent hook.
55 * This function, in the former case, or the hook, in the latter, is
56 * responsible for creating a set of vmcmds which can be used to build
57 * the process's vm space and inserting them into the exec package.
61 exec_freebsd_aout_makecmds(struct lwp
*l
, struct exec_package
*epp
)
65 struct exec
*execp
= epp
->ep_hdr
;
67 if (epp
->ep_hdrvalid
< sizeof(struct exec
))
70 midmag
= FREEBSD_N_GETMID(*execp
) << 16 | FREEBSD_N_GETMAGIC(*execp
);
72 /* assume FreeBSD's MID_MACHINE and [ZQNO]MAGIC is same as NetBSD's */
74 case (MID_MACHINE
<< 16) | ZMAGIC
:
75 error
= exec_aout_prep_oldzmagic(l
, epp
);
77 case (MID_MACHINE
<< 16) | QMAGIC
:
78 error
= exec_aout_prep_zmagic(l
, epp
);
80 case (MID_MACHINE
<< 16) | NMAGIC
:
81 error
= exec_aout_prep_nmagic(l
, epp
);
83 case (MID_MACHINE
<< 16) | OMAGIC
:
84 error
= exec_aout_prep_omagic(l
, epp
);
88 kill_vmcmds(&epp
->ep_vmcmds
);