summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorriastradh <riastradh@NetBSD.org>2023-01-31 13:21:37 +0000
committerriastradh <riastradh@NetBSD.org>2023-01-31 13:21:37 +0000
commitb211d7a35b68a8fc3d3e8dfa958bedd9fa6b4e8e (patch)
treeda428adf2c2750535352469015e9fe4947534310 /sys
parent3ba324374e12661a1d5cc3b1842a51d7e47e5fa7 (diff)
module(9): Make error message for multiple MODULE decls more obvious.
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_module.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/sys/kern/kern_module.c b/sys/kern/kern_module.c
index 0e5c515526c..ba6ebd65c6b 100644
--- a/sys/kern/kern_module.c
+++ b/sys/kern/kern_module.c
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_module.c,v 1.160 2022/10/26 23:22:07 riastradh Exp $ */
+/* $NetBSD: kern_module.c,v 1.161 2023/01/31 13:21:37 riastradh Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.160 2022/10/26 23:22:07 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.161 2023/01/31 13:21:37 riastradh Exp $");
#define _MODULE_INTERNAL
@@ -1632,8 +1632,16 @@ module_fetch_info(module_t *mod)
return error;
}
if (size != sizeof(modinfo_t **)) {
- module_error("`link_set_modules' section wrong size "
- "(got %zu, wanted %zu)", size, sizeof(modinfo_t **));
+ if (size > sizeof(modinfo_t **) &&
+ (size % sizeof(modinfo_t **)) == 0) {
+ module_error("`link_set_modules' section wrong size "
+ "(%zu different MODULE declarations?)",
+ size / sizeof(modinfo_t **));
+ } else {
+ module_error("`link_set_modules' section wrong size "
+ "(got %zu, wanted %zu)",
+ size, sizeof(modinfo_t **));
+ }
return ENOEXEC;
}
mod->mod_info = *(modinfo_t **)addr;