xref: /openbsd-src/sys/kern/exec_conf.c (revision 3a3fbb3f2e2521ab7c4a56b7ff7462ebd9095ec5)
1 /*	$OpenBSD: exec_conf.c,v 1.12 2001/11/14 14:37:22 hugh 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 #ifdef COMPAT_VAX1K
75 #include <compat/vax1k/vax1k_exec.h>
76 #endif
77 
78 struct execsw execsw[] = {
79 #ifdef LKM
80 	{ 0, NULL, },					/* entries for LKMs */
81 	{ 0, NULL, },
82 	{ 0, NULL, },
83 	{ 0, NULL, },
84 	{ 0, NULL, },
85 #endif
86 	{ MAXINTERP, exec_script_makecmds, },		/* shell scripts */
87 #ifdef _KERN_DO_AOUT
88 	{ sizeof(struct exec), exec_aout_makecmds, },	/* a.out binaries */
89 #endif
90 #ifdef _KERN_DO_ECOFF
91 	{ ECOFF_HDR_SIZE, exec_ecoff_makecmds, },	/* ecoff binaries */
92 #endif
93 #ifdef _KERN_DO_ELF
94 	{ sizeof(Elf32_Ehdr), exec_elf32_makecmds, },	/* elf binaries */
95 #endif
96 #ifdef _KERN_DO_ELF64
97 	{ sizeof(Elf64_Ehdr), exec_elf64_makecmds, },	/* elf binaries */
98 #endif
99 #ifdef COMPAT_LINUX
100 	{ LINUX_AOUT_HDR_SIZE, exec_linux_aout_makecmds, }, /* linux a.out */
101 #endif
102 #ifdef COMPAT_IBCS2
103 	{ COFF_HDR_SIZE, exec_ibcs2_coff_makecmds, },	/* coff binaries */
104 	{ XOUT_HDR_SIZE, exec_ibcs2_xout_makecmds, },	/* x.out binaries */
105 #endif
106 #ifdef COMPAT_BSDOS
107 	{ BSDOS_AOUT_HDR_SIZE, exec_bsdos_aout_makecmds, },	/* bsdos */
108 #endif
109 #ifdef COMPAT_FREEBSD
110 	{ FREEBSD_AOUT_HDR_SIZE, exec_freebsd_aout_makecmds, },	/* freebsd */
111 #endif
112 #ifdef COMPAT_HPUX
113 	{ HPUX_EXEC_HDR_SIZE, exec_hpux_makecmds, },	/* HP-UX a.out */
114 #endif
115 #ifdef COMPAT_M68K4K
116 	{ sizeof(struct exec), exec_m68k4k_makecmds, },	/* m68k4k a.out */
117 #endif
118 #ifdef COMPAT_VAX1K
119 	{ sizeof(struct exec), exec_vax1k_makecmds, },	/* vax1k a.out */
120 #endif
121 };
122 int nexecs = (sizeof execsw / sizeof(*execsw));
123 int exec_maxhdrsz;
124