From 071c66bde32eb0f2a6aed8c6d0f932720c65f38d Mon Sep 17 00:00:00 2001 From: riastradh Date: Tue, 31 Jan 2023 13:21:37 +0000 Subject: [PATCH] module(9): Make error message for multiple MODULE decls more obvious. --- sys/kern/kern_module.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/sys/kern/kern_module.c b/sys/kern/kern_module.c index 0e5c515526c4..ba6ebd65c6b4 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 -__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;