Skip to contentSkip to conversation

kbuild: Add "Section mismatch" warning whitelist for powerpc

PATCH In review Li Yang 6 participants 12 messages May 14, 2007 – May 15, 2007 Kbuild

lore
Share & tools
lore

Li Yang

author
#0 lore raw

PATCH 1/2 kbuild: Add "Section mismatch" warning whitelist for powerpc

This patch fixes the following "Section mismatch" warnings when build powerpc platforms.

-------------
WARNING: arch/powerpc/mm/built-in.o - Section mismatch: reference to .init.text:early_get_page from .text between 'pte_alloc_one_kernel' (at offset 0xc68) and 'pte_alloc_one'
WARNING: mm/built-in.o - Section mismatch: reference to .init.text:set_up_list3s from .text between 'kmem_cache_create' (at offset 0x20300) and 'cache_reap'
-------------

Massive warnings represented by:
-------------
WARNING: arch/powerpc/kernel/built-in.o - Section mismatch: reference to .init.data:.got2 from prom_entry (offset 0x0)
WARNING: arch/powerpc/platforms/built-in.o - Section mismatch: reference to .init.text:mpc8313_rdb_probe from .machine.desc after 'mach_mpc8313_rdb' (at offset 0x4)
-------------

---
scripts/mod/modpost.c | 16 ++++++++++++----

1 files changed, 12 insertions(+), 4 deletions(-)
scripts/mod/modpost.c +4 -3
index c89cb71..aa3a881 100644
@@ -649,9 +649,10 @@ static int strrcmp(const char *s, const char *sub)
 *  tosec    = .init.text
 *
 * Pattern 10:
- *  ia64 has machvec table for each platform. It is mixture of function
- *  pointer of .init.text and .text.
- *  fromsec  = .machvec
+ *  ia64 has machvec table and powerpc has machine desc table for each
+ *  platform. It is mixture of function pointer of .init.text and .text.
+ *  fromsec  = .machvec | .machine.desc
+ *
 **/

static int secref_whitelist(const char *modname, const char *tosec,
const char *fromsec, const char *atsym,
@@ -681,6 +682,8 @@ static int secref_whitelist(const char *modname, const char *tosec,

	const char *pat4sym[] = {
		"sparse_index_alloc",
		"zone_wait_table_init",
+		"pte_alloc_one_kernel",
+		"kmem_cache_create",
		NULL
	};

@@ -750,7 +753,8 @@ static int secref_whitelist(const char *modname, const char *tosec,

				return 1;

	/* Check for pattern 10 */
-	if (strcmp(fromsec, ".machvec") == 0)
+	if ((strcmp(fromsec, ".machvec") == 0) ||
+	    (strcmp(fromsec, ".machine.desc") == 0))
		return 1;

	return 0;
@@ -883,6 +887,10 @@ static void warn_sec_mismatch(const char *modname, const char *fromsec,
	    secref_whitelist(modname, secname, fromsec,
			     elf->strtab + before->st_name, refsymname))
		return;

+ /* fromsec whitelist - without a valid 'before' */
+ /* powerpc has a GOT table in .got2 section */
+ if (strcmp(fromsec, ".got2") == 0)
+ return;

	if (before && after) {
		warn("%s - Section mismatch: reference to %s:%s from %s "
Acked-by on v1 1/2
#1 lore raw
Quoted 21 lines · Li Yang

This patch fixes the following "Section mismatch" warnings when build powerpc platforms.

-------------
WARNING: arch/powerpc/mm/built-in.o - Section mismatch: reference to .init.text:early_get_page from .text between 'pte_alloc_one_kernel' (at offset 0xc68) and 'pte_alloc_one'
WARNING: mm/built-in.o - Section mismatch: reference to .init.text:set_up_list3s from .text between 'kmem_cache_create' (at offset 0x20300) and 'cache_reap'
-------------

Massive warnings represented by:
-------------
WARNING: arch/powerpc/kernel/built-in.o - Section mismatch: reference to .init.data:.got2 from prom_entry (offset 0x0)
WARNING: arch/powerpc/platforms/built-in.o - Section mismatch: reference to .init.text:mpc8313_rdb_probe from .machine.desc after 'mach_mpc8313_rdb' (at offset 0x4)
-------------

Quoted 1 line
Quoted 56 lines

---
scripts/mod/modpost.c | 16 ++++++++++++----

1 files changed, 12 insertions(+), 4 deletions(-)
scripts/mod/modpost.c +8 -4
index c89cb71..aa3a881 100644
@@ -649,9 +649,10 @@ static int strrcmp(const char *s, const char *sub)
 *  tosec    = .init.text
 *
 * Pattern 10:
- *  ia64 has machvec table for each platform. It is mixture of function
- *  pointer of .init.text and .text.
- *  fromsec  = .machvec
+ *  ia64 has machvec table and powerpc has machine desc table for each
+ *  platform. It is mixture of function pointer of .init.text and .text.
+ *  fromsec  = .machvec | .machine.desc
+ *
 **/
 static int secref_whitelist(const char *modname, const char *tosec,
 			    const char *fromsec, const char *atsym,
@@ -681,6 +682,8 @@ static int secref_whitelist(const char *modname, const 
 char *tosec,
 	const char *pat4sym[] = {
 		"sparse_index_alloc",
 		"zone_wait_table_init",
+		"pte_alloc_one_kernel",
+		"kmem_cache_create",
 		NULL
 	};
@@ -750,7 +753,8 @@ static int secref_whitelist(const char *modname, const 
 char *tosec,
 				return 1;
 
 	/* Check for pattern 10 */
-	if (strcmp(fromsec, ".machvec") == 0)
+	if ((strcmp(fromsec, ".machvec") == 0) ||
+	    (strcmp(fromsec, ".machine.desc") == 0))
 		return 1;
 
	return 0;
scripts/mod/modpost.c +4 -0
@@ -883,6 +887,10 @@ static void warn_sec_mismatch(const char *modname, 
 const char *fromsec,
 	    secref_whitelist(modname, secname, fromsec,
 			     elf->strtab + before->st_name, refsymname))
 		return;
+	/* fromsec whitelist - without a valid 'before' */
+	/* powerpc has a GOT table in .got2 section */
+	if (strcmp(fromsec, ".got2") == 0)
+		return;
 
 	if (before && after) {

warn("%s - Section mismatch: reference to %s:%s from %s "

#2 lore raw
Quoted 4 lines · Sam Ravnborg
Quoted 3 lines · Li Yang

This patch fixes the following "Section mismatch" warnings when build powerpc platforms.

Quoted 8 lines
Quoted 8 lines

-------------
WARNING: arch/powerpc/mm/built-in.o - Section mismatch: reference to .init.text:early_get_page from .text between 'pte_alloc_one_kernel' (at offset 0xc68) and 'pte_alloc_one'
WARNING: mm/built-in.o - Section mismatch: reference to .init.text:set_up_list3s from .text between 'kmem_cache_create' (at offset 0x20300) and 'cache_reap'
-------------

This warnings should be handled by __init_refok instead.

- k

Quoted 79 lines
Quoted 10 lines

Massive warnings represented by:
-------------
WARNING: arch/powerpc/kernel/built-in.o - Section mismatch: reference to .init.data:.got2 from prom_entry (offset 0x0)
WARNING: arch/powerpc/platforms/built-in.o - Section mismatch: reference to .init.text:mpc8313_rdb_probe from .machine.desc after 'mach_mpc8313_rdb' (at offset 0x4)
-------------

Quoted 60 lines

---
scripts/mod/modpost.c | 16 ++++++++++++----

1 files changed, 12 insertions(+), 4 deletions(-)
scripts/mod/modpost.c +0 -1
index c89cb71..aa3a881 100644
@@ -649,9 +649,10 @@ static int strrcmp(const char *s, const char  
 *sub)
 *  tosec    = .init.text
 *
 * Pattern 10:
- *  ia64 has machvec table for each platform. It is mixture of  

function

- *  pointer of .init.text and .text.
- *  fromsec  = .machvec
+ *  ia64 has machvec table and powerpc has machine desc table for  

each
+ * platform. It is mixture of function pointer of .init.text and .text.
+ * fromsec = .machvec | .machine.desc
+ *
**/
static int secref_whitelist(const char *modname, const char *tosec,
const char *fromsec, const char *atsym,

scripts/mod/modpost.c +2 -0
@@ -681,6 +682,8 @@ static int secref_whitelist(const char  
 *modname, const
 char *tosec,
 	const char *pat4sym[] = {
 		"sparse_index_alloc",
 		"zone_wait_table_init",
+		"pte_alloc_one_kernel",
+		"kmem_cache_create",
 		NULL
	};
scripts/mod/modpost.c +2 -1
@@ -750,7 +753,8 @@ static int secref_whitelist(const char  
 *modname, const
 char *tosec,
 				return 1;
 
 	/* Check for pattern 10 */
-	if (strcmp(fromsec, ".machvec") == 0)
+	if ((strcmp(fromsec, ".machvec") == 0) ||
+	    (strcmp(fromsec, ".machine.desc") == 0))
 		return 1;
	return 0;
scripts/mod/modpost.c +4 -0
@@ -883,6 +887,10 @@ static void warn_sec_mismatch(const char  
 *modname,
 const char *fromsec,
 	    secref_whitelist(modname, secname, fromsec,
 			     elf->strtab + before->st_name, refsymname))
 		return;
+	/* fromsec whitelist - without a valid 'before' */
+	/* powerpc has a GOT table in .got2 section */
+	if (strcmp(fromsec, ".got2") == 0)
+		return;
 
Quoted 3 lines
	if (before && after) {
		warn("%s - Section mismatch: reference to %s:%s from %s "

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#3 lore raw
Quoted 17 lines · On Mon, 14 May 2007 08:56:52 -0500 Kumar Gala <[email protected]> wrote:
Quoted 4 lines · Sam Ravnborg
Quoted 3 lines · Li Yang

This patch fixes the following "Section mismatch" warnings when build powerpc platforms.

Quoted 10 lines
Quoted 10 lines

-------------
WARNING: arch/powerpc/mm/built-in.o - Section mismatch: reference to .init.text:early_get_page from .text between 'pte_alloc_one_kernel' (at
offset 0xc68) and 'pte_alloc_one'
WARNING: mm/built-in.o - Section mismatch: reference to .init.text:set_up_list3s from .text between 'kmem_cache_create' (at offset
0x20300) and 'cache_reap'
-------------

Quoted 2 lines

This warnings should be handled by __init_refok instead.

Yes, I think so.

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines

Massive warnings represented by:
-------------
WARNING: arch/powerpc/kernel/built-in.o - Section mismatch:
reference to
.init.data:.got2 from prom_entry (offset 0x0)
WARNING: arch/powerpc/platforms/built-in.o - Section mismatch:
reference to
.init.text:mpc8313_rdb_probe from .machine.desc after 'mach_mpc8313_rdb'
(at offset 0x4)
-------------

Quoted 2 lines
Quoted 2 lines
Quoted 1 line

I always get confused when a git-tree-owner says "acked-by" against a patch which falls within his tree's area. An acked-by would mean "I'm OK with the patch, please apply it". But I'd have expected to see a "thanks, applied" instead.

If it was "Andrew: please merge and send to Linus because it's urgent and I can't be bothered setting up a git pull for it" then fine, but please be explicit about that.

#4 lore raw
Quoted 41 lines · Andrew Morton
Quoted 17 lines · On Mon, 14 May 2007 08:56:52 -0500 Kumar Gala <[email protected]> wrote:
Quoted 4 lines · Sam Ravnborg
Quoted 3 lines · Li Yang

This patch fixes the following "Section mismatch" warnings when build powerpc platforms.

Quoted 10 lines
Quoted 10 lines

-------------
WARNING: arch/powerpc/mm/built-in.o - Section mismatch: reference to .init.text:early_get_page from .text between 'pte_alloc_one_kernel' (at
offset 0xc68) and 'pte_alloc_one'
WARNING: mm/built-in.o - Section mismatch: reference to .init.text:set_up_list3s from .text between 'kmem_cache_create' (at offset
0x20300) and 'cache_reap'
-------------

Quoted 2 lines

This warnings should be handled by __init_refok instead.

Yes, I think so.

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines

Massive warnings represented by:
-------------
WARNING: arch/powerpc/kernel/built-in.o - Section mismatch:
reference to
.init.data:.got2 from prom_entry (offset 0x0)
WARNING: arch/powerpc/platforms/built-in.o - Section mismatch:
reference to
.init.text:mpc8313_rdb_probe from .machine.desc after 'mach_mpc8313_rdb'
(at offset 0x4)
-------------

Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 8 lines

I always get confused when a git-tree-owner says "acked-by" against a patch which falls within his tree's area. An acked-by would mean "I'm OK with the patch, please apply it". But I'd have expected to see a "thanks, applied" instead.

If it was "Andrew: please merge and send to Linus because it's urgent and I can't be bothered setting up a git pull for it" then fine, but please be explicit about that.

I'd prefer to handle the ppc specific bits through the powerpc.git since they are only warnings and we should be able to fix them up for the next 2.6.22-rc unless Linus is on a made dash to get 2.6.22 out faster than any previous release :)

- k

#5 lore raw
In reply to Andrew Morton
Quoted 8 lines · Andrew Morton
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

I always get confused when a git-tree-owner says "acked-by" against a patch which falls within his tree's area. An acked-by would mean "I'm OK with the patch, please apply it". But I'd have expected to see a "thanks, applied" instead.

I have saved the patch so I can apply it if Linus does not do so. My "Acked-by:" was actually mostly to tell Linus that I was OK with the modpost changes although I did not write so in my mail.

So if this is not picked up by Linus I will pick up this patch.

Sam

#6 lore raw
In reply to Kumar Gala

Hi,

Quoted 18 lines · Kumar Gala
Quoted 4 lines · Sam Ravnborg
Quoted 3 lines · Li Yang

This patch fixes the following "Section mismatch" warnings when build powerpc platforms.

Quoted 10 lines
Quoted 10 lines

-------------
WARNING: arch/powerpc/mm/built-in.o - Section mismatch: reference to .init.text:early_get_page from .text between 'pte_alloc_one_kernel' (at
offset 0xc68) and 'pte_alloc_one'
WARNING: mm/built-in.o - Section mismatch: reference to .init.text:set_up_list3s from .text between 'kmem_cache_create' (at offset
0x20300) and 'cache_reap'
-------------

Quoted 1 line

This warnings should be handled by __init_refok instead.

Actually, once __init_refok comes in, would we need any other whitelisting mechanism at all? I think the exception patterns in secref_whitelist() and those two other whitelisting functions (init_section_ref_ok and exit_section_ref_ok) could all be subsumed and made redundant if / when __init_refok is used in the actual sources.

Satyam

#7 lore raw
Quoted 7 lines

-----Original Message-----
From: Satyam Sharma [mailto:[email protected]]
Sent: Tuesday, May 15, 2007 8:18 AM
To: Kumar Gala
Cc: Sam Ravnborg; Li Yang-r58472; Linus; Andrew Morton; Linux Kernel; [email protected]
Subject: Re: [PATCH 1/2] kbuild: Add "Section mismatch" warning

whitelist for

Quoted 14 lines

powerpc
=20
Hi,
=20

Quoted 9 lines · Kumar Gala
Quoted 6 lines · Sam Ravnborg
Quoted 5 lines · Li Yang

This patch fixes the following "Section mismatch" warnings when build powerpc platforms.

-------------
WARNING: arch/powerpc/mm/built-in.o - Section mismatch: reference

to

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines

.init.text:early_get_page from .text between 'pte_alloc_one_kernel' (at
offset 0xc68) and 'pte_alloc_one'
WARNING: mm/built-in.o - Section mismatch: reference to .init.text:set_up_list3s from .text between 'kmem_cache_create' (at offset
0x20300) and 'cache_reap'
-------------

Quoted 8 lines
Quoted 1 line

This warnings should be handled by __init_refok instead.

=20
Actually, once __init_refok comes in, would we need any other whitelisting mechanism at all? I think the exception patterns in secref_whitelist() and those two other whitelisting functions (init_section_ref_ok and exit_section_ref_ok) could all be subsumed and made redundant if / when __init_refok is used in the actual sources.

I don't think so. __init_refok can be used to mark special functions which are legitimate to reference .init.text/.init.data but cannot be used to mark special sections.

- Leo

#8 lore raw
Quoted 10 lines · On 5/15/07, Li Yang-r58472 <[email protected]> wrote:
Quoted 7 lines

[...]
Actually, once __init_refok comes in, would we need any other whitelisting mechanism at all? I think the exception patterns in secref_whitelist() and those two other whitelisting functions (init_section_ref_ok and exit_section_ref_ok) could all be subsumed and made redundant if / when __init_refok is used in the actual sources.

I don't think so. __init_refok can be used to mark special functions which are legitimate to reference .init.text/.init.data

But I have slightly different (reversed) semantics for __init_refok in mind. Basically, we use __init_refok to annotate _callees_ and not _callers_. In short, __init_refok is a _type_ of __init section that other sections can freely reference to, without modpost complaining about this. [ had suggested this in some previous thread earlier ]

The __init_refok-for-callees mechanism could be useful to reduce duplication, having to mark lesser number of functions, and also make most of those exception patterns in modpost.c redundant.

Ultimately, we want modpost to shut up for some known false positives. Currently we have 9 exception patterns, 'n' number of special sections hard-coded in modpost.c, 3 whitelisting functions and also the __init_refok thing that can be used directly to mark functions in the sources. But modpost doesn't really care _how_ a particular case got whitelisted.

Using _only_ the __init_refok (easily greppable in the sources) annotation for callees could help keep all such special cases manageable and in control, compared to several different ways to dodge modpost warnings.

Quoted 1 line

but cannot be used to mark special sections.

Yes, so mark the special _callees_ as __init_refok.

#9 lore raw
Quoted 7 lines · On Tue, 15 May 2007 15:33:50 +0530 "Satyam Sharma" <[email protected]>…

But I have slightly different (reversed) semantics for __init_refok in mind. Basically, we use __init_refok to annotate _callees_ and not _callers_. In short, __init_refok is a _type_ of __init section that other sections can freely reference to, without modpost complaining about this. [ had suggested this in some previous thread earlier ]

But lots of __init routines cannot be called from just anywhere, it is the special circumstances of some of the callers that makes the call from non-init to init ok. So you need to mark the callers specially.

--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/

#10 lore raw
In reply to Kumar Gala
Quoted 5 lines

-----Original Message-----
From: Kumar Gala [mailto:[email protected]]
Sent: Monday, May 14, 2007 9:57 PM
To: Sam Ravnborg
Cc: Li Yang-r58472; Linus; Andrew Morton; Linux Kernel;

[email protected]

Quoted 1 line

Subject: Re: [PATCH 1/2] kbuild: Add "Section mismatch" warning

whitelist for

Quoted 11 lines

powerpc
=20
=20
On May 14, 2007, at 6:06 AM, Sam Ravnborg wrote:
=20

Quoted 6 lines · Li Yang
Quoted 5 lines

This patch fixes the following "Section mismatch" warnings when build powerpc platforms.

-------------
WARNING: arch/powerpc/mm/built-in.o - Section mismatch: reference

to

Quoted 10 lines
Quoted 8 lines
Quoted 8 lines

.init.text:early_get_page from .text between 'pte_alloc_one_kernel' (at
offset 0xc68) and 'pte_alloc_one'
WARNING: mm/built-in.o - Section mismatch: reference to .init.text:set_up_list3s from .text between 'kmem_cache_create' (at offset
0x20300) and 'cache_reap'
-------------

=20
This warnings should be handled by __init_refok instead.

Yes. When __init_refok gets in, we can change all Pattern 9 members in the whitelist to use __init_refok.

- Leo

#11 lore raw
Quoted 29 lines · On Tue, May 15, 2007 at 05:36:40PM +0800, Li Yang-r58472 wrote:
Quoted 5 lines

-----Original Message-----
From: Kumar Gala [mailto:[email protected]]
Sent: Monday, May 14, 2007 9:57 PM
To: Sam Ravnborg
Cc: Li Yang-r58472; Linus; Andrew Morton; Linux Kernel;

[email protected]

Quoted 1 line

Subject: Re: [PATCH 1/2] kbuild: Add "Section mismatch" warning

whitelist for

Quoted 11 lines

powerpc

Quoted 6 lines · Sam Ravnborg
Quoted 5 lines · Li Yang

This patch fixes the following "Section mismatch" warnings when build powerpc platforms.

-------------
WARNING: arch/powerpc/mm/built-in.o - Section mismatch: reference

to

Quoted 9 lines
Quoted 8 lines
Quoted 8 lines

.init.text:early_get_page from .text between 'pte_alloc_one_kernel' (at
offset 0xc68) and 'pte_alloc_one'
WARNING: mm/built-in.o - Section mismatch: reference to .init.text:set_up_list3s from .text between 'kmem_cache_create' (at offset
0x20300) and 'cache_reap'
-------------

Quoted 4 lines
Quoted 1 line

This warnings should be handled by __init_refok instead.

Yes. When __init_refok gets in, we can change all Pattern 9 members in the whitelist to use __init_refok.

I have applied the patch without the fixes for the above functions. Will merge and push the __init_refok changes soonish.

Sam