public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: sam@ravnborg.org
To: linux-kernel@vger.kernel.org
Cc: Kirill Korotaev <dev@openvz.org>, Andrey Mirkin <amirkin@sw.ru>,
	Andrew Morton <akpm@osdl.org>, Sam Ravnborg <sam@ravnborg.org>
Subject: [PATCH 18/28] kbuild: fail kernel compilation in case of unresolved module symbols
Date: Sun, 24 Sep 2006 23:18:14 +0200	[thread overview]
Message-ID: <1159132706174-git-send-email-sam@ravnborg.org> (raw)
In-Reply-To: <11591327061320-git-send-email-sam@ravnborg.org>

From: Kirill Korotaev <dev@openvz.org>

At stage 2 modpost utility is used to check modules.  In case of unresolved
symbols modpost only prints warning.

IMHO it is a good idea to fail compilation process in case of unresolved
symbols (at least in modules coming with kernel), since usually such errors
are left unnoticed, but kernel modules are broken.

- new option '-w' is added to modpost:
  if option is specified, modpost only warns about unresolved symbols

- modpost is called with '-w' for external modules in Makefile.modpost

Signed-off-by: Andrey Mirkin <amirkin@sw.ru>
Signed-off-by: Kirill Korotaev <dev@openvz.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
---
 scripts/Makefile.modpost |    1 +
 scripts/mod/modpost.c    |   25 +++++++++++++++++++------
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index 9137df2..4b2721c 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -58,6 +58,7 @@ quiet_cmd_modpost = MODPOST $(words $(fi
 	$(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \
 	$(if $(KBUILD_EXTMOD),-I $(modulesymfile)) \
 	$(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \
+	$(if $(KBUILD_EXTMOD),-w) \
 	$(wildcard vmlinux) $(filter-out FORCE,$^)
 
 PHONY += __modpost
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 16a1935..4127796 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -23,6 +23,8 @@ int have_vmlinux = 0;
 static int all_versions = 0;
 /* If we are modposting external module set to 1 */
 static int external_module = 0;
+/* Only warn about unresolved symbols */
+static int warn_unresolved = 0;
 /* How a symbol is exported */
 enum export {
 	export_plain,      export_unused,     export_gpl,
@@ -1196,16 +1198,19 @@ static void add_header(struct buffer *b,
 /**
  * Record CRCs for unresolved symbols
  **/
-static void add_versions(struct buffer *b, struct module *mod)
+static int add_versions(struct buffer *b, struct module *mod)
 {
 	struct symbol *s, *exp;
+	int err = 0;
 
 	for (s = mod->unres; s; s = s->next) {
 		exp = find_symbol(s->name);
 		if (!exp || exp->module == mod) {
-			if (have_vmlinux && !s->weak)
+			if (have_vmlinux && !s->weak) {
 				warn("\"%s\" [%s.ko] undefined!\n",
 				     s->name, mod->name);
+				err = warn_unresolved ? 0 : 1;
+			}
 			continue;
 		}
 		s->module = exp->module;
@@ -1214,7 +1219,7 @@ static void add_versions(struct buffer *
 	}
 
 	if (!modversions)
-		return;
+		return err;
 
 	buf_printf(b, "\n");
 	buf_printf(b, "static const struct modversion_info ____versions[]\n");
@@ -1234,6 +1239,8 @@ static void add_versions(struct buffer *
 	}
 
 	buf_printf(b, "};\n");
+
+	return err;
 }
 
 static void add_depends(struct buffer *b, struct module *mod,
@@ -1411,8 +1418,9 @@ int main(int argc, char **argv)
 	char *kernel_read = NULL, *module_read = NULL;
 	char *dump_write = NULL;
 	int opt;
+	int err;
 
-	while ((opt = getopt(argc, argv, "i:I:mo:a")) != -1) {
+	while ((opt = getopt(argc, argv, "i:I:mo:aw")) != -1) {
 		switch(opt) {
 			case 'i':
 				kernel_read = optarg;
@@ -1430,6 +1438,9 @@ int main(int argc, char **argv)
 			case 'a':
 				all_versions = 1;
 				break;
+			case 'w':
+				warn_unresolved = 1;
+				break;
 			default:
 				exit(1);
 		}
@@ -1450,6 +1461,8 @@ int main(int argc, char **argv)
 		check_exports(mod);
 	}
 
+	err = 0;
+
 	for (mod = modules; mod; mod = mod->next) {
 		if (mod->skip)
 			continue;
@@ -1457,7 +1470,7 @@ int main(int argc, char **argv)
 		buf.pos = 0;
 
 		add_header(&buf, mod);
-		add_versions(&buf, mod);
+		err |= add_versions(&buf, mod);
 		add_depends(&buf, mod, modules);
 		add_moddevtable(&buf, mod);
 		add_srcversion(&buf, mod);
@@ -1469,5 +1482,5 @@ int main(int argc, char **argv)
 	if (dump_write)
 		write_dump(dump_write);
 
-	return 0;
+	return err;
 }
-- 
1.4.1


  reply	other threads:[~2006-09-24 21:19 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-24 21:17 [PATCH 1/28] kconfig: support DOS line endings sam
2006-09-24 21:17 ` [PATCH 2/28] kbuild: consistently decide when to rebuild a target sam
2006-09-24 21:17   ` [PATCH 3/28] kbuild: add unifdef sam
2006-09-24 21:18     ` [PATCH 4/28] kbuild: replace use of strlcpy with a dedicated implmentation in unifdef sam
2006-09-24 21:18       ` [PATCH 5/28] kbuild: use in-kernel unifdef sam
2006-09-24 21:18         ` [PATCH 6/28] remove RPM_BUILD_ROOT from asm-offsets.h sam
2006-09-24 21:18           ` [PATCH 7/28] kconfig: linguistic fixes for Documentation/kbuild/kconfig-language.txt sam
2006-09-24 21:18             ` [PATCH 8/28] kbuild: linguistic fixes for Documentation/kbuild/modules.txt sam
2006-09-24 21:18               ` [PATCH 9/28] kbuild: linguistic fixes for Documentation/kbuild/makefiles.txt sam
2006-09-24 21:18                 ` [PATCH 10/28] kbuild: ignore references from ".pci_fixup" to ".init.text" sam
2006-09-24 21:18                   ` [PATCH 11/28] kbuild: modpost on vmlinux regardless of CONFIG_MODULES sam
2006-09-24 21:18                     ` [PATCH 12/28] kbuild: make V=2 tell why a target is rebuild sam
2006-09-24 21:18                       ` [PATCH 13/28] kbuild: make -rR is now default sam
2006-09-24 21:18                         ` [PATCH 14/28] kbuild: preperly align SYSMAP output sam
2006-09-24 21:18                           ` [PATCH 15/28] kbuild: add missing return statement in modpost.c:secref_whitelist() sam
2006-09-24 21:18                             ` [PATCH 16/28] kbuild: create output directory for hostprogs with O=.. build sam
2006-09-24 21:18                               ` [PATCH 17/28] kbuild: remove debug left-over from Makefile.host sam
2006-09-24 21:18                                 ` sam [this message]
2006-09-24 21:18                                   ` [PATCH 19/28] kbuild: update help in top level Makefile sam
2006-09-24 21:18                                     ` [PATCH 20/28] Documentaion: update Documentation/Changes with minimum versions sam
2006-09-24 21:18                                       ` [PATCH 21/28] kbuild: clarify "make C=" build option sam
2006-09-24 21:18                                         ` [PATCH 22/28] kbuild: fix for some typos in Documentation/makefiles.txt sam
2006-09-24 21:18                                           ` [PATCH 23/28] kbuild: Extend kbuild/defconfig tags support to exuberant ctags sam
2006-09-24 21:18                                             ` [PATCH 24/28] kbuild: fixup Documentation/kbuild/modules.txt sam
2006-09-24 21:18                                               ` [PATCH 25/28] kbuild: correct and clarify versioning info in Makefile sam
2006-09-24 21:18                                                 ` [PATCH 26/28] kbuild: fix "mkdir -p" usage in scripts/package/mkspec sam
2006-09-24 21:18                                                   ` [PATCH 27/28] dontdiff: add utsrelease.h sam
2006-09-24 21:18                                                     ` [PATCH 28/28] kbuild: add distclean info to 'make help' and more details for 'clean' sam
2006-09-24 22:20                                   ` [PATCH 18/28] kbuild: fail kernel compilation in case of unresolved module symbols Al Viro
2006-09-24 22:35                                     ` Sam Ravnborg
2006-09-24 22:36                                       ` Al Viro
2006-09-24 22:47                                         ` Sam Ravnborg
2006-09-24 22:48                                           ` Al Viro
2006-09-25  6:24                         ` [PATCH 13/28] kbuild: make -rR is now default Jan Engelhardt
2006-09-25 18:02                           ` Sam Ravnborg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1159132706174-git-send-email-sam@ravnborg.org \
    --to=sam@ravnborg.org \
    --cc=akpm@osdl.org \
    --cc=amirkin@sw.ru \
    --cc=dev@openvz.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox