linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] modpost: Add flag -f for making section mismatches fatal
@ 2012-12-20 18:49 Jonathan Kliegman
  2013-01-02 23:56 ` Rusty Russell
  2013-01-06  9:36 ` Sam Ravnborg
  0 siblings, 2 replies; 12+ messages in thread
From: Jonathan Kliegman @ 2012-12-20 18:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Michal Marek, Rusty Russell, Greg Kroah-Hartman, Tony Lindgren,
	linux-kbuild, Jonathan Kliegman

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.

Signed-off-by: Jonathan Kliegman <kliegs@chromium.org>
---
 scripts/Makefile.modpost |    1 +
 scripts/mod/modpost.c    |   24 +++++++++++++++++-------
 2 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index a1cb022..1e496d3 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -81,6 +81,7 @@ modpost = scripts/mod/modpost                    \
  $(if $(KBUILD_EXTMOD),-o $(modulesymfile))      \
  $(if $(CONFIG_DEBUG_SECTION_MISMATCH),,-S)      \
  $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w) \
+ $(if $(CONFIG_SECTION_MISMATCH_FATAL),,-f)      \
  $(if $(cross_build),-c)
 
 quiet_cmd_modpost = MODPOST $(words $(filter-out vmlinux FORCE, $^)) modules
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index ff36c50..5648882 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -42,6 +42,7 @@ static int warn_unresolved = 0;
 /* How a symbol is exported */
 static int sec_mismatch_count = 0;
 static int sec_mismatch_verbose = 1;
+static int sec_mismatch_fatal = 0;
 
 enum export {
 	export_plain,      export_unused,     export_gpl,
@@ -2126,7 +2127,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:f")) != -1) {
 		switch (opt) {
 		case 'i':
 			kernel_read = optarg;
@@ -2164,6 +2165,9 @@ int main(int argc, char **argv)
 		case 'w':
 			warn_unresolved = 1;
 			break;
+		case 'f':
+			sec_mismatch_fatal = 1;
+			break;
 		default:
 			exit(1);
 		}
@@ -2210,14 +2214,20 @@ int main(int argc, char **argv)
 		sprintf(fname, "%s.mod.c", mod->name);
 		write_if_changed(&buf, fname);
 	}
-
 	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) {
+		if (!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_fatal) {
+			fatal("modpost: Section mismatches detected.\n"
+			      "Unset CONFIG_SECTION_MISMATCH_FATAL to allow them.\n");
+		}
+	}
 
 	return err;
 }
-- 
1.7.7.3


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH] modpost: Add flag -f for making section mismatches fatal
  2012-12-20 18:49 [PATCH] modpost: Add flag -f for making section mismatches fatal Jonathan Kliegman
@ 2013-01-02 23:56 ` Rusty Russell
  2013-01-03  9:06   ` Michal Marek
  2013-01-06  9:36 ` Sam Ravnborg
  1 sibling, 1 reply; 12+ messages in thread
From: Rusty Russell @ 2013-01-02 23:56 UTC (permalink / raw)
  To: Jonathan Kliegman, linux-kernel
  Cc: Michal Marek, Greg Kroah-Hartman, Tony Lindgren, linux-kbuild,
	Jonathan Kliegman

Jonathan Kliegman <kliegs@chromium.org> writes:
> 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.
>
> Signed-off-by: Jonathan Kliegman <kliegs@chromium.org>

Hmm, a CONFIG option with no Kconfig entry?  That seems weird...

Cheers,
Rusty.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] modpost: Add flag -f for making section mismatches fatal
  2013-01-02 23:56 ` Rusty Russell
@ 2013-01-03  9:06   ` Michal Marek
  2013-01-03 21:39     ` Jonathan Kliegman
  0 siblings, 1 reply; 12+ messages in thread
From: Michal Marek @ 2013-01-03  9:06 UTC (permalink / raw)
  To: Rusty Russell
  Cc: Jonathan Kliegman, linux-kernel, Greg Kroah-Hartman,
	Tony Lindgren, linux-kbuild

Dne 3.1.2013 00:56, Rusty Russell napsal(a):
> Jonathan Kliegman <kliegs@chromium.org> writes:
>> 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.
>>
>> Signed-off-by: Jonathan Kliegman <kliegs@chromium.org>
> 
> Hmm, a CONFIG option with no Kconfig entry?  That seems weird...

With a Kconfig entry, all{mod,yes}configs would start failing. It can be
enabled with make CONFIG_SECTION_MISMATCH_FATAL=y for now. Maybe it
could be added to Kconfig with 'depends on n', so that it is documented
somewhere.

Michal

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] modpost: Add flag -f for making section mismatches fatal
  2013-01-03  9:06   ` Michal Marek
@ 2013-01-03 21:39     ` Jonathan Kliegman
  2013-01-12 21:24       ` Michal Marek
  0 siblings, 1 reply; 12+ messages in thread
From: Jonathan Kliegman @ 2013-01-03 21:39 UTC (permalink / raw)
  To: Michal Marek
  Cc: Rusty Russell, linux-kernel, Greg Kroah-Hartman, Tony Lindgren,
	linux-kbuild

On Thu, Jan 3, 2013 at 4:06 AM, Michal Marek <mmarek@suse.cz> wrote:
>
> Dne 3.1.2013 00:56, Rusty Russell napsal(a):
> > Jonathan Kliegman <kliegs@chromium.org> writes:
> >> 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.
> >>
> >> Signed-off-by: Jonathan Kliegman <kliegs@chromium.org>
> >
> > Hmm, a CONFIG option with no Kconfig entry?  That seems weird...
>
> With a Kconfig entry, all{mod,yes}configs would start failing. It can be
> enabled with make CONFIG_SECTION_MISMATCH_FATAL=y for now. Maybe it
> could be added to Kconfig with 'depends on n', so that it is documented
> somewhere.
>
Sorry for missing the Kconfig entry.  It looks like init/Kconfig in
the "General setup" seems the best fit as that looks like where the
other build options are.  If this is ok I'll upload a new version of
the patch with the entry added.

I'm not sure what you mean about configs failing.  After adding this
option to init/Kconfig I was able to build fine using old and new
configs with and without the option set.  Is there something specific
you'd like me to test for?

> Michal

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] modpost: Add flag -f for making section mismatches fatal
  2012-12-20 18:49 [PATCH] modpost: Add flag -f for making section mismatches fatal Jonathan Kliegman
  2013-01-02 23:56 ` Rusty Russell
@ 2013-01-06  9:36 ` Sam Ravnborg
  2013-01-06 20:22   ` Jonathan Kliegman
  1 sibling, 1 reply; 12+ messages in thread
From: Sam Ravnborg @ 2013-01-06  9:36 UTC (permalink / raw)
  To: Jonathan Kliegman
  Cc: linux-kernel, Michal Marek, Rusty Russell, Greg Kroah-Hartman,
	Tony Lindgren, linux-kbuild

Hi Jonathan.

> 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.
> 
> Signed-off-by: Jonathan Kliegman <kliegs@chromium.org>

Another way to make them much more visible would be to make
the warnings always be verbose.

In other words drop support for the "-S" options used below:
>   $(if $(CONFIG_DEBUG_SECTION_MISMATCH),,-S) 

Previously the dev* stuff caused a lot of warnings, but
since we have HOTPLUG always enabled this is a non-issue.
So I think that this is a good time to enable the verboce
warnings.

	Sam

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] modpost: Add flag -f for making section mismatches fatal
  2013-01-06  9:36 ` Sam Ravnborg
@ 2013-01-06 20:22   ` Jonathan Kliegman
  2013-01-08 19:16     ` Sam Ravnborg
  0 siblings, 1 reply; 12+ messages in thread
From: Jonathan Kliegman @ 2013-01-06 20:22 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: linux-kernel, Michal Marek, Rusty Russell, Greg Kroah-Hartman,
	Tony Lindgren, linux-kbuild

On Sun, Jan 6, 2013 at 4:36 AM, Sam Ravnborg <sam@ravnborg.org> wrote:
> Hi Jonathan.
>
>> 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.
>>
>> Signed-off-by: Jonathan Kliegman <kliegs@chromium.org>
>
> Another way to make them much more visible would be to make
> the warnings always be verbose.

I'd like to keep the option for a hard fail if a mismatch is detected.
 This way automated build systems will detect the failed build and can
reject a chan

> In other words drop support for the "-S" options used below:
>>   $(if $(CONFIG_DEBUG_SECTION_MISMATCH),,-S)
>
> Previously the dev* stuff caused a lot of warnings, but
> since we have HOTPLUG always enabled this is a non-issue.
> So I think that this is a good time to enable the verboce
> warnings.
I can submit a second patch for this if you'd like, but I'm not
familiar with all the previous decisions in this area.  If I
understand correctly we'll still need the config option as it also
changes compiler flags for inlining.
>
>         Sam

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] modpost: Add flag -f for making section mismatches fatal
  2013-01-06 20:22   ` Jonathan Kliegman
@ 2013-01-08 19:16     ` Sam Ravnborg
  2013-01-08 19:38       ` Jonathan Kliegman
  0 siblings, 1 reply; 12+ messages in thread
From: Sam Ravnborg @ 2013-01-08 19:16 UTC (permalink / raw)
  To: Jonathan Kliegman
  Cc: linux-kernel, Michal Marek, Rusty Russell, Greg Kroah-Hartman,
	Tony Lindgren, linux-kbuild

On Sun, Jan 06, 2013 at 03:22:39PM -0500, Jonathan Kliegman wrote:
> On Sun, Jan 6, 2013 at 4:36 AM, Sam Ravnborg <sam@ravnborg.org> wrote:
> > Hi Jonathan.
> >
> >> 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.
> >>
> >> Signed-off-by: Jonathan Kliegman <kliegs@chromium.org>
> >
> > Another way to make them much more visible would be to make
> > the warnings always be verbose.
> 
> I'd like to keep the option for a hard fail if a mismatch is detected.
>  This way automated build systems will detect the failed build and can
> reject a chan
> 
> > In other words drop support for the "-S" options used below:
> >>   $(if $(CONFIG_DEBUG_SECTION_MISMATCH),,-S)
> >
> > Previously the dev* stuff caused a lot of warnings, but
> > since we have HOTPLUG always enabled this is a non-issue.
> > So I think that this is a good time to enable the verboce
> > warnings.
> I can submit a second patch for this if you'd like, but I'm not
> familiar with all the previous decisions in this area.  If I
> understand correctly we'll still need the config option as it also
> changes compiler flags for inlining.

Correct.
We need one config option that allows us to debug section mismatchs.
This options adds another gcc option as you also points out.
And this is the one that already exist.

And then you suggest to add another options which makes section
mismatch warnings fatal.
This sounds like a good idea but reverse the logic.
Something like:

   CONFIG_SECTION_MISMATCH_WARN
	bool "Section mismatch warnings produced by modpost are non-fatal"
	default y
	help
	  bla bla

Because then you do not cause section mismatch to be fatal for allyesconfig and
allmodconfig builds. We really do not want to go there yet (I think).
I must admit I do not know how many section mismatch warnigns that are lingering
for the different architectures.
If the number is sufficiently low then we could consider go for fatal as default.


And it would be good to have first patch that makes section mismatch warnings verbose,
independent on any config options.

This patch would have to do something like:
- Makes it possible to set CONFIG_DEBUG_SECTION_MISMATCH using menuconfig (I recall there are
  a dependency that avoids this today)
- Drop support for the -S options and drop the bits that set it
- Drop the reference to CONFIG_DEBUG_SECTION_MISMATCH in modpost error message

I would be happy if you could do this and test it.

	Sam

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] modpost: Add flag -f for making section mismatches fatal
  2013-01-08 19:16     ` Sam Ravnborg
@ 2013-01-08 19:38       ` Jonathan Kliegman
  2013-01-08 19:39         ` Sam Ravnborg
  0 siblings, 1 reply; 12+ messages in thread
From: Jonathan Kliegman @ 2013-01-08 19:38 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: linux-kernel, Michal Marek, Rusty Russell, Greg Kroah-Hartman,
	Tony Lindgren, linux-kbuild

On Tue, Jan 8, 2013 at 2:16 PM, Sam Ravnborg <sam@ravnborg.org> wrote:
> On Sun, Jan 06, 2013 at 03:22:39PM -0500, Jonathan Kliegman wrote:
>> On Sun, Jan 6, 2013 at 4:36 AM, Sam Ravnborg <sam@ravnborg.org> wrote:
>> > Hi Jonathan.
>> >
>> >> 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.
>> >>
>> >> Signed-off-by: Jonathan Kliegman <kliegs@chromium.org>
>> >
>> > Another way to make them much more visible would be to make
>> > the warnings always be verbose.
>>
>> I'd like to keep the option for a hard fail if a mismatch is detected.
>>  This way automated build systems will detect the failed build and can
>> reject a chan
>>
>> > In other words drop support for the "-S" options used below:
>> >>   $(if $(CONFIG_DEBUG_SECTION_MISMATCH),,-S)
>> >
>> > Previously the dev* stuff caused a lot of warnings, but
>> > since we have HOTPLUG always enabled this is a non-issue.
>> > So I think that this is a good time to enable the verboce
>> > warnings.
>> I can submit a second patch for this if you'd like, but I'm not
>> familiar with all the previous decisions in this area.  If I
>> understand correctly we'll still need the config option as it also
>> changes compiler flags for inlining.
>
> Correct.
> We need one config option that allows us to debug section mismatchs.
> This options adds another gcc option as you also points out.
> And this is the one that already exist.
>
> And then you suggest to add another options which makes section
> mismatch warnings fatal.
> This sounds like a good idea but reverse the logic.
> Something like:
>
>    CONFIG_SECTION_MISMATCH_WARN
>         bool "Section mismatch warnings produced by modpost are non-fatal"
>         default y
>         help
>           bla bla
>
> Because then you do not cause section mismatch to be fatal for allyesconfig and
> allmodconfig builds. We really do not want to go there yet (I think).
> I must admit I do not know how many section mismatch warnigns that are lingering
> for the different architectures.
> If the number is sufficiently low then we could consider go for fatal as default.
>
>
> And it would be good to have first patch that makes section mismatch warnings verbose,
> independent on any config options.
>
> This patch would have to do something like:
> - Makes it possible to set CONFIG_DEBUG_SECTION_MISMATCH using menuconfig (I recall there are
>   a dependency that avoids this today)
> - Drop support for the -S options and drop the bits that set it
> - Drop the reference to CONFIG_DEBUG_SECTION_MISMATCH in modpost error message
>
> I would be happy if you could do this and test it.
Ok - I understand what you mean now.  I'll put this together as a two
patch sequence then and upload it later this week.  Should I start a
new thread with that since its adding a new patch?  Or just respond
here with it?
>
>         Sam

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] modpost: Add flag -f for making section mismatches fatal
  2013-01-08 19:38       ` Jonathan Kliegman
@ 2013-01-08 19:39         ` Sam Ravnborg
  0 siblings, 0 replies; 12+ messages in thread
From: Sam Ravnborg @ 2013-01-08 19:39 UTC (permalink / raw)
  To: Jonathan Kliegman
  Cc: linux-kernel, Michal Marek, Rusty Russell, Greg Kroah-Hartman,
	Tony Lindgren, linux-kbuild

On Tue, Jan 08, 2013 at 02:38:10PM -0500, Jonathan Kliegman wrote:
> On Tue, Jan 8, 2013 at 2:16 PM, Sam Ravnborg <sam@ravnborg.org> wrote:
> > On Sun, Jan 06, 2013 at 03:22:39PM -0500, Jonathan Kliegman wrote:
> >> On Sun, Jan 6, 2013 at 4:36 AM, Sam Ravnborg <sam@ravnborg.org> wrote:
> >> > Hi Jonathan.
> >> >
> >> >> 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.
> >> >>
> >> >> Signed-off-by: Jonathan Kliegman <kliegs@chromium.org>
> >> >
> >> > Another way to make them much more visible would be to make
> >> > the warnings always be verbose.
> >>
> >> I'd like to keep the option for a hard fail if a mismatch is detected.
> >>  This way automated build systems will detect the failed build and can
> >> reject a chan
> >>
> >> > In other words drop support for the "-S" options used below:
> >> >>   $(if $(CONFIG_DEBUG_SECTION_MISMATCH),,-S)
> >> >
> >> > Previously the dev* stuff caused a lot of warnings, but
> >> > since we have HOTPLUG always enabled this is a non-issue.
> >> > So I think that this is a good time to enable the verboce
> >> > warnings.
> >> I can submit a second patch for this if you'd like, but I'm not
> >> familiar with all the previous decisions in this area.  If I
> >> understand correctly we'll still need the config option as it also
> >> changes compiler flags for inlining.
> >
> > Correct.
> > We need one config option that allows us to debug section mismatchs.
> > This options adds another gcc option as you also points out.
> > And this is the one that already exist.
> >
> > And then you suggest to add another options which makes section
> > mismatch warnings fatal.
> > This sounds like a good idea but reverse the logic.
> > Something like:
> >
> >    CONFIG_SECTION_MISMATCH_WARN
> >         bool "Section mismatch warnings produced by modpost are non-fatal"
> >         default y
> >         help
> >           bla bla
> >
> > Because then you do not cause section mismatch to be fatal for allyesconfig and
> > allmodconfig builds. We really do not want to go there yet (I think).
> > I must admit I do not know how many section mismatch warnigns that are lingering
> > for the different architectures.
> > If the number is sufficiently low then we could consider go for fatal as default.
> >
> >
> > And it would be good to have first patch that makes section mismatch warnings verbose,
> > independent on any config options.
> >
> > This patch would have to do something like:
> > - Makes it possible to set CONFIG_DEBUG_SECTION_MISMATCH using menuconfig (I recall there are
> >   a dependency that avoids this today)
> > - Drop support for the -S options and drop the bits that set it
> > - Drop the reference to CONFIG_DEBUG_SECTION_MISMATCH in modpost error message
> >
> > I would be happy if you could do this and test it.
> Ok - I understand what you mean now.  I'll put this together as a two
> patch sequence then and upload it later this week.  Should I start a
> new thread with that since its adding a new patch?  Or just respond
> here with it?
Start a new thread.

	Sam

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] modpost: Add flag -f for making section mismatches fatal
  2013-01-03 21:39     ` Jonathan Kliegman
@ 2013-01-12 21:24       ` Michal Marek
  0 siblings, 0 replies; 12+ messages in thread
From: Michal Marek @ 2013-01-12 21:24 UTC (permalink / raw)
  To: Jonathan Kliegman
  Cc: Rusty Russell, linux-kernel, Greg Kroah-Hartman, Tony Lindgren,
	linux-kbuild

On 3.1.2013 22:39, Jonathan Kliegman wrote:
> I'm not sure what you mean about configs failing.  After adding this
> option to init/Kconfig I was able to build fine using old and new
> configs with and without the option set.  Is there something specific
> you'd like me to test for?

We still have section mismatches in allmodconfig. With a Kconfig option
to make them fatal, allmodconfig would select it and fail.

Michal

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH] modpost: Add flag -f for making section mismatches fatal
@ 2015-10-02  0:34 Nicolas Boichat
  2015-10-02  1:26 ` Rusty Russell
  0 siblings, 1 reply; 12+ messages in thread
From: Nicolas Boichat @ 2015-10-02  0:34 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Michal Marek, Paul E . McKenney, Andrew Morton, Ingo Molnar,
	Pranith Kumar, Peter Zijlstra, Vladimir Murzin, Davidlohr Bueso,
	Joonsoo Kim, John Stultz, Jan Kiszka, Rusty Russell,
	Quentin Casasnovas, Paul Gortmaker, Chris Metcalf, Takashi Iwai,
	Nicolas Boichat, Kyle McMartin, linux-kernel, Jonathan Kliegman,
	olofj, Sam Ravnborg

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_WARNING=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
---

I'm trying to revive this old patch. When it was first submitted [1],
Jonathan got the following feedback:
 - The logic of the option should be inverted (i.e. SECTION_MISMATCH_WARNING),
   so that is not not enabled in allmodconfig for some architectures that do
   have section mismatches. I've seen some failures (namely, on arm64), so I
   did that.
 - CONFIG_DEBUG_SECTION_MISMATCH should be removed and warnings should always
   be shown verbosely. This option does 3 things:
     1. Enable -fno-inline-functions-called-onc
     2. Run the section mismatch analysis for each module/built-in.o
     3. Enable verbose reporting from modpost
   We definitely do not want 1 by default, so I think we should keep the option.
   If we enable 2 & 3 by default, which I think would be reasonable, then the
   option name does not make much sense anymore, and I'm not sure what to do
   with the documentation that is currently provided in the Kconfig description.

Tested on x86-64 allmodconfig, setting the option to =n, and creating a
section mismatch by running:
sed -i -e 's/\(ssize_t soc_codec_reg_show\)/__init \1/' sound/soc/soc-core.c

Applies on linux-next/20151001

[1] http://thread.gmane.org/gmane.linux.kbuild.devel/9044

 lib/Kconfig.debug        |  9 +++++++++
 scripts/Makefile.modpost |  1 +
 scripts/mod/modpost.c    | 24 +++++++++++++++++-------
 3 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index d190d44..74314bb 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -311,6 +311,15 @@ config DEBUG_SECTION_MISMATCH
 	  - Enable verbose reporting from modpost in order to help resolve
 	    the section mismatches that are reported.
 
+config SECTION_MISMATCH_WARNING
+	bool "Make section mismatch errors non-fatal"
+	default y
+	help
+	  If you say N here, the build process will fail if there are any
+	  section mismatch, instead of just throwing warnings.
+
+	  If unsure, say Y.
+
 #
 # Select this config option from the architecture Kconfig, if it
 # is preferred to always offer frame pointers as a config
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index 9c40dae..d2cbd83 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -77,6 +77,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_SECTION_MISMATCH_WARNING),,-f)    \
  $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w) \
  $(if $(CONFIG_LTO),-w)
 
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index d583c98..bc729b8 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -38,6 +38,7 @@ static int warn_unresolved = 0;
 /* How a symbol is exported */
 static int sec_mismatch_count = 0;
 static int sec_mismatch_verbose = 1;
+static int sec_mismatch_fatal = 0;
 /* ignore missing files */
 static int ignore_missing_files;
 
@@ -2385,7 +2386,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:mnsST:o:awM:K:")) != -1) {
+	while ((opt = getopt(argc, argv, "i:I:e:mnsST:o:awM:K:f")) != -1) {
 		switch (opt) {
 		case 'i':
 			kernel_read = optarg;
@@ -2426,6 +2427,9 @@ int main(int argc, char **argv)
 		case 'w':
 			warn_unresolved = 1;
 			break;
+		case 'f':
+			sec_mismatch_fatal = 1;
+			break;
 		default:
 			exit(1);
 		}
@@ -2475,14 +2479,20 @@ int main(int argc, char **argv)
 		sprintf(fname, "%s.mod.c", mod->name);
 		write_if_changed(&buf, fname);
 	}
-
 	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) {
+		if (!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_fatal) {
+			fatal("modpost: Section mismatches detected.\n"
+			      "Set CONFIG_SECTION_MISMATCH_WARNING=y to allow them.\n");
+		}
+	}
 
 	return err;
 }
-- 
2.6.0.rc2.230.g3dd15c0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH] modpost: Add flag -f for making section mismatches fatal
  2015-10-02  0:34 Nicolas Boichat
@ 2015-10-02  1:26 ` Rusty Russell
  0 siblings, 0 replies; 12+ messages in thread
From: Rusty Russell @ 2015-10-02  1:26 UTC (permalink / raw)
  To: Nicolas Boichat, linux-kbuild
  Cc: Michal Marek, Paul E . McKenney, Andrew Morton, Ingo Molnar,
	Pranith Kumar, Peter Zijlstra, Vladimir Murzin, Davidlohr Bueso,
	Joonsoo Kim, John Stultz, Jan Kiszka, Quentin Casasnovas,
	Paul Gortmaker, Chris Metcalf, Takashi Iwai, Nicolas Boichat,
	Kyle McMartin, linux-kernel, Jonathan Kliegman, olofj,
	Sam Ravnborg

Nicolas Boichat <drinkcat@chromium.org> writes:
> 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_WARNING=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
> ---
>
> I'm trying to revive this old patch. When it was first submitted [1],
> Jonathan got the following feedback:
>  - The logic of the option should be inverted (i.e. SECTION_MISMATCH_WARNING),
>    so that is not not enabled in allmodconfig for some architectures that do
>    have section mismatches. I've seen some failures (namely, on arm64), so I
>    did that.
>  - CONFIG_DEBUG_SECTION_MISMATCH should be removed and warnings should always
>    be shown verbosely. This option does 3 things:
>      1. Enable -fno-inline-functions-called-onc
>      2. Run the section mismatch analysis for each module/built-in.o
>      3. Enable verbose reporting from modpost
>    We definitely do not want 1 by default, so I think we should keep the option.
>    If we enable 2 & 3 by default, which I think would be reasonable, then the
>    option name does not make much sense anymore, and I'm not sure what to do
>    with the documentation that is currently provided in the Kconfig description.
>
> Tested on x86-64 allmodconfig, setting the option to =n, and creating a
> section mismatch by running:
> sed -i -e 's/\(ssize_t soc_codec_reg_show\)/__init \1/' sound/soc/soc-core.c

Minor feedback:

1) Please rename to CONFIG_SECTION_MISMATCH_WARN_ONLY.
2) -f means force, perhaps -E for error?

Otherwise, quite nice.

Thanks,
Rusty.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2015-10-02  1:26 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-20 18:49 [PATCH] modpost: Add flag -f for making section mismatches fatal Jonathan Kliegman
2013-01-02 23:56 ` Rusty Russell
2013-01-03  9:06   ` Michal Marek
2013-01-03 21:39     ` Jonathan Kliegman
2013-01-12 21:24       ` Michal Marek
2013-01-06  9:36 ` Sam Ravnborg
2013-01-06 20:22   ` Jonathan Kliegman
2013-01-08 19:16     ` Sam Ravnborg
2013-01-08 19:38       ` Jonathan Kliegman
2013-01-08 19:39         ` Sam Ravnborg
  -- strict thread matches above, loose matches on Subject: below --
2015-10-02  0:34 Nicolas Boichat
2015-10-02  1:26 ` Rusty Russell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).