mm: fix section mismatch warnings
[sfrench/cifs-2.6.git] / scripts / mod / modpost.c
index ce7e0d17bae26955fe73a1d54838fa898735d140..8424d1f53bbe6e2b9cb646ee32d94fe239c89938 100644 (file)
@@ -583,6 +583,12 @@ static int strrcmp(const char *s, const char *sub)
 
 /**
  * Whitelist to allow certain references to pass with no warning.
+ *
+ * Pattern 0:
+ *   Do not warn if funtion/data are marked with __init_refok/__initdata_refok.
+ *   The pattern is identified by:
+ *   fromsec = .text.init.refok | .data.init.refok
+ *
  * Pattern 1:
  *   If a module parameter is declared __initdata and permissions=0
  *   then this is legal despite the warning generated.
@@ -620,14 +626,6 @@ static int strrcmp(const char *s, const char *sub)
  *   This pattern is identified by
  *   refsymname = __init_begin, _sinittext, _einittext
  *
- * Pattern 6:
- *   During the early init phase we have references from .init.text to
- *   .text we have an intended section mismatch - do not warn about it.
- *   See kernel_init() in init/main.c
- *   tosec   = .init.text
- *   fromsec = .text
- *   atsym = kernel_init
- *
  * Pattern 7:
  *  Logos used in drivers/video/logo reside in __initdata but the
  *  funtion that references them are EXPORT_SYMBOL() so cannot be
@@ -643,16 +641,11 @@ static int strrcmp(const char *s, const char *sub)
  *  tosec   = .init.text
  *  fromsec  = .paravirtprobe
  *
- * Pattern 9:
- *  Some of functions are common code between boot time and hotplug
- *  time. The bootmem allocater is called only boot time in its
- *  functions. So it's ok to reference.
- *  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 for each platform and
+ *  powerpc has a machine desc table for each platform.
+ *  It is mixture of function pointers 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,
@@ -679,11 +672,10 @@ static int secref_whitelist(const char *modname, const char *tosec,
                NULL
        };
 
-       const char *pat4sym[] = {
-               "sparse_index_alloc",
-               "zone_wait_table_init",
-               NULL
-       };
+       /* Check for pattern 0 */
+       if ((strcmp(fromsec, ".text.init.refok") == 0) ||
+           (strcmp(fromsec, ".data.init.refok") == 0))
+               return 1;
 
        /* Check for pattern 1 */
        if (strcmp(tosec, ".init.data") != 0)
@@ -726,12 +718,6 @@ static int secref_whitelist(const char *modname, const char *tosec,
                if (strcmp(refsymname, *s) == 0)
                        return 1;
 
-       /* Check for pattern 6 */
-       if ((strcmp(tosec, ".init.text") == 0) &&
-           (strcmp(fromsec, ".text") == 0) &&
-           (strcmp(refsymname, "kernel_init") == 0))
-               return 1;
-
        /* Check for pattern 7 */
        if ((strcmp(tosec, ".init.data") == 0) &&
            (strncmp(fromsec, ".text", strlen(".text")) == 0) &&
@@ -743,15 +729,9 @@ static int secref_whitelist(const char *modname, const char *tosec,
            (strcmp(fromsec, ".paravirtprobe") == 0))
                return 1;
 
-       /* Check for pattern 9 */
-       if ((strcmp(tosec, ".init.text") == 0) &&
-           (strcmp(fromsec, ".text") == 0))
-               for (s = pat4sym; *s; s++)
-                       if (strcmp(atsym, *s) == 0)
-                               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;
@@ -887,6 +867,11 @@ static void warn_sec_mismatch(const char *modname, const char *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(%s+0x%llx): Section mismatch: reference to %s:%s "
                     "(between '%s' and '%s')\n",