Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys 1) On 64bit systems, don't add the 32bit execsw[] to the...
details: https://anonhg.NetBSD.org/src/rev/42f8eb7e7a45
branches: trunk
changeset: 797561:42f8eb7e7a45
user: maxv <maxv%NetBSD.org@localhost>
date: Tue Jul 22 08:18:33 2014 +0000
description:
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.
diffstat:
sys/compat/linux32/common/linux32_mod.c | 6 +++---
sys/compat/netbsd32/netbsd32_mod.c | 6 +++---
sys/kern/exec_elf32.c | 28 +++++++++++++++++++++++++---
sys/kern/exec_elf64.c | 6 +++---
4 files changed, 34 insertions(+), 12 deletions(-)
diffs (143 lines):
diff -r 9eda27738281 -r 42f8eb7e7a45 sys/compat/linux32/common/linux32_mod.c
--- a/sys/compat/linux32/common/linux32_mod.c Tue Jul 22 07:38:41 2014 +0000
+++ b/sys/compat/linux32/common/linux32_mod.c Tue Jul 22 08:18:33 2014 +0000
@@ -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 @@
.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,
diff -r 9eda27738281 -r 42f8eb7e7a45 sys/compat/netbsd32/netbsd32_mod.c
--- a/sys/compat/netbsd32/netbsd32_mod.c Tue Jul 22 07:38:41 2014 +0000
+++ b/sys/compat/netbsd32/netbsd32_mod.c Tue Jul 22 08:18:33 2014 +0000
@@ -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 @@
.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,
diff -r 9eda27738281 -r 42f8eb7e7a45 sys/kern/exec_elf32.c
--- a/sys/kern/exec_elf32.c Tue Jul 22 07:38:41 2014 +0000
+++ b/sys/kern/exec_elf32.c Tue Jul 22 08:18:33 2014 +0000
@@ -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 @@
.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 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 @@
default:
return ENOTTY;
}
+#endif /* ARCH_ELFSIZE == 64 */
}
diff -r 9eda27738281 -r 42f8eb7e7a45 sys/kern/exec_elf64.c
--- a/sys/kern/exec_elf64.c Tue Jul 22 07:38:41 2014 +0000
+++ b/sys/kern/exec_elf64.c Tue Jul 22 08:18:33 2014 +0000
@@ -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 @@
.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,
Home |
Main Index |
Thread Index |
Old Index