Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern module(9): Make error message for multiple MODULE d...



details:   https://anonhg.NetBSD.org/src/rev/f7e202e9eb9f
branches:  trunk
changeset: 373309:f7e202e9eb9f
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Tue Jan 31 13:21:37 2023 +0000

description:
module(9): Make error message for multiple MODULE decls more obvious.

diffstat:

 sys/kern/kern_module.c |  16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diffs (37 lines):

diff -r cd2e840da55e -r f7e202e9eb9f sys/kern/kern_module.c
--- a/sys/kern/kern_module.c    Tue Jan 31 13:09:54 2023 +0000
+++ b/sys/kern/kern_module.c    Tue Jan 31 13:21:37 2023 +0000
@@ -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 @@
                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;



Home | Main Index | Thread Index | Old Index