Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
[powerpc.git] / scripts / mod / modpost.c
index c903a16..0a4051f 100644 (file)
@@ -640,7 +640,7 @@ static int data_section(const char *name)
  * 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
+ *   fromsec = .text.init.refok* | .data.init.refok*
  *
  * Pattern 1:
  *   If a module parameter is declared __initdata and permissions=0
@@ -658,8 +658,8 @@ static int data_section(const char *name)
  *   These functions may often be marked __init and we do not want to
  *   warn here.
  *   the pattern is identified by:
- *   tosec   = .init.text | .exit.text | .init.data
- *   fromsec = .data | .data.rel | .data.rel.*
+ *   tosec   = init or exit section
+ *   fromsec = data section
  *   atsym = *driver, *_template, *_sht, *_ops, *_probe, *probe_one, *_console, *_timer
  *
  * Pattern 3:
@@ -675,12 +675,18 @@ static int data_section(const char *name)
  *   This pattern is identified by
  *   refsymname = __init_begin, _sinittext, _einittext
  *
+ * Pattern 5:
+ *   Xtensa uses literal sections for constants that are accessed PC-relative.
+ *   Literal sections may safely reference their text sections.
+ *   (Note that the name for the literal section omits any trailing '.text')
+ *   tosec = <section>[.text]
+ *   fromsec = <section>.literal
  **/
 static int secref_whitelist(const char *modname, const char *tosec,
                            const char *fromsec, const char *atsym,
                            const char *refsymname)
 {
-       int f1 = 1, f2 = 1;
+       int len;
        const char **s;
        const char *pat2sym[] = {
                "driver",
@@ -702,36 +708,22 @@ static int secref_whitelist(const char *modname, const char *tosec,
        };
 
        /* Check for pattern 0 */
-       if ((strcmp(fromsec, ".text.init.refok") == 0) ||
-           (strcmp(fromsec, ".data.init.refok") == 0))
+       if ((strncmp(fromsec, ".text.init.refok", strlen(".text.init.refok")) == 0) ||
+           (strncmp(fromsec, ".exit.text.refok", strlen(".exit.text.refok")) == 0) ||
+           (strncmp(fromsec, ".data.init.refok", strlen(".data.init.refok")) == 0))
                return 1;
 
        /* Check for pattern 1 */
-       if (strcmp(tosec, ".init.data") != 0)
-               f1 = 0;
-       if (strncmp(fromsec, ".data", strlen(".data")) != 0)
-               f1 = 0;
-       if (strncmp(atsym, "__param", strlen("__param")) != 0)
-               f1 = 0;
-
-       if (f1)
-               return f1;
+       if ((strcmp(tosec, ".init.data") == 0) &&
+           (strncmp(fromsec, ".data", strlen(".data")) == 0) &&
+           (strncmp(atsym, "__param", strlen("__param")) == 0))
+               return 1;
 
        /* Check for pattern 2 */
-       if ((strcmp(tosec, ".init.text") != 0) &&
-           (strcmp(tosec, ".exit.text") != 0) &&
-           (strcmp(tosec, ".init.data") != 0))
-               f2 = 0;
-       if ((strcmp(fromsec, ".data") != 0) &&
-           (strcmp(fromsec, ".data.rel") != 0) &&
-           (strncmp(fromsec, ".data.rel.", strlen(".data.rel.")) != 0))
-               f2 = 0;
-
-       for (s = pat2sym; *s; s++)
-               if (strrcmp(atsym, *s) == 0)
-                       f1 = 1;
-       if (f1 && f2)
-               return 1;
+       if ((init_section(tosec) || exit_section(tosec)) && data_section(fromsec))
+               for (s = pat2sym; *s; s++)
+                       if (strrcmp(atsym, *s) == 0)
+                               return 1;
 
        /* Check for pattern 3 */
        if ((strcmp(fromsec, ".text.head") == 0) &&
@@ -744,6 +736,15 @@ static int secref_whitelist(const char *modname, const char *tosec,
                if (strcmp(refsymname, *s) == 0)
                        return 1;
 
+       /* Check for pattern 5 */
+       if (strrcmp(tosec, ".text") == 0)
+               len = strlen(tosec) - strlen(".text");
+       else
+               len = strlen(tosec);
+       if ((strncmp(tosec, fromsec, len) == 0) && (strlen(fromsec) > len) &&
+           (strcmp(fromsec + len, ".literal") == 0))
+               return 1;
+
        return 0;
 }
 
@@ -872,9 +873,9 @@ static void warn_sec_mismatch(const char *modname, const char *fromsec,
                refsymname = elf->strtab + refsym->st_name;
 
        /* check whitelist - we may ignore it */
-       if (before &&
-           secref_whitelist(modname, secname, fromsec,
-                            elf->strtab + before->st_name, refsymname))
+       if (secref_whitelist(modname, secname, fromsec,
+                            before ? elf->strtab + before->st_name : "",
+                            refsymname))
                return;
 
        if (before && after) {
@@ -1121,12 +1122,15 @@ static int initexit_section_ref_ok(const char *name)
                ".machvec",             /* ia64 + powerpc uses these */
                ".machine.desc",
                ".opd",                 /* See comment [OPD] */
+               "__dbe_table",
                ".parainstructions",
                ".pdr",
                ".plt",                 /* seen on ARCH=um build on x86_64. Harmless */
                ".smp_locks",
                ".stab",
                ".m68k_fixup",
+               ".xt.prop",             /* xtensa informational section */
+               ".xt.lit",              /* xtensa informational section */
                NULL
        };
        /* Start of section names */