diff options
| author | maxv <maxv@NetBSD.org> | 2014-07-22 08:18:33 +0000 |
|---|---|---|
| committer | maxv <maxv@NetBSD.org> | 2014-07-22 08:18:33 +0000 |
| commit | 411c285f096225e475852ea70eb3b30c64d6416b (patch) | |
| tree | 372540c6482d96c4f60f8efa7d77120cc570fbf1 /sys/kern/exec_elf32.c | |
| parent | 524e06d13fc85f69d515772813fcbdd9f9c46b3f (diff) | |
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 (limited to 'sys/kern/exec_elf32.c')
| -rw-r--r-- | sys/kern/exec_elf32.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/sys/kern/exec_elf32.c b/sys/kern/exec_elf32.c index 690c2d2f6e0..8a0e96087e1 100644 --- a/sys/kern/exec_elf32.c +++ b/sys/kern/exec_elf32.c @@ -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 */ } |
