Le 05/07/2014 16:58, Maxime Villard a écrit :
[...]
My approach was wrong. #if(ARCH_ELFSIZE != 64) doesn't remove the exec_elf32
module, since it is still listed in distrib/sets/lists/modules/md.amd64. It
just removes exec_elf32_modcmd() from the module.
If the module is built in (GENERIC kernel) then there's no problem, but if it
is loaded from the fs (with modload) it won't work, since the kernel doesn't
know what to do with a module that has no _modcmd().
If loaded from the filesystem, this module will make available all the 32bit
functions used by netbsd32 and linux32. Which means that we just can't delete
it. However, we can make it dormant (from an execsw point of view), so that it
won't interfere with the 32bit binaries.
I was nonetheless right on another point: there's an inconsistency in the
module dependency of netbsd32 and linux32; but it's fixed now.
Here is a working, clean patch tested by me and njoly@ on
linux/linux32/netbsd32.
exec_elf32 is still there, but not plugged in the global exec array. It is
just here to provide 32bit functions to linux32 and netbsd32.
I'll commit this, unless anyone disagrees.
Index: compat/netbsd32/netbsd32_mod.c
===================================================================
RCS file: /cvsroot/src/sys/compat/netbsd32/netbsd32_mod.c,v
retrieving revision 1.3
diff -u -r1.3 netbsd32_mod.c
--- compat/netbsd32/netbsd32_mod.c 7 Mar 2014 01:33:43 -0000 1.3
+++ compat/netbsd32/netbsd32_mod.c 11 Jul 2014 12:13:44 -0000
@@ -81,7 +81,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,
Index: compat/linux32/common/linux32_mod.c
===================================================================
RCS file: /cvsroot/src/sys/compat/linux32/common/linux32_mod.c,v
retrieving revision 1.5
diff -u -r1.5 linux32_mod.c
--- compat/linux32/common/linux32_mod.c 7 Mar 2014 01:33:43 -0000 1.5
+++ compat/linux32/common/linux32_mod.c 11 Jul 2014 12:13:44 -0000
@@ -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,
Index: kern/exec_elf32.c
===================================================================
RCS file: /cvsroot/src/sys/kern/exec_elf32.c,v
retrieving revision 1.140
diff -u -r1.140 exec_elf32.c
--- kern/exec_elf32.c 7 Apr 2014 17:02:15 -0000 1.140
+++ kern/exec_elf32.c 11 Jul 2014 12:13:44 -0000
@@ -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
switch (cmd) {
case MODULE_CMD_INIT:
return exec_add(exec_elf32_execsw,
@@ -100,4 +121,5 @@
default:
return ENOTTY;
}
+#endif /* ARCH_ELFSIZE == 64 */
}
Index: kern/exec_elf64.c
===================================================================
RCS file: /cvsroot/src/sys/kern/exec_elf64.c,v
retrieving revision 1.5
diff -u -r1.5 exec_elf64.c
--- kern/exec_elf64.c 7 Mar 2014 01:34:29 -0000 1.5
+++ kern/exec_elf64.c 11 Jul 2014 12:13:44 -0000
@@ -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,
!DSPAM:53c062ac36691270338434!