From 1bf41f8a125b85cfe10f0945a686a49d14df1914 Mon Sep 17 00:00:00 2001 From: Laura Abbott Date: Thu, 2 Dec 2010 11:20:32 -0800 Subject: [PATCH] modpost: Make section mismatches an error If any section mismatches are detected the compilation will fail. Section mismatches can go back to being warnings with CONFIG_NO_ERROR_ON_MISMATCH=y. Change-Id: I44f01f348703d2fdda77f2930bc290f6867b5b08 Signed-off-by: Laura Abbott (cherry picked from commit d34cd35c3aacb219de789a61a140e7f095794a3f) --- scripts/Makefile.modpost | 1 + scripts/mod/modpost.c | 28 ++++++++++++++++++++++------ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 08dce14f2dc8..c1bc4588806a 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -80,6 +80,7 @@ modpost = scripts/mod/modpost \ $(if $(KBUILD_EXTRA_SYMBOLS), $(patsubst %, -e %,$(KBUILD_EXTRA_SYMBOLS))) \ $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ $(if $(CONFIG_DEBUG_SECTION_MISMATCH),,-S) \ + $(if $(CONFIG_NO_ERROR_ON_MISMATCH),,-E) \ $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w) \ $(if $(cross_build),-c) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index c4e7d1510f9d..70d211d0b992 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -37,6 +37,8 @@ static int all_versions = 0; static int external_module = 0; /* Warn about section mismatch in vmlinux if set to 1 */ static int vmlinux_section_warnings = 1; +/* Exit with an error when there is a section mismatch if set to 1 */ +static int section_error_on_mismatch; /* Only warn about unresolved symbols */ static int warn_unresolved = 0; /* How a symbol is exported */ @@ -2113,7 +2115,7 @@ int main(int argc, char **argv) struct ext_sym_list *extsym_iter; struct ext_sym_list *extsym_start = NULL; - while ((opt = getopt(argc, argv, "i:I:e:cmsSo:awM:K:")) != -1) { + while ((opt = getopt(argc, argv, "i:I:e:cmsSo:awM:K:E")) != -1) { switch (opt) { case 'i': kernel_read = optarg; @@ -2151,6 +2153,9 @@ int main(int argc, char **argv) case 'w': warn_unresolved = 1; break; + case 'E': + section_error_on_mismatch = 1; + break; default: exit(1); } @@ -2200,11 +2205,22 @@ int main(int argc, char **argv) if (dump_write) write_dump(dump_write); - if (sec_mismatch_count && !sec_mismatch_verbose) - warn("modpost: Found %d section mismatch(es).\n" - "To see full details build your kernel with:\n" - "'make CONFIG_DEBUG_SECTION_MISMATCH=y'\n", - sec_mismatch_count); + + if (sec_mismatch_count && !sec_mismatch_verbose) { + merror( + "modpost: Found %d section mismatch(es).\n" + "To see full details build your kernel with:\n" + "'make CONFIG_DEBUG_SECTION_MISMATCH=y'\n", + sec_mismatch_count); + + if (section_error_on_mismatch) { + err |= 1; + printf( + "To build the kernel despite the mismatches, " + "build with:\n'make CONFIG_NO_ERROR_ON_MISMATCH=y'\n" + "(NOTE: This is not recommended)\n"); + } + } return err; }