1) On 64bit systems, don't add the 32bit execsw[] to the global exec array.
exec_elf32 works on 32bit systems only, and will crash 32bit binaries on 64bit systems. 2) Now that exec_elf32 is dormant, we can give the native ELF loaders the highest priority. Binaries will load faster now (system boot, compilation, etc.). With the help of njloy@. Discussed a bit on tech-kern@, no disagreement.
This commit is contained in:
parent
01bd325227
commit
5848af8e14
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: linux32_mod.c,v 1.5 2014/03/07 01:33:43 christos Exp $ */
|
||||
/* $NetBSD: linux32_mod.c,v 1.6 2014/07/22 08:18:33 maxv Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -30,7 +30,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: linux32_mod.c,v 1.5 2014/03/07 01:33:43 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: linux32_mod.c,v 1.6 2014/07/22 08:18:33 maxv Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_execfmt.h"
|
||||
|
@ -67,7 +67,7 @@ static struct execsw linux32_execsw[] = {
|
|||
.elf_probe_func = linux32_elf32_probe,
|
||||
},
|
||||
.es_emul = &emul_linux32,
|
||||
.es_prio = EXECSW_PRIO_FIRST,
|
||||
.es_prio = EXECSW_PRIO_ANY,
|
||||
.es_arglen = LINUX32_ELF_AUX_ARGSIZ,
|
||||
.es_copyargs = linux32_elf32_copyargs,
|
||||
.es_setregs = NULL,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: netbsd32_mod.c,v 1.4 2014/07/11 16:22:49 maxv Exp $ */
|
||||
/* $NetBSD: netbsd32_mod.c,v 1.5 2014/07/22 08:18:33 maxv Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -30,7 +30,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: netbsd32_mod.c,v 1.4 2014/07/11 16:22:49 maxv Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: netbsd32_mod.c,v 1.5 2014/07/22 08:18:33 maxv Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_execfmt.h"
|
||||
|
@ -87,7 +87,7 @@ static struct execsw netbsd32_execsw[] = {
|
|||
.elf_probe_func = netbsd32_elf32_probe,
|
||||
},
|
||||
.es_emul = &emul_netbsd32,
|
||||
.es_prio = EXECSW_PRIO_FIRST,
|
||||
.es_prio = EXECSW_PRIO_ANY,
|
||||
.es_arglen = ELF32_AUXSIZE,
|
||||
.es_copyargs = netbsd32_elf32_copyargs,
|
||||
.es_setregs = NULL,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: exec_elf32.c,v 1.140 2014/04/07 17:02:15 rjs Exp $ */
|
||||
/* $NetBSD: exec_elf32.c,v 1.141 2014/07/22 08:18:33 maxv Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Christopher G. Demetriou
|
||||
|
@ -32,7 +32,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: exec_elf32.c,v 1.140 2014/04/07 17:02:15 rjs Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: exec_elf32.c,v 1.141 2014/07/22 08:18:33 maxv Exp $");
|
||||
|
||||
#define ELFSIZE 32
|
||||
|
||||
|
@ -59,7 +59,7 @@ static struct execsw exec_elf32_execsw[] = {
|
|||
.elf_probe_func = netbsd_elf32_probe,
|
||||
},
|
||||
.es_emul = &emul_netbsd,
|
||||
.es_prio = EXECSW_PRIO_ANY,
|
||||
.es_prio = EXECSW_PRIO_FIRST,
|
||||
.es_arglen = ELF32_AUXSIZE,
|
||||
.es_copyargs = elf32_copyargs,
|
||||
.es_setregs = NULL,
|
||||
|
@ -87,7 +87,28 @@ static struct execsw exec_elf32_execsw[] = {
|
|||
static int
|
||||
exec_elf32_modcmd(modcmd_t cmd, void *arg)
|
||||
{
|
||||
#if ARCH_ELFSIZE == 64
|
||||
/*
|
||||
* If we are on a 64bit system, we don't want the 32bit execsw[] to be
|
||||
* added in the global array, because the exec_elf32 module only works
|
||||
* on 32bit systems.
|
||||
*
|
||||
* However, we need the exec_elf32 module, because it will make the 32bit
|
||||
* functions available for netbsd32 and linux32.
|
||||
*
|
||||
* Therefore, allow this module on 64bit systems, but make it dormant.
|
||||
*/
|
||||
|
||||
(void)exec_elf32_execsw; /* unused */
|
||||
|
||||
switch (cmd) {
|
||||
case MODULE_CMD_INIT:
|
||||
case MODULE_CMD_FINI:
|
||||
return 0;
|
||||
default:
|
||||
return ENOTTY;
|
||||
}
|
||||
#else /* ARCH_ELFSIZE == 64 */
|
||||
switch (cmd) {
|
||||
case MODULE_CMD_INIT:
|
||||
return exec_add(exec_elf32_execsw,
|
||||
|
@ -100,4 +121,5 @@ exec_elf32_modcmd(modcmd_t cmd, void *arg)
|
|||
default:
|
||||
return ENOTTY;
|
||||
}
|
||||
#endif /* ARCH_ELFSIZE == 64 */
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: exec_elf64.c,v 1.5 2014/03/07 01:34:29 christos Exp $ */
|
||||
/* $NetBSD: exec_elf64.c,v 1.6 2014/07/22 08:18:33 maxv Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Christopher G. Demetriou
|
||||
|
@ -32,7 +32,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: exec_elf64.c,v 1.5 2014/03/07 01:34:29 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: exec_elf64.c,v 1.6 2014/07/22 08:18:33 maxv Exp $");
|
||||
|
||||
#define ELFSIZE 64
|
||||
|
||||
|
@ -60,7 +60,7 @@ static struct execsw exec_elf64_execsw[] = {
|
|||
.elf_probe_func = netbsd_elf64_probe,
|
||||
},
|
||||
.es_emul = &emul_netbsd,
|
||||
.es_prio = EXECSW_PRIO_ANY,
|
||||
.es_prio = EXECSW_PRIO_FIRST,
|
||||
.es_arglen = ELF64_AUXSIZE,
|
||||
.es_copyargs = elf64_copyargs,
|
||||
.es_setregs = NULL,
|
||||
|
|
Loading…
Reference in New Issue