Annotation of sys/kern/exec_conf.c, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: exec_conf.c,v 1.18 2007/05/28 23:10:10 beck 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: extern struct emul emul_native, emul_elf32, emul_elf64, emul_aout,
! 79: emul_bsdos, emul_freebsd_aout, emul_freebsd_elf, emul_hpux,
! 80: emul_ibcs2, emul_linux_elf, emul_linux_aout, emul_netbsd_elf64,
! 81: emul_osf1, emul_sunos, emul_svr4, emul_ultrix;
! 82:
! 83: struct execsw execsw[] = {
! 84: { MAXINTERP, exec_script_makecmds, &emul_native, }, /* shell scripts */
! 85: #ifdef _KERN_DO_AOUT
! 86: #ifdef COMPAT_AOUT
! 87: { sizeof(struct exec), exec_aout_makecmds, &emul_aout },
! 88: #else
! 89: { sizeof(struct exec), exec_aout_makecmds, &emul_native }, /* a.out binaries */
! 90: #endif
! 91: #endif
! 92: #ifdef _KERN_DO_ECOFF
! 93: { ECOFF_HDR_SIZE, exec_ecoff_makecmds, &emul_native }, /* ecoff binaries */
! 94: #endif
! 95: #ifdef _KERN_DO_ELF
! 96: { sizeof(Elf32_Ehdr), exec_elf32_makecmds, &emul_native }, /* elf binaries */
! 97: #endif
! 98: #ifdef _KERN_DO_ELF64
! 99: { sizeof(Elf64_Ehdr), exec_elf64_makecmds, &emul_native }, /* elf binaries */
! 100: #ifdef COMPAT_OSF1
! 101: { sizeof(Elf64_Ehdr), exec_elf64_makecmds, &emul_osf1 },
! 102: #endif
! 103: #endif /* ELF64 */
! 104: #ifdef COMPAT_LINUX
! 105: { LINUX_AOUT_HDR_SIZE, exec_linux_aout_makecmds, &emul_linux_aout }, /* linux a.out */
! 106: { sizeof(Elf32_Ehdr), exec_linux_elf32_makecmds, &emul_linux_elf },
! 107: #endif
! 108: #ifdef COMPAT_IBCS2
! 109: { COFF_HDR_SIZE, exec_ibcs2_coff_makecmds, &emul_ibcs2 }, /* coff binaries */
! 110: { XOUT_HDR_SIZE, exec_ibcs2_xout_makecmds, &emul_ibcs2 }, /* x.out binaries */
! 111: #endif
! 112: #ifdef COMPAT_BSDOS
! 113: { BSDOS_AOUT_HDR_SIZE, exec_bsdos_aout_makecmds, &emul_bsdos }, /* bsdos */
! 114: #endif
! 115: #ifdef COMPAT_FREEBSD
! 116: { FREEBSD_AOUT_HDR_SIZE, exec_freebsd_aout_makecmds, &emul_freebsd_aout }, /* freebsd */
! 117: { sizeof(Elf32_Ehdr), exec_freebsd_elf32_makecmds, &emul_freebsd_elf },
! 118: #endif
! 119: #ifdef COMPAT_HPUX
! 120: { HPUX_EXEC_HDR_SIZE, exec_hpux_makecmds, &emul_hpux }, /* HP-UX a.out */
! 121: #endif
! 122: #ifdef COMPAT_M68K4K
! 123: { sizeof(struct exec), exec_m68k4k_makecmds, &emul_native }, /* m68k4k a.out */
! 124: #endif
! 125: #ifdef COMPAT_VAX1K
! 126: { sizeof(struct exec), exec_vax1k_makecmds, &emul_native }, /* vax1k a.out */
! 127: #endif
! 128: #ifdef COMPAT_ULTRIX
! 129: { ECOFF_HDR_SIZE, exec_ecoff_makecmds, &emul_ultrix }, /* ecoff binaries */
! 130: #endif
! 131: #ifdef COMPAT_SVR4
! 132: { sizeof(Elf32_Ehdr), exec_elf32_makecmds, &emul_svr4 }, /* elf binaries */
! 133: #endif
! 134: #ifdef COMPAT_SUNOS
! 135: { sizeof(struct exec), exec_aout_makecmds, &emul_sunos },
! 136: #endif
! 137: #ifdef LKM
! 138: { 0, NULL, NULL }, /* entries for LKMs */
! 139: { 0, NULL, NULL },
! 140: { 0, NULL, NULL },
! 141: { 0, NULL, NULL },
! 142: { 0, NULL, NULL },
! 143: #endif
! 144: };
! 145: int nexecs = (sizeof execsw / sizeof(*execsw));
! 146: int exec_maxhdrsz;
! 147:
! 148: void init_exec(void);
! 149:
! 150: void
! 151: init_exec(void)
! 152: {
! 153: int i;
! 154:
! 155: /*
! 156: * figure out the maximum size of an exec header.
! 157: * XXX should be able to keep LKM code from modifying exec switch
! 158: * when we're still using it, but...
! 159: */
! 160: for (i = 0; i < nexecs; i++)
! 161: if (execsw[i].es_check != NULL &&
! 162: execsw[i].es_hdrsz > exec_maxhdrsz)
! 163: exec_maxhdrsz = execsw[i].es_hdrsz;
! 164: }
CVSweb