Index: conf/files =================================================================== RCS file: /home/ncvs/src/sys/conf/files,v retrieving revision 1.742 diff -u -r1.742 files --- conf/files 1 Jan 2003 19:49:29 -0000 1.742 +++ conf/files 4 Jan 2003 04:59:03 -0000 @@ -966,9 +966,7 @@ isofs/cd9660/cd9660_util.c optional cd9660 isofs/cd9660/cd9660_vfsops.c optional cd9660 isofs/cd9660/cd9660_vnops.c optional cd9660 -kern/imgact_elf32.c standard -kern/imgact_elf64.c standard -kern/imgact_elfN.c standard +kern/imgact_elf.c standard kern/imgact_shell.c standard kern/inflate.c optional gzip kern/init_main.c standard Index: conf/files.ia64 =================================================================== RCS file: /home/ncvs/src/sys/conf/files.ia64,v retrieving revision 1.41 diff -u -r1.41 files.ia64 --- conf/files.ia64 24 Oct 2002 19:05:03 -0000 1.41 +++ conf/files.ia64 4 Jan 2003 04:59:03 -0000 @@ -109,6 +109,7 @@ isa/psm.c optional psm isa/syscons_isa.c optional sc isa/vga_isa.c optional vga +kern/imgact_elf32.c optional ia32 kern/subr_diskmbr.c standard libkern/ia64/bswap16.S standard libkern/ia64/bswap32.S standard Index: kern/imgact_elf.c =================================================================== RCS file: /home/ncvs/src/sys/kern/imgact_elf.c,v retrieving revision 1.134 diff -u -r1.134 imgact_elf.c --- kern/imgact_elf.c 21 Dec 2002 01:15:39 -0000 1.134 +++ kern/imgact_elf.c 4 Jan 2003 04:59:05 -0000 @@ -81,20 +81,24 @@ vm_prot_t prot, size_t pagesize); static int __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp); +SYSCTL_NODE(_kern, OID_AUTO, __CONCAT(elf, __ELF_WORD_SIZE), CTLFLAG_RW, 0, + ""); + +static int fallback_brand = -1; +SYSCTL_INT(__CONCAT(_kern_elf, __ELF_WORD_SIZE), OID_AUTO, fallback_brand, + CTLFLAG_RW, &fallback_brand, 0, + __XSTRING(__CONCAT(ELF, __ELF_WORD_SIZE)) " brand of last resort"); +TUNABLE_INT("kern.elf" __XSTRING(__ELF_WORD_SIZE) ".fallback_brand", + &fallback_brand); + static int elf_trace = 0; +SYSCTL_INT(_debug, OID_AUTO, __elfN(trace), CTLFLAG_RW, &elf_trace, 0, ""); + static int elf_legacy_coredump = 0; -#if __ELF_WORD_SIZE == 32 -SYSCTL_INT(_debug, OID_AUTO, elf32_trace, CTLFLAG_RW, &elf_trace, 0, ""); -SYSCTL_INT(_debug, OID_AUTO, elf32_legacy_coredump, CTLFLAG_RW, - &elf_legacy_coredump, 0, ""); -#else -SYSCTL_INT(_debug, OID_AUTO, elf64_trace, CTLFLAG_RW, &elf_trace, 0, ""); -SYSCTL_INT(_debug, OID_AUTO, elf64_legacy_coredump, CTLFLAG_RW, +SYSCTL_INT(_debug, OID_AUTO, __elfN(legacy_coredump), CTLFLAG_RW, &elf_legacy_coredump, 0, ""); -#endif static Elf_Brandinfo *elf_brand_list[MAX_BRANDS]; -extern int fallback_elf_brand; int __elfN(insert_brand_entry)(Elf_Brandinfo *entry) @@ -184,7 +188,7 @@ for (i = 0; i < MAX_BRANDS; i++) { bi = elf_brand_list[i]; if (bi != NULL && hdr->e_machine == bi->machine && - fallback_elf_brand == bi->brand) + fallback_brand == bi->brand) return (bi); } return (NULL); @@ -849,22 +853,16 @@ return (error); } -#if __ELF_WORD_SIZE == 32 -#define suword suword32 -#define stacktype u_int32_t -#else -#define suword suword64 -#define stacktype u_int64_t -#endif +#define suword __CONCAT(suword, __ELF_WORD_SIZE) int __elfN(freebsd_fixup)(register_t **stack_base, struct image_params *imgp) { Elf_Auxargs *args = (Elf_Auxargs *)imgp->auxargs; - stacktype *base; - stacktype *pos; + Elf_Addr *base; + Elf_Addr *pos; - base = (stacktype *)*stack_base; + base = (Elf_Addr *)*stack_base; pos = base + (imgp->argc + imgp->envc + 2); if (args->trace) { @@ -1260,10 +1258,8 @@ /* * Tell kern_execve.c about it, with a little help from the linker. */ -#if __ELF_WORD_SIZE == 32 -static struct execsw elf_execsw = {exec_elf32_imgact, "ELF32"}; -EXEC_SET(elf32, elf_execsw); -#else -static struct execsw elf_execsw = {exec_elf64_imgact, "ELF64"}; -EXEC_SET(elf64, elf_execsw); -#endif +static struct execsw __elfN(execsw) = { + __CONCAT(exec_, __elfN(imgact)), + __XSTRING(__CONCAT(ELF, __ELF_WORD_SIZE)) +}; +EXEC_SET(__CONCAT(elf, __ELF_WORD_SIZE), __elfN(execsw)); Index: kern/imgact_elf32.c =================================================================== RCS file: /home/ncvs/src/sys/kern/imgact_elf32.c,v retrieving revision 1.1 diff -u -r1.1 imgact_elf32.c --- kern/imgact_elf32.c 20 Jul 2002 02:56:11 -0000 1.1 +++ kern/imgact_elf32.c 4 Jan 2003 04:59:05 -0000 @@ -26,13 +26,5 @@ * $FreeBSD: src/sys/kern/imgact_elf32.c,v 1.1 2002/07/20 02:56:11 peter Exp $ */ -/* - * There ought to be a better way of deciding this. - */ -#if defined(__i386__) || defined(__ia64__) || defined(__powerpc__) - #define __ELF_WORD_SIZE 32 - #include - -#endif Index: kern/imgact_elf64.c =================================================================== RCS file: /home/ncvs/src/sys/kern/imgact_elf64.c,v retrieving revision 1.1 diff -u -r1.1 imgact_elf64.c --- kern/imgact_elf64.c 20 Jul 2002 02:56:11 -0000 1.1 +++ kern/imgact_elf64.c 4 Jan 2003 04:59:05 -0000 @@ -26,13 +26,5 @@ * $FreeBSD: src/sys/kern/imgact_elf64.c,v 1.1 2002/07/20 02:56:11 peter Exp $ */ -/* - * There ought to be a better way of deciding this. - */ -#if defined(__alpha__) || defined(__ia64__) || defined(__sparc64__) - #define __ELF_WORD_SIZE 64 - #include - -#endif Index: kern/imgact_elfN.c =================================================================== RCS file: kern/imgact_elfN.c diff -N kern/imgact_elfN.c --- kern/imgact_elfN.c 20 Jul 2002 02:56:11 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 2000 David O'Brien - * Copyright (c) 1995-1996 Søren Schmidt - * Copyright (c) 1996 Peter Wemm - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer - * in this position and unchanged. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software withough specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD: src/sys/kern/imgact_elfN.c,v 1.1 2002/07/20 02:56:11 peter Exp $ - */ - -#include -#include -#include - -#include -#include - -/* - * non static, as it can be overridden by start_init() - */ -#ifdef __ia64__ -int fallback_elf_brand = ELFOSABI_FREEBSD; -#else -int fallback_elf_brand = -1; -#endif -SYSCTL_INT(_kern, OID_AUTO, fallback_elf_brand, CTLFLAG_RW, - &fallback_elf_brand, -1, - "ELF brand of last resort"); - Index: kern/init_main.c =================================================================== RCS file: /home/ncvs/src/sys/kern/init_main.c,v retrieving revision 1.217 diff -u -r1.217 init_main.c --- kern/init_main.c 28 Dec 2002 01:23:07 -0000 1.217 +++ kern/init_main.c 4 Jan 2003 04:59:05 -0000 @@ -97,7 +97,6 @@ struct proc *initproc; int cmask = CMASK; -extern int fallback_elf_brand; struct vnode *rootvp; int boothowto = 0; /* initialized so that it can be patched */ @@ -583,10 +582,6 @@ if ((var = getenv("init_path")) != NULL) { strlcpy(init_path, var, sizeof(init_path)); - freeenv(var); - } - if ((var = getenv("kern.fallback_elf_brand")) != NULL) { - fallback_elf_brand = strtol(var, NULL, 0); freeenv(var); } Index: kern/kern_mib.c =================================================================== RCS file: /home/ncvs/src/sys/kern/kern_mib.c,v retrieving revision 1.62 diff -u -r1.62 kern_mib.c --- kern/kern_mib.c 7 Nov 2002 23:57:17 -0000 1.62 +++ kern/kern_mib.c 4 Jan 2003 05:32:31 -0000 @@ -361,3 +361,7 @@ #include SYSCTL_INT(_debug_sizeof, OID_AUTO, kinfo_proc, CTLFLAG_RD, 0, sizeof(struct kinfo_proc), "sizeof(struct kinfo_proc)"); + +SYSCTL_STRING(_kern, OID_AUTO, fallback_elf_brand, CTLFLAG_RD, + "kern.fallback_elf_brand is deprecated, use kern.elf32.fallback_brand or " + "kern.elf64.fallback_brand" , 0, "");