xref: /openbsd-src/sys/kern/exec_conf.c (revision b2ea75c1b17e1a9a339660e7ed45cd24946b230e)
1 /*	$OpenBSD: exec_conf.c,v 1.10 1999/09/10 12:24:27 kstailey Exp $	*/
2 /*	$NetBSD: exec_conf.c,v 1.16 1995/12/09 05:34:47 cgd Exp $	*/
3 
4 /*
5  * Copyright (c) 1993, 1994 Christopher G. Demetriou
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. All advertising materials mentioning features or use of this software
17  *    must display the following acknowledgement:
18  *      This product includes software developed by Christopher G. Demetriou.
19  * 4. The name of the author may not be used to endorse or promote products
20  *    derived from this software without specific prior written permission
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #include <sys/param.h>
35 #include <sys/exec.h>
36 #include <sys/exec_script.h>
37 
38 #if defined(_KERN_DO_ECOFF)
39 #include <sys/exec_ecoff.h>
40 #endif
41 
42 #if defined(_KERN_DO_ELF) || defined(_KERN_DO_ELF64)
43 #include <sys/exec_elf.h>
44 #endif
45 
46 #ifdef COMPAT_SVR4
47 #include <compat/svr4/svr4_exec.h>
48 #endif
49 
50 #ifdef COMPAT_IBCS2
51 #include <compat/ibcs2/ibcs2_exec.h>
52 #endif
53 
54 #ifdef COMPAT_LINUX
55 #include <compat/linux/linux_exec.h>
56 #endif
57 
58 #ifdef COMPAT_BSDOS
59 #include <compat/bsdos/bsdos_exec.h>
60 #endif
61 
62 #ifdef COMPAT_FREEBSD
63 #include <compat/freebsd/freebsd_exec.h>
64 #endif
65 
66 #ifdef COMPAT_HPUX
67 #include <compat/hpux/hpux_exec.h>
68 #endif
69 
70 #ifdef COMPAT_M68K4K
71 #include <compat/m68k4k/m68k4k_exec.h>
72 #endif
73 
74 struct execsw execsw[] = {
75 #ifdef LKM
76 	{ 0, NULL, },					/* entries for LKMs */
77 	{ 0, NULL, },
78 	{ 0, NULL, },
79 	{ 0, NULL, },
80 	{ 0, NULL, },
81 #endif
82 	{ MAXINTERP, exec_script_makecmds, },		/* shell scripts */
83 #ifdef _KERN_DO_AOUT
84 	{ sizeof(struct exec), exec_aout_makecmds, },	/* a.out binaries */
85 #endif
86 #ifdef _KERN_DO_ECOFF
87 	{ ECOFF_HDR_SIZE, exec_ecoff_makecmds, },	/* ecoff binaries */
88 #endif
89 #ifdef _KERN_DO_ELF
90 	{ sizeof(Elf32_Ehdr), exec_elf_makecmds, },	/* elf binaries */
91 #endif
92 #ifdef _KERN_DO_ELF64
93 	{ sizeof(Elf64_Ehdr), exec_elf64_makecmds, },	/* elf binaries */
94 #endif
95 #ifdef COMPAT_LINUX
96 	{ LINUX_AOUT_HDR_SIZE, exec_linux_aout_makecmds, }, /* linux a.out */
97 #endif
98 #ifdef COMPAT_IBCS2
99 	{ COFF_HDR_SIZE, exec_ibcs2_coff_makecmds, },	/* coff binaries */
100 	{ XOUT_HDR_SIZE, exec_ibcs2_xout_makecmds, },	/* x.out binaries */
101 #endif
102 #ifdef COMPAT_BSDOS
103 	{ BSDOS_AOUT_HDR_SIZE, exec_bsdos_aout_makecmds, },	/* bsdos */
104 #endif
105 #ifdef COMPAT_FREEBSD
106 	{ FREEBSD_AOUT_HDR_SIZE, exec_freebsd_aout_makecmds, },	/* freebsd */
107 #endif
108 #ifdef COMPAT_HPUX
109 	{ HPUX_EXEC_HDR_SIZE, exec_hpux_makecmds, },	/* HP-UX a.out */
110 #endif
111 #ifdef COMPAT_M68K4K
112 	{ sizeof(struct exec), exec_m68k4k_makecmds, },	/* m68k4k a.out */
113 #endif
114 };
115 int nexecs = (sizeof execsw / sizeof(*execsw));
116 int exec_maxhdrsz;
117