From a398dccb526cb5e3d7d355b866168fa6717962fe Mon Sep 17 00:00:00 2001 From: deraadt Date: Mon, 23 Dec 1996 02:42:22 +0000 Subject: [PATCH] use _{NLIST,KERN}_DO_{AOUT,ELF,ECOFF} to select binary types --- lib/libc/gen/nlist.c | 24 +++++++------- sys/arch/alpha/include/exec.h | 9 ++++-- sys/arch/amiga/include/exec.h | 9 ++++-- sys/arch/arc/include/exec.h | 13 ++++---- sys/arch/arm32/include/exec.h | 4 ++- sys/arch/atari/include/exec.h | 9 ++++-- sys/arch/hp300/include/exec.h | 9 ++++-- sys/arch/i386/include/exec.h | 9 ++++-- sys/arch/mac68k/include/exec.h | 11 +++++-- sys/arch/mvme68k/include/exec.h | 11 +++++-- sys/arch/mvme88k/include/exec.h | 7 +++-- sys/arch/pc532/include/exec.h | 4 ++- sys/arch/pmax/include/exec.h | 14 ++++----- sys/arch/powerpc/include/exec.h | 10 +++--- sys/arch/sparc/include/exec.h | 9 ++++-- sys/arch/sun3/include/exec.h | 5 +-- sys/arch/vax/include/exec.h | 4 +++ sys/conf/files | 6 ++-- sys/kern/exec_aout.c | 54 +++++--------------------------- sys/kern/exec_conf.c | 38 +++++------------------ sys/kern/exec_ecoff.c | 55 +++++---------------------------- sys/kern/exec_elf.c | 16 ++++------ sys/kern/exec_subr.c | 45 +++++++++++++++++++++++++++ sys/sys/exec.h | 3 +- sys/sys/exec_aout.h | 3 +- 25 files changed, 183 insertions(+), 198 deletions(-) diff --git a/lib/libc/gen/nlist.c b/lib/libc/gen/nlist.c index f6bee8dfb7b..d571ed8b6ba 100644 --- a/lib/libc/gen/nlist.c +++ b/lib/libc/gen/nlist.c @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: nlist.c,v 1.16 1996/10/27 20:34:37 etheisen Exp $"; +static char rcsid[] = "$OpenBSD: nlist.c,v 1.17 1996/12/23 02:42:22 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ #include @@ -47,18 +47,18 @@ static char rcsid[] = "$OpenBSD: nlist.c,v 1.16 1996/10/27 20:34:37 etheisen Exp #include #include /* pulls in nlist.h */ -#ifdef DO_ELF +#ifdef _NLIST_DO_ELF #include #include #endif -#ifdef DO_ECOFF +#ifdef _NLIST_DO_ECOFF #include #endif #define ISLAST(p) (p->n_un.n_name == 0 || p->n_un.n_name[0] == 0) -#ifdef DO_AOUT +#ifdef _NLIST_DO_AOUT int __aout_fdnlist(fd, list) register int fd; @@ -143,9 +143,9 @@ __aout_fdnlist(fd, list) munmap(strtab, strsize); return (nent); } -#endif /* DO_AOUT */ +#endif /* _NLIST_DO_AOUT */ -#ifdef DO_ECOFF +#ifdef _NLIST_DO_ECOFF #define check(off, size) ((off < 0) || (off + size > mappedsize)) #define BAD do { rv = -1; goto out; } while (0) #define BADUNMAP do { rv = -1; goto unmap; } while (0) @@ -246,9 +246,9 @@ unmap: out: return (rv); } -#endif /* DO_ECOFF */ +#endif /* _NLIST_DO_ECOFF */ -#ifdef DO_ELF +#ifdef _NLIST_DO_ELF /* * __elf_is_okay__ - Determine if ehdr really * is ELF and valid for the target platform. @@ -436,19 +436,19 @@ __elf_fdnlist(fd, list) return (nent); } -#endif /* DO_ELF */ +#endif /* _NLIST_DO_ELF */ static struct nlist_handlers { int (*fn) __P((int fd, struct nlist *list)); } nlist_fn[] = { -#ifdef DO_AOUT +#ifdef _NLIST_DO_AOUT { __aout_fdnlist }, #endif -#ifdef DO_ELF +#ifdef _NLIST_DO_ELF { __elf_fdnlist }, #endif -#ifdef DO_ECOFF +#ifdef _NLIST_DO_ECOFF { __ecoff_fdnlist }, #endif }; diff --git a/sys/arch/alpha/include/exec.h b/sys/arch/alpha/include/exec.h index bbe03bd1f7e..163eae5dad1 100644 --- a/sys/arch/alpha/include/exec.h +++ b/sys/arch/alpha/include/exec.h @@ -1,4 +1,4 @@ -/* $OpenBSD: exec.h,v 1.3 1996/07/29 22:58:42 niklas Exp $ */ +/* $OpenBSD: exec.h,v 1.4 1996/12/23 02:42:24 deraadt Exp $ */ /* $NetBSD: exec.h,v 1.1 1995/02/13 23:07:37 cgd Exp $ */ /* @@ -40,7 +40,10 @@ #define ELF_TARG_DATA ELFDATA2LSB #define ELF_TARG_MACH EM_ALPHA -#define DO_AOUT /* support a.out */ -#define DO_ECOFF /* support ECOFF */ +#define _NLIST_DO_AOUT +#define _NLIST_DO_ECOFF + +#define _KERN_DO_AOUT +#define _KERN_DO_ECOFF #endif /* !_ALPHA_EXEC_H_ */ diff --git a/sys/arch/amiga/include/exec.h b/sys/arch/amiga/include/exec.h index 5eaeccc4a3b..4850a249ac2 100644 --- a/sys/arch/amiga/include/exec.h +++ b/sys/arch/amiga/include/exec.h @@ -49,7 +49,12 @@ struct relocation_info_m68k { #define ELF_TARG_DATA ELFDATA2MSB #define ELF_TARG_MACH EM_68K -#define DO_AOUT /* support a.out */ -#define DO_ELF /* support ELF */ +#define _NLIST_DO_AOUT +#define _NLIST_DO_ELF + +#define _KERN_DO_AOUT +#if defined(COMPAT_LINUX) || defined(COMPAT_SVR4) +#define _KERN_DO_KERN +#endif #endif /* _MACHINE_EXEC_H_ */ diff --git a/sys/arch/arc/include/exec.h b/sys/arch/arc/include/exec.h index ad696244c20..18ea54bdc82 100644 --- a/sys/arch/arc/include/exec.h +++ b/sys/arch/arc/include/exec.h @@ -1,4 +1,4 @@ -/* $OpenBSD: exec.h,v 1.1.1.1 1996/06/24 09:07:17 pefo Exp $ */ +/* $OpenBSD: exec.h,v 1.2 1996/12/23 02:42:26 deraadt Exp $ */ /* $NetBSD: exec.h,v 1.5 1994/10/26 21:09:39 cgd Exp $ */ /*- @@ -48,10 +48,9 @@ #define ELF_TARG_DATA ELFDATA2LSB #define ELF_TARG_MACH EM_MIPS -/* - * This is what we want nlist(3) to handle. - */ -#define DO_AOUT /* support a.out */ -#define DO_ELF /* support ELF */ -#define DO_ECOFF /* support ECOFF */ +#define _NLIST_DO_AOUT +#define _NLIST_DO_ELF +#define _NLIST_DO_ECOFF +#define _KERN_DO_ECOFF +#define _KERN_DO_ELF diff --git a/sys/arch/arm32/include/exec.h b/sys/arch/arm32/include/exec.h index a366d2f339f..0761398bc52 100644 --- a/sys/arch/arm32/include/exec.h +++ b/sys/arch/arm32/include/exec.h @@ -60,6 +60,8 @@ struct relocation_info_arm6 { #define ELF_TARG_DATA ELFDATA2LSB #define ELF_TARG_MACH EM_ARM -#define DO_AOUT /* support a.out */ +#define _NLIST_DO_AOUT + +#define _KERN_DO_AOUT #endif /* _ARM_EXEC_H_ */ diff --git a/sys/arch/atari/include/exec.h b/sys/arch/atari/include/exec.h index 73355376a1e..2537bb10931 100644 --- a/sys/arch/atari/include/exec.h +++ b/sys/arch/atari/include/exec.h @@ -50,7 +50,12 @@ struct relocation_info_m68k { #define ELF_TARG_DATA ELFDATA2MSB #define ELF_TARG_MACH EM_68K -#define DO_AOUT /* support a.out */ -#define DO_ELF /* support ELF */ +#define _NLIST_DO_AOUT +#define _NLIST_DO_ELF + +#define _KERN_DO_AOUT +#if defined(COMPAT_LINUX) || defined(COMPAT_SVR4) +#define _KERN_DO_ELF +#endif #endif /* _MACHINE_EXEC_H_ */ diff --git a/sys/arch/hp300/include/exec.h b/sys/arch/hp300/include/exec.h index b19b2fda177..c38c46f767e 100644 --- a/sys/arch/hp300/include/exec.h +++ b/sys/arch/hp300/include/exec.h @@ -50,7 +50,12 @@ struct relocation_info_m68k { #define ELF_TARG_DATA ELFDATA2MSB #define ELF_TARG_MACH EM_68K -#define DO_AOUT /* support a.out */ -#define DO_ELF /* support ELF */ +#define _NLIST_DO_AOUT +#define _NLIST_DO_ELF + +#define _KERN_DO_AOUT +#if defined(COMPAT_LINUX) || defined(COMPAT_SVR4) +#define _KERN_DO_ELF +#endif #endif /* _MACHINE_EXEC_H_ */ diff --git a/sys/arch/i386/include/exec.h b/sys/arch/i386/include/exec.h index 3e84579c225..f7e6b6401b9 100644 --- a/sys/arch/i386/include/exec.h +++ b/sys/arch/i386/include/exec.h @@ -51,7 +51,12 @@ struct relocation_info_i386 { #define ELF_TARG_MACH EM_386 /* XXX - EM_486 is currently unused by all OSs/compilers/linkers */ -#define DO_AOUT /* support a.out */ -#define DO_ELF /* support ELF */ +#define _NLIST_DO_AOUT +#define _NLIST_DO_ELF + +#define _KERN_DO_AOUT +#if defined(COMPAT_LINUX) || defined(COMPAT_SVR4) || !defined(_KERNEL) +#define _KERN_DO_ELF +#endif #endif /* _I386_EXEC_H_ */ diff --git a/sys/arch/mac68k/include/exec.h b/sys/arch/mac68k/include/exec.h index a2867f86c67..de2b2485753 100644 --- a/sys/arch/mac68k/include/exec.h +++ b/sys/arch/mac68k/include/exec.h @@ -1,4 +1,4 @@ -/* $OpenBSD: exec.h,v 1.4 1996/05/29 03:05:00 deraadt Exp $ */ +/* $OpenBSD: exec.h,v 1.5 1996/12/23 02:42:30 deraadt Exp $ */ /* $NetBSD: exec.h,v 1.8 1996/05/05 06:17:40 briggs Exp $ */ /*- @@ -59,7 +59,12 @@ struct relocation_info_mac68k { #define ELF_TARG_DATA ELFDATA2MSB #define ELF_TARG_MACH EM_68K -#define DO_AOUT /* support a.out */ -#define DO_ELF /* support ELF */ +#define _NLIST_DO_AOUT +#define _NLIST_DO_ELF + +#define _KERN_DO_AOUT +#if defined(COMPAT_LINUX) || defined(COMPAT_SVR4) +#define _KERN_DO_ELF +#endif #endif /* _EXEC_MACHINE_ */ diff --git a/sys/arch/mvme68k/include/exec.h b/sys/arch/mvme68k/include/exec.h index d16cf3bc72b..ef5cfd8e3e2 100644 --- a/sys/arch/mvme68k/include/exec.h +++ b/sys/arch/mvme68k/include/exec.h @@ -1,4 +1,4 @@ -/* $OpenBSD: exec.h,v 1.4 1996/05/29 03:05:01 deraadt Exp $ */ +/* $OpenBSD: exec.h,v 1.5 1996/12/23 02:42:31 deraadt Exp $ */ /* * Copyright (c) 1993 Christopher G. Demetriou @@ -49,7 +49,12 @@ struct relocation_info_m68k { #define ELF_TARG_DATA ELFDATA2MSB #define ELF_TARG_MACH EM_68K -#define DO_AOUT /* support a.out */ -#define DO_ELF /* support ELF */ +#define _NLIST_DO_AOUT +#define _NLIST_DO_ELF + +#define _KERN_DO_AOUT +#if defined(COMPAT_LINUX) || defined(COMPAT_SVR4) +#define _KERN_DO_ELF +#endif #endif /* _MACHINE_EXEC_H_ */ diff --git a/sys/arch/mvme88k/include/exec.h b/sys/arch/mvme88k/include/exec.h index bf2d01aa06e..bbff3a67156 100644 --- a/sys/arch/mvme88k/include/exec.h +++ b/sys/arch/mvme88k/include/exec.h @@ -328,7 +328,10 @@ struct relocation_info #define ELF_TARG_DATA ELFDATA2MSB #define ELF_TARG_MACH EM_88K -#define DO_AOUT /* support a.out */ -#define DO_ELF /* support ELF */ +#define _NLIST_DO_AOUT +#define _NLIST_DO_ELF + +#define _KERN_DO_AOUT +#define _KERN_DO_ELF #endif /* __A_OUT_GNU_H__ */ diff --git a/sys/arch/pc532/include/exec.h b/sys/arch/pc532/include/exec.h index 780505f14f8..c8055f80b5b 100644 --- a/sys/arch/pc532/include/exec.h +++ b/sys/arch/pc532/include/exec.h @@ -51,6 +51,8 @@ struct relocation_info_pc532 { #define ELF_TARG_DATA ELFDATA2LSB #define ELF_TARG_MACH EM_32K -#define DO_AOUT /* support a.out */ +#define _NLIST_DO_AOUT + +#define _KERN_DO_AOUT #endif /* _PC532_EXEC_H_ */ diff --git a/sys/arch/pmax/include/exec.h b/sys/arch/pmax/include/exec.h index 34ffd0bf1d2..22ad23ebf19 100644 --- a/sys/arch/pmax/include/exec.h +++ b/sys/arch/pmax/include/exec.h @@ -1,4 +1,4 @@ -/* $OpenBSD: exec.h,v 1.6 1996/12/22 15:22:22 graichen Exp $ */ +/* $OpenBSD: exec.h,v 1.7 1996/12/23 02:42:34 deraadt Exp $ */ /* $NetBSD: exec.h,v 1.5 1994/10/26 21:09:39 cgd Exp $ */ /*- @@ -48,10 +48,10 @@ #define ELF_TARG_DATA ELFDATA2LSB #define ELF_TARG_MACH EM_MIPS -/* - * This is what we want nlist(3) to handle. - */ -#define DO_AOUT /* support a.out */ -#define DO_ELF /* support ELF */ -#define DO_ECOFF /* support ECOFF */ +#define _NLIST_DO_AOUT +#define _NLIST_DO_ELF +#define _NLIST_DO_ECOFF +#undef _KERN_DO_AOUT +#define _KERN_DO_ELF +#define _KERN_DO_ECOFF diff --git a/sys/arch/powerpc/include/exec.h b/sys/arch/powerpc/include/exec.h index 36aa23455f7..54357834d22 100644 --- a/sys/arch/powerpc/include/exec.h +++ b/sys/arch/powerpc/include/exec.h @@ -24,7 +24,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: exec.h,v 1.1.1.1 1996/12/21 20:35:54 rahnds Exp $ + * $Id: exec.h,v 1.2 1996/12/23 02:42:35 deraadt Exp $ */ #ifndef _PPC_EXEC_H_ @@ -51,11 +51,9 @@ struct relocation_info_powerpc { #define ELF_TARG_DATA ELFDATA2MSB #define ELF_TARG_MACH EM_PPC -/* - * This is what we want nlist(3) to handle. - */ -#define DO_AOUT /* support a.out */ -#define DO_ELF /* support ELF */ +#define _NLIST_DO_AOUT +#define _NLIST_DO_ELF +#define _KERN_DO_ELF #endif /* _PPC_EXEC_H_ */ diff --git a/sys/arch/sparc/include/exec.h b/sys/arch/sparc/include/exec.h index 50ee2751730..b4c3925fd48 100644 --- a/sys/arch/sparc/include/exec.h +++ b/sys/arch/sparc/include/exec.h @@ -61,7 +61,12 @@ struct relocation_info_sparc { #define ELF_TARG_DATA ELFDATA2MSB #define ELF_TARG_MACH EM_SPARC -#define DO_AOUT /* support a.out */ -#define DO_ELF /* support ELF */ +#define _NLIST_DO_AOUT +#define _NLIST_DO_ELF + +#define _KERN_DO_AOUT +#if defined(COMPAT_LINUX) || defined(COMPAT_SVR4) +#define _KERN_DO_ELF +#endif #endif /* _SPARC_EXEC_H_ */ diff --git a/sys/arch/sun3/include/exec.h b/sys/arch/sun3/include/exec.h index 22d46f1bd7e..2aa79fc0d5a 100644 --- a/sys/arch/sun3/include/exec.h +++ b/sys/arch/sun3/include/exec.h @@ -50,7 +50,8 @@ struct relocation_info_m68k { #define ELF_TARG_DATA ELFDATA2MSB #define ELF_TARG_MACH EM_68K -#define DO_AOUT /* support a.out */ -#define DO_ELF /* support ELF */ +#define _NLIST_DO_AOUT + +#define _KERN_DO_AOUT #endif /* _SUN3_EXEC_H_ */ diff --git a/sys/arch/vax/include/exec.h b/sys/arch/vax/include/exec.h index 3493e317afa..74e73c549e8 100644 --- a/sys/arch/vax/include/exec.h +++ b/sys/arch/vax/include/exec.h @@ -46,4 +46,8 @@ struct relocation_info_vax { }; #define relocation_info relocation_info_vax +#define _NLIST_DO_AOUT + +#define _KERN_DO_AOUT + #endif /* _VAX_EXEC_H_ */ diff --git a/sys/conf/files b/sys/conf/files index 572b0584ab6..dbcb9628c28 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1,4 +1,4 @@ -# $OpenBSD: files,v 1.48 1996/11/30 13:39:20 niklas Exp $ +# $OpenBSD: files,v 1.49 1996/12/23 02:42:23 deraadt Exp $ # $NetBSD: files,v 1.87 1996/05/19 17:17:50 jonathan Exp $ # @(#)files.newconf 7.5 (Berkeley) 5/10/93 @@ -129,8 +129,8 @@ file isofs/cd9660/cd9660_vfsops.c cd9660 file isofs/cd9660/cd9660_vnops.c cd9660 file kern/exec_aout.c file kern/exec_conf.c -file kern/exec_ecoff.c compat_ultrix | compat_osf1 | exec_ecoff -file kern/exec_elf.c compat_svr4 | compat_linux | native_elf +file kern/exec_ecoff.c +file kern/exec_elf.c file kern/exec_script.c file kern/exec_subr.c file kern/init_main.c diff --git a/sys/kern/exec_aout.c b/sys/kern/exec_aout.c index 3a13bd0711c..458f39e598a 100644 --- a/sys/kern/exec_aout.c +++ b/sys/kern/exec_aout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_aout.c,v 1.2 1996/03/03 17:19:36 niklas Exp $ */ +/* $OpenBSD: exec_aout.c,v 1.3 1996/12/23 02:42:41 deraadt Exp $ */ /* $NetBSD: exec_aout.c,v 1.14 1996/02/04 02:15:01 christos Exp $ */ /* @@ -40,6 +40,8 @@ #include #include +#if defined(_KERN_DO_AOUT) + /* * exec_aout_makecmds(): Check if it's an a.out-format executable. * @@ -143,7 +145,7 @@ exec_aout_prep_zmagic(p, epp) epp->ep_daddr + execp->a_data, NULLVP, 0, VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); - return exec_aout_setup_stack(p, epp); + return exec_setup_stack(p, epp); } /* @@ -181,7 +183,7 @@ exec_aout_prep_nmagic(p, epp) NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, bsize, baddr, NULLVP, 0, VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); - return exec_aout_setup_stack(p, epp); + return exec_setup_stack(p, epp); } /* @@ -224,49 +226,7 @@ exec_aout_prep_omagic(p, epp) */ dsize = epp->ep_dsize + execp->a_text - roundup(execp->a_text, NBPG); epp->ep_dsize = (dsize > 0) ? dsize : 0; - return exec_aout_setup_stack(p, epp); + return exec_setup_stack(p, epp); } -/* - * exec_aout_setup_stack(): Set up the stack segment for an a.out - * executable. - * - * Note that the ep_ssize parameter must be set to be the current stack - * limit; this is adjusted in the body of execve() to yield the - * appropriate stack segment usage once the argument length is - * calculated. - * - * This function returns an int for uniformity with other (future) formats' - * stack setup functions. They might have errors to return. - */ - -int -exec_aout_setup_stack(p, epp) - struct proc *p; - struct exec_package *epp; -{ - - epp->ep_maxsaddr = USRSTACK - MAXSSIZ; - epp->ep_minsaddr = USRSTACK; - epp->ep_ssize = p->p_rlimit[RLIMIT_STACK].rlim_cur; - - /* - * set up commands for stack. note that this takes *two*, one to - * map the part of the stack which we can access, and one to map - * the part which we can't. - * - * arguably, it could be made into one, but that would require the - * addition of another mapping proc, which is unnecessary - * - * note that in memory, things assumed to be: 0 ....... ep_maxsaddr - * ep_minsaddr - */ - NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, - ((epp->ep_minsaddr - epp->ep_ssize) - epp->ep_maxsaddr), - epp->ep_maxsaddr, NULLVP, 0, VM_PROT_NONE); - NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, epp->ep_ssize, - (epp->ep_minsaddr - epp->ep_ssize), NULLVP, 0, - VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); - - return 0; -} +#endif /* _KERN_DO_AOUT */ diff --git a/sys/kern/exec_conf.c b/sys/kern/exec_conf.c index 44a7a6aa3af..f2b8fb4128b 100644 --- a/sys/kern/exec_conf.c +++ b/sys/kern/exec_conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_conf.c,v 1.6 1996/06/07 19:38:58 pefo Exp $ */ +/* $OpenBSD: exec_conf.c,v 1.7 1996/12/23 02:42:42 deraadt Exp $ */ /* $NetBSD: exec_conf.c,v 1.16 1995/12/09 05:34:47 cgd Exp $ */ /* @@ -33,35 +33,13 @@ #include #include - -#undef EXEC_SCRIPT /* XXX */ -#define EXEC_SCRIPT /* XXX */ -#undef EXEC_AOUT /* XXX */ -#define EXEC_AOUT /* XXX */ - -#if defined(COMPAT_ULTRIX) || defined(COMPAT_OSF1) -#undef EXEC_ECOFF -#define EXEC_ECOFF -#endif - -#if defined(COMPAT_SVR4) || defined(COMPAT_LINUX) -#undef EXEC_ELF -#define EXEC_ELF -#endif - -#ifdef EXEC_SCRIPT #include -#endif -#if defined(NATIVE_EXEC_AOUT) || defined(EXEC_AOUT) -/*#include -- automatically pulled in */ -#endif - -#if defined(NATIVE_EXEC_ECOFF) || defined(EXEC_ECOFF) +#if defined(_KERN_DO_ECOFF) #include #endif -#if defined(NATIVE_EXEC_ELF) || defined(EXEC_ELF) +#if defined(_KERN_DO_ELF) #include #endif @@ -93,16 +71,14 @@ struct execsw execsw[] = { { 0, NULL, }, { 0, NULL, }, #endif -#ifdef EXEC_SCRIPT { MAXINTERP, exec_script_makecmds, }, /* shell scripts */ -#endif -#ifdef EXEC_AOUT +#ifdef _KERN_DO_AOUT { sizeof(struct exec), exec_aout_makecmds, }, /* a.out binaries */ #endif -#ifdef EXEC_ECOFF +#ifdef _KERN_DO_ECOFF { ECOFF_HDR_SIZE, exec_ecoff_makecmds, }, /* ecoff binaries */ #endif -#if defined(NATIVE_EXEC_ELF) || defined(EXEC_ELF) +#ifdef _KERN_DO_ELF { sizeof(Elf32_Ehdr), exec_elf_makecmds, }, /* elf binaries */ #endif #ifdef COMPAT_LINUX @@ -113,7 +89,7 @@ struct execsw execsw[] = { { XOUT_HDR_SIZE, exec_ibcs2_xout_makecmds, }, /* x.out binaries */ #endif #ifdef COMPAT_FREEBSD - { FREEBSD_AOUT_HDR_SIZE, exec_freebsd_aout_makecmds, }, /* a.out */ + { FREEBSD_AOUT_HDR_SIZE, exec_freebsd_aout_makecmds, }, /* freebsd */ #endif #ifdef COMPAT_HPUX { HPUX_EXEC_HDR_SIZE, exec_hpux_makecmds, }, /* HP-UX a.out */ diff --git a/sys/kern/exec_ecoff.c b/sys/kern/exec_ecoff.c index 34cfda7fa65..741fecea34d 100644 --- a/sys/kern/exec_ecoff.c +++ b/sys/kern/exec_ecoff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_ecoff.c,v 1.3 1996/05/22 12:05:19 deraadt Exp $ */ +/* $OpenBSD: exec_ecoff.c,v 1.4 1996/12/23 02:42:42 deraadt Exp $ */ /* $NetBSD: exec_ecoff.c,v 1.8 1996/05/19 20:36:06 jonathan Exp $ */ /* @@ -41,6 +41,8 @@ #include #include +#if defined(_KERN_DO_ECOFF) + #include int exec_ecoff_prep_omagic __P((struct proc *, struct exec_package *)); @@ -96,49 +98,6 @@ exec_ecoff_makecmds(p, epp) return error; } -/* - * exec_ecoff_setup_stack(): Set up the stack segment for an ecoff - * executable. - * - * Note that the ep_ssize parameter must be set to be the current stack - * limit; this is adjusted in the body of execve() to yield the - * appropriate stack segment usage once the argument length is - * calculated. - * - * This function returns an int for uniformity with other (future) formats' - * stack setup functions. They might have errors to return. - */ -int -exec_ecoff_setup_stack(p, epp) - struct proc *p; - struct exec_package *epp; -{ - - epp->ep_maxsaddr = USRSTACK - MAXSSIZ; - epp->ep_minsaddr = USRSTACK; - epp->ep_ssize = p->p_rlimit[RLIMIT_STACK].rlim_cur; - - /* - * set up commands for stack. note that this takes *two*, one to - * map the part of the stack which we can access, and one to map - * the part which we can't. - * - * arguably, it could be made into one, but that would require the - * addition of another mapping proc, which is unnecessary - * - * note that in memory, things assumed to be: 0 ....... ep_maxsaddr - * ep_minsaddr - */ - NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, - ((epp->ep_minsaddr - epp->ep_ssize) - epp->ep_maxsaddr), - epp->ep_maxsaddr, NULLVP, 0, VM_PROT_NONE); - NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, epp->ep_ssize, - (epp->ep_minsaddr - epp->ep_ssize), NULLVP, 0, - VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); - - return 0; -} - /* * exec_ecoff_prep_omagic(): Prepare a ECOFF OMAGIC binary's exec package */ @@ -168,7 +127,7 @@ exec_ecoff_prep_omagic(p, epp) ECOFF_SEGMENT_ALIGN(execp, eap->bss_start), NULLVP, 0, VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); - return exec_ecoff_setup_stack(p, epp); + return exec_setup_stack(p, epp); } /* @@ -205,7 +164,7 @@ exec_ecoff_prep_nmagic(p, epp) ECOFF_SEGMENT_ALIGN(execp, eap->bss_start), NULLVP, 0, VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); - return exec_ecoff_setup_stack(p, epp); + return exec_setup_stack(p, epp); } /* @@ -261,5 +220,7 @@ exec_ecoff_prep_zmagic(p, epp) ECOFF_SEGMENT_ALIGN(execp, eap->bss_start), NULLVP, 0, VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); - return exec_ecoff_setup_stack(p, epp); + return exec_setup_stack(p, epp); } + +#endif /* _KERN_DO_ECOFF */ diff --git a/sys/kern/exec_elf.c b/sys/kern/exec_elf.c index 053fdf9cb0a..649a062acc3 100644 --- a/sys/kern/exec_elf.c +++ b/sys/kern/exec_elf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_elf.c,v 1.18 1996/11/24 18:31:25 etheisen Exp $ */ +/* $OpenBSD: exec_elf.c,v 1.19 1996/12/23 02:42:43 deraadt Exp $ */ /* * Copyright (c) 1996 Per Fogelstrom @@ -40,6 +40,9 @@ #include #include #include + +#if defined(_KERN_DO_ELF) + #include #include #include @@ -47,13 +50,6 @@ #include #include -#if defined(COMPAT_LINUX) || defined(COMPAT_SVR4) /*XXX should be */ -#undef EXEC_ELF /*XXX defined in */ -#define EXEC_ELF /*XXX machine/exec.h */ -#endif /*XXX instead ? */ - -#if defined(NATIVE_EXEC_ELF) || defined(EXEC_ELF) - #include #include #include @@ -616,7 +612,7 @@ exec_elf_makecmds(p, epp) free((char *) ph, M_TEMP); epp->ep_vp->v_flag |= VTEXT; - return exec_aout_setup_stack(p, epp); + return exec_setup_stack(p, epp); bad: free((char *) ph, M_TEMP); @@ -708,4 +704,4 @@ exec_elf_fixup(p, epp) free((char *) interp, M_TEMP); return error; } -#endif /* NATIVE_EXEC_ELF || EXEC_ELF */ +#endif /* _KERN_DO_ELF */ diff --git a/sys/kern/exec_subr.c b/sys/kern/exec_subr.c index 2bc891accaa..e8810979a6d 100644 --- a/sys/kern/exec_subr.c +++ b/sys/kern/exec_subr.c @@ -38,6 +38,7 @@ #include #include #include +#include #include @@ -194,3 +195,47 @@ vmcmd_map_zero(p, cmd) return vm_map_protect(&p->p_vmspace->vm_map, trunc_page(cmd->ev_addr), round_page(cmd->ev_addr + cmd->ev_len), cmd->ev_prot, FALSE); } + +/* + * exec_setup_stack(): Set up the stack segment for an a.out + * executable. + * + * Note that the ep_ssize parameter must be set to be the current stack + * limit; this is adjusted in the body of execve() to yield the + * appropriate stack segment usage once the argument length is + * calculated. + * + * This function returns an int for uniformity with other (future) formats' + * stack setup functions. They might have errors to return. + */ + +int +exec_setup_stack(p, epp) + struct proc *p; + struct exec_package *epp; +{ + + epp->ep_maxsaddr = USRSTACK - MAXSSIZ; + epp->ep_minsaddr = USRSTACK; + epp->ep_ssize = p->p_rlimit[RLIMIT_STACK].rlim_cur; + + /* + * set up commands for stack. note that this takes *two*, one to + * map the part of the stack which we can access, and one to map + * the part which we can't. + * + * arguably, it could be made into one, but that would require the + * addition of another mapping proc, which is unnecessary + * + * note that in memory, things assumed to be: 0 ....... ep_maxsaddr + * ep_minsaddr + */ + NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, + ((epp->ep_minsaddr - epp->ep_ssize) - epp->ep_maxsaddr), + epp->ep_maxsaddr, NULLVP, 0, VM_PROT_NONE); + NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, epp->ep_ssize, + (epp->ep_minsaddr - epp->ep_ssize), NULLVP, 0, + VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); + + return 0; +} diff --git a/sys/sys/exec.h b/sys/sys/exec.h index 8937a8b19fa..f26e1ae77b4 100644 --- a/sys/sys/exec.h +++ b/sys/sys/exec.h @@ -1,4 +1,4 @@ -/* $OpenBSD: exec.h,v 1.4 1996/08/31 09:17:16 pefo Exp $ */ +/* $OpenBSD: exec.h,v 1.5 1996/12/23 02:42:39 deraadt Exp $ */ /* $NetBSD: exec.h,v 1.59 1996/02/09 18:25:09 christos Exp $ */ /*- @@ -172,6 +172,7 @@ void *copyargs __P((struct exec_package *, struct ps_strings *, void setregs __P((struct proc *, struct exec_package *, u_long, register_t *)); int check_exec __P((struct proc *, struct exec_package *)); +int exec_setup_stack __P((struct proc *, struct exec_package *)); #ifdef DEBUG void new_vmcmd __P((struct exec_vmcmd_set *evsp, diff --git a/sys/sys/exec_aout.h b/sys/sys/exec_aout.h index 4908869943e..d2521ea3d18 100644 --- a/sys/sys/exec_aout.h +++ b/sys/sys/exec_aout.h @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_aout.h,v 1.5 1996/06/25 20:48:58 deraadt Exp $ */ +/* $OpenBSD: exec_aout.h,v 1.6 1996/12/23 02:42:40 deraadt Exp $ */ /* $NetBSD: exec_aout.h,v 1.15 1996/05/18 17:20:54 christos Exp $ */ /* @@ -179,7 +179,6 @@ int exec_aout_makecmds __P((struct proc *, struct exec_package *)); int exec_aout_prep_zmagic __P((struct proc *, struct exec_package *)); int exec_aout_prep_nmagic __P((struct proc *, struct exec_package *)); int exec_aout_prep_omagic __P((struct proc *, struct exec_package *)); -int exec_aout_setup_stack __P((struct proc *, struct exec_package *)); /* For compatibility modules */ int exec_aout_prep_oldzmagic __P((struct proc *, struct exec_package *)); -- 2.20.1