aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile5
-rw-r--r--lib/Kconfig.debug30
-rw-r--r--scripts/Makefile.build9
3 files changed, 42 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 6847464402aa..8533f258c0e4 100644
--- a/Makefile
+++ b/Makefile
@@ -520,6 +520,11 @@ KBUILD_CFLAGS += -g
520KBUILD_AFLAGS += -gdwarf-2 520KBUILD_AFLAGS += -gdwarf-2
521endif 521endif
522 522
523# We trigger additional mismatches with less inlining
524ifdef CONFIG_DEBUG_SECTION_MISMATCH
525KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions-called-once)
526endif
527
523# Force gcc to behave correct even for buggy distributions 528# Force gcc to behave correct even for buggy distributions
524KBUILD_CFLAGS += $(call cc-option, -fno-stack-protector) 529KBUILD_CFLAGS += $(call cc-option, -fno-stack-protector)
525 530
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 14fb355e3caa..748e72be6e68 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -79,6 +79,36 @@ config HEADERS_CHECK
79 exported to $(INSTALL_HDR_PATH) (usually 'usr/include' in 79 exported to $(INSTALL_HDR_PATH) (usually 'usr/include' in
80 your build tree), to make sure they're suitable. 80 your build tree), to make sure they're suitable.
81 81
82config DEBUG_SECTION_MISMATCH
83 bool "Enable full Section mismatch analysis"
84 default n
85 help
86 The section mismatch analysis checks if there are illegal
87 references from one section to another section.
88 Linux will during link or during runtime drop some sections
89 and any use of code/data previously in these sections will
90 most likely result in an oops.
91 In the code functions and variables are annotated with
92 __init, __devinit etc. (see full list in include/linux/init.h)
93 which result in the code/data being placed in specific sections.
94 The section mismatch anaylsis are always done after a full
95 kernel build but enabling this options will in addition
96 do the following:
97 - Add the option -fno-inline-functions-called-once to gcc
98 When inlining a function annotated __init in a non-init
99 function we would loose the section information and thus
100 the analysis would not catch the illegal reference.
101 This options tell gcc to inline less but will also
102 result in a larger kernel.
103 - Run the section mismatch analysis for each module/built-in.o
104 When we run the section mismatch analysis on vmlinux.o we
105 looses valueable information about where the mismatch was
106 introduced.
107 Running the analysis for each module/built-in.o file
108 will tell where the mismatch happens much closer to the
109 source. The drawback is that we will report the same
110 mismatch at least twice.
111
82config DEBUG_KERNEL 112config DEBUG_KERNEL
83 bool "Kernel debugging" 113 bool "Kernel debugging"
84 help 114 help
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index db38ef465a63..67fb4530a6ff 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -103,6 +103,10 @@ ifneq ($(KBUILD_CHECKSRC),0)
103 endif 103 endif
104endif 104endif
105 105
106# Do section mismatch analysis for each module/built-in.o
107ifdef CONFIG_DEBUG_SECTION_MISMATCH
108 cmd_secanalysis = ; scripts/mod/modpost $@
109endif
106 110
107# Compile C sources (.c) 111# Compile C sources (.c)
108# --------------------------------------------------------------------------- 112# ---------------------------------------------------------------------------
@@ -268,7 +272,8 @@ ifdef builtin-target
268quiet_cmd_link_o_target = LD $@ 272quiet_cmd_link_o_target = LD $@
269# If the list of objects to link is empty, just create an empty built-in.o 273# If the list of objects to link is empty, just create an empty built-in.o
270cmd_link_o_target = $(if $(strip $(obj-y)),\ 274cmd_link_o_target = $(if $(strip $(obj-y)),\
271 $(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^),\ 275 $(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^) \
276 $(cmd_secanalysis),\
272 rm -f $@; $(AR) rcs $@) 277 rm -f $@; $(AR) rcs $@)
273 278
274$(builtin-target): $(obj-y) FORCE 279$(builtin-target): $(obj-y) FORCE
@@ -316,7 +321,7 @@ $($(subst $(obj)/,,$(@:.o=-objs))) \
316$($(subst $(obj)/,,$(@:.o=-y)))), $^) 321$($(subst $(obj)/,,$(@:.o=-y)))), $^)
317 322
318quiet_cmd_link_multi-y = LD $@ 323quiet_cmd_link_multi-y = LD $@
319cmd_link_multi-y = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) 324cmd_link_multi-y = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) $(cmd_secanalysis)
320 325
321quiet_cmd_link_multi-m = LD [M] $@ 326quiet_cmd_link_multi-m = LD [M] $@
322cmd_link_multi-m = $(cmd_link_multi-y) 327cmd_link_multi-m = $(cmd_link_multi-y)