summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@chromium.org>2015-10-05 19:14:42 -0400
committerRusty Russell <rusty@rustcorp.com.au>2015-10-05 20:16:21 -0400
commit47490ec141b9944a8a7cbe3bec8b8f4fdaaa700b (patch)
tree250ae9e4fb5f2a956cfc1ab474ffc2872167a231
parent74b22c465cd2b6ff4b8cec3997512ec807e6e495 (diff)
modpost: Add flag -E for making section mismatches fatal
The section mismatch warning can be easy to miss during the kernel build process. Allow it to be marked as fatal to be easily caught and prevent bugs from slipping in. Setting CONFIG_SECTION_MISMATCH_WARN_ONLY=y causes these warnings to be non-fatal, since there are a number of section mismatches when using allmodconfig on some architectures, and we do not want to break these builds by default. Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Change-Id: Ic346706e3297c9f0d790e3552aa94e5cff9897a6 Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
-rw-r--r--lib/Kconfig.debug9
-rw-r--r--scripts/Makefile.modpost1
-rw-r--r--scripts/mod/modpost.c24
3 files changed, 27 insertions, 7 deletions
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index e2894b23efb6..ebe51a34cf48 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -311,6 +311,15 @@ config DEBUG_SECTION_MISMATCH
311 - Enable verbose reporting from modpost in order to help resolve 311 - Enable verbose reporting from modpost in order to help resolve
312 the section mismatches that are reported. 312 the section mismatches that are reported.
313 313
314config SECTION_MISMATCH_WARN_ONLY
315 bool "Make section mismatch errors non-fatal"
316 default y
317 help
318 If you say N here, the build process will fail if there are any
319 section mismatch, instead of just throwing warnings.
320
321 If unsure, say Y.
322
314# 323#
315# Select this config option from the architecture Kconfig, if it 324# Select this config option from the architecture Kconfig, if it
316# is preferred to always offer frame pointers as a config 325# is preferred to always offer frame pointers as a config
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index 69f0a1417e9a..1366a94b6c39 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -77,6 +77,7 @@ modpost = scripts/mod/modpost \
77 $(if $(KBUILD_EXTRA_SYMBOLS), $(patsubst %, -e %,$(KBUILD_EXTRA_SYMBOLS))) \ 77 $(if $(KBUILD_EXTRA_SYMBOLS), $(patsubst %, -e %,$(KBUILD_EXTRA_SYMBOLS))) \
78 $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ 78 $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \
79 $(if $(CONFIG_DEBUG_SECTION_MISMATCH),,-S) \ 79 $(if $(CONFIG_DEBUG_SECTION_MISMATCH),,-S) \
80 $(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \
80 $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w) 81 $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w)
81 82
82MODPOST_OPT=$(subst -i,-n,$(filter -i,$(MAKEFLAGS))) 83MODPOST_OPT=$(subst -i,-n,$(filter -i,$(MAKEFLAGS)))
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index d583c98fde31..b2ae8afc1ab1 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -38,6 +38,7 @@ static int warn_unresolved = 0;
38/* How a symbol is exported */ 38/* How a symbol is exported */
39static int sec_mismatch_count = 0; 39static int sec_mismatch_count = 0;
40static int sec_mismatch_verbose = 1; 40static int sec_mismatch_verbose = 1;
41static int sec_mismatch_fatal = 0;
41/* ignore missing files */ 42/* ignore missing files */
42static int ignore_missing_files; 43static int ignore_missing_files;
43 44
@@ -2385,7 +2386,7 @@ int main(int argc, char **argv)
2385 struct ext_sym_list *extsym_iter; 2386 struct ext_sym_list *extsym_iter;
2386 struct ext_sym_list *extsym_start = NULL; 2387 struct ext_sym_list *extsym_start = NULL;
2387 2388
2388 while ((opt = getopt(argc, argv, "i:I:e:mnsST:o:awM:K:")) != -1) { 2389 while ((opt = getopt(argc, argv, "i:I:e:mnsST:o:awM:K:E")) != -1) {
2389 switch (opt) { 2390 switch (opt) {
2390 case 'i': 2391 case 'i':
2391 kernel_read = optarg; 2392 kernel_read = optarg;
@@ -2426,6 +2427,9 @@ int main(int argc, char **argv)
2426 case 'w': 2427 case 'w':
2427 warn_unresolved = 1; 2428 warn_unresolved = 1;
2428 break; 2429 break;
2430 case 'E':
2431 sec_mismatch_fatal = 1;
2432 break;
2429 default: 2433 default:
2430 exit(1); 2434 exit(1);
2431 } 2435 }
@@ -2475,14 +2479,20 @@ int main(int argc, char **argv)
2475 sprintf(fname, "%s.mod.c", mod->name); 2479 sprintf(fname, "%s.mod.c", mod->name);
2476 write_if_changed(&buf, fname); 2480 write_if_changed(&buf, fname);
2477 } 2481 }
2478
2479 if (dump_write) 2482 if (dump_write)
2480 write_dump(dump_write); 2483 write_dump(dump_write);
2481 if (sec_mismatch_count && !sec_mismatch_verbose) 2484 if (sec_mismatch_count) {
2482 warn("modpost: Found %d section mismatch(es).\n" 2485 if (!sec_mismatch_verbose) {
2483 "To see full details build your kernel with:\n" 2486 warn("modpost: Found %d section mismatch(es).\n"
2484 "'make CONFIG_DEBUG_SECTION_MISMATCH=y'\n", 2487 "To see full details build your kernel with:\n"
2485 sec_mismatch_count); 2488 "'make CONFIG_DEBUG_SECTION_MISMATCH=y'\n",
2489 sec_mismatch_count);
2490 }
2491 if (sec_mismatch_fatal) {
2492 fatal("modpost: Section mismatches detected.\n"
2493 "Set CONFIG_SECTION_MISMATCH_WARN_ONLY=y to allow them.\n");
2494 }
2495 }
2486 2496
2487 return err; 2497 return err;
2488} 2498}