diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/conf/files | 4 | ||||
-rw-r--r-- | sys/conf/files.ia64 | 1 | ||||
-rw-r--r-- | sys/kern/imgact_elf.c | 50 | ||||
-rw-r--r-- | sys/kern/imgact_elf32.c | 8 | ||||
-rw-r--r-- | sys/kern/imgact_elf64.c | 8 | ||||
-rw-r--r-- | sys/kern/imgact_elfN.c | 51 | ||||
-rw-r--r-- | sys/kern/init_main.c | 5 | ||||
-rw-r--r-- | sys/kern/kern_mib.c | 4 |
8 files changed, 29 insertions, 102 deletions
diff --git a/sys/conf/files b/sys/conf/files index 61a9221..99e6c5d 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -966,9 +966,7 @@ isofs/cd9660/cd9660_rrip.c optional cd9660 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 diff --git a/sys/conf/files.ia64 b/sys/conf/files.ia64 index 3e50191..e3417eb 100644 --- a/sys/conf/files.ia64 +++ b/sys/conf/files.ia64 @@ -109,6 +109,7 @@ isa/ppc.c optional ppc 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 diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index 3fba3cd..714ee15 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -81,20 +81,24 @@ static int __elfN(load_section)(struct proc *p, 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 @@ __elfN(get_brandinfo)(const Elf_Ehdr *hdr, const char *interp) 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 @@ fail: 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 @@ __elfN(putnote)(void *dst, size_t *off, const char *name, int type, /* * 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)); diff --git a/sys/kern/imgact_elf32.c b/sys/kern/imgact_elf32.c index 7fd99b7..3ce6d54 100644 --- a/sys/kern/imgact_elf32.c +++ b/sys/kern/imgact_elf32.c @@ -26,13 +26,5 @@ * $FreeBSD$ */ -/* - * There ought to be a better way of deciding this. - */ -#if defined(__i386__) || defined(__ia64__) || defined(__powerpc__) - #define __ELF_WORD_SIZE 32 - #include <kern/imgact_elf.c> - -#endif diff --git a/sys/kern/imgact_elf64.c b/sys/kern/imgact_elf64.c index ea6d61d..a356591 100644 --- a/sys/kern/imgact_elf64.c +++ b/sys/kern/imgact_elf64.c @@ -26,13 +26,5 @@ * $FreeBSD$ */ -/* - * There ought to be a better way of deciding this. - */ -#if defined(__alpha__) || defined(__ia64__) || defined(__sparc64__) - #define __ELF_WORD_SIZE 64 - #include <kern/imgact_elf.c> - -#endif diff --git a/sys/kern/imgact_elfN.c b/sys/kern/imgact_elfN.c deleted file mode 100644 index fd8487f..0000000 --- a/sys/kern/imgact_elfN.c +++ /dev/null @@ -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$ - */ - -#include <sys/param.h> -#include <sys/kernel.h> -#include <sys/sysctl.h> - -#include <machine/elf.h> -#include <sys/elf_generic.h> - -/* - * 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"); - diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index e49ce08..354536f 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -97,7 +97,6 @@ static struct vmspace vmspace0; struct proc *initproc; int cmask = CMASK; -extern int fallback_elf_brand; struct vnode *rootvp; int boothowto = 0; /* initialized so that it can be patched */ @@ -585,10 +584,6 @@ start_init(void *dummy) 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); - } for (path = init_path; *path != '\0'; path = next) { while (*path == ':') diff --git a/sys/kern/kern_mib.c b/sys/kern/kern_mib.c index dc72629..fd7dda5 100644 --- a/sys/kern/kern_mib.c +++ b/sys/kern/kern_mib.c @@ -361,3 +361,7 @@ SYSCTL_INT(_debug_sizeof, OID_AUTO, buf, CTLFLAG_RD, #include <sys/user.h> 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, ""); |