The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* Question about CONFIG_DEBUG_SECTION_MISMATCH
@ 2021-01-20 18:04 Josh Poimboeuf
  0 siblings, 0 replies; only message in thread
From: Josh Poimboeuf @ 2021-01-20 18:04 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: linux-kernel, Peter Zijlstra

Hi Sam,

I have a question about CONFIG_DEBUG_SECTION_MISMATCH's use of
-fno-inline-functions-called-once.

	  - Add the option -fno-inline-functions-called-once to gcc commands.
	    When inlining a function annotated with __init in a non-init
	    function, we would lose the section information and thus
	    the analysis would not catch the illegal reference.
	    This option tells gcc to inline less (but it does result in
	    a larger kernel).

Is -fno-inline-functions-called-once really needed?

From what I can tell, a .text function inlining an .init.text function
should be harmless unless the inlined function either referenced another
.init.text function, or referenced .init.data.  In either case, that
would be detected by modpost.

Or am I missing another scenario where this flag would be needed?

I verified this with the following patch, it detected a mismatch even
without CONFIG_DEBUG_SECTION_MISMATCH.

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 6bd20c0de8bc..c3e41a3abc7e 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -153,6 +153,18 @@ static inline void imcr_apic_to_pic(void)
  */
 static int force_enable_local_apic __initdata;
 
+static int __init foo(void)
+{
+	if (force_enable_local_apic)
+		return 1;
+	return 0;
+}
+
+int bar(void)
+{
+	return foo();
+}
+
 /*
  * APIC command line parameters
  */

-- 
Josh


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-01-20 18:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-20 18:04 Question about CONFIG_DEBUG_SECTION_MISMATCH Josh Poimboeuf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox