Improve the way that an elf image activator for an alternate word size is

included in the kernel.  Include imgact_elf.c in conf/files,  instead of
both imgact_elf32.c and imgact_elf64.c, which will use the default word
size for an architecture as defined in machine/elf.h.  Architectures that
wish to build an additional image activator for an alternate word size can
include either imgact_elf32.c or imgact_elf64.c in files.${ARCH}, which
allows it to be dependent on MD options instead of solely on architecture.

Glanced at by:	peter
This commit is contained in:
Jake Burkholder 2003-01-04 22:07:48 +00:00
parent b59ba7df87
commit a360a43dd5
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=108685
8 changed files with 29 additions and 102 deletions

View File

@ -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

View File

@ -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

View File

@ -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,
SYSCTL_INT(_debug, OID_AUTO, __elfN(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,
&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 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp)
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));

View File

@ -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

View File

@ -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

View File

@ -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");

View File

@ -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 == ':')

View File

@ -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, "");