scripts/kallsyms: skip ppc compiler stub *.long_branch.* / *.plt_branch.*
authorMasahiro Yamada <masahiroy@kernel.org>
Tue, 22 Sep 2020 17:48:56 +0000 (02:48 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Thu, 24 Sep 2020 15:41:54 +0000 (00:41 +0900)
PowerPC allmodconfig often fails to build as follows:

    LD      .tmp_vmlinux.kallsyms1
    KSYM    .tmp_vmlinux.kallsyms1.o
    LD      .tmp_vmlinux.kallsyms2
    KSYM    .tmp_vmlinux.kallsyms2.o
    LD      .tmp_vmlinux.kallsyms3
    KSYM    .tmp_vmlinux.kallsyms3.o
    LD      vmlinux
    SORTTAB vmlinux
    SYSMAP  System.map
  Inconsistent kallsyms data
  Try make KALLSYMS_EXTRA_PASS=1 as a workaround
  make[2]: *** [../Makefile:1162: vmlinux] Error 1

Setting KALLSYMS_EXTRA_PASS=1 does not help.

This is caused by the compiler inserting stubs such as *.long_branch.*
and *.plt_branch.*

  $ powerpc-linux-nm -n .tmp_vmlinux.kallsyms2
   [ snip ]
  c00000000210c010 t 00000075.plt_branch.da9:19
  c00000000210c020 t 00000075.plt_branch.1677:5
  c00000000210c030 t 00000075.long_branch.memmove
  c00000000210c034 t 00000075.plt_branch.9e0:5
  c00000000210c044 t 00000075.plt_branch.free_initrd_mem
    ...

Actually, the problem mentioned in scripts/link-vmlinux.sh comments;
"In theory it's possible this results in even more stubs, but unlikely"
is happening here, and ends up with another kallsyms step required.

scripts/kallsyms.c already ignores various compiler stubs. Let's do
similar to make kallsysms for PowerPC always succeed in 2 steps.

Reported-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Tested-by: Guenter Roeck <linux@roeck-us.net>
scripts/kallsyms.c

index 0096cd9..7ecd2cc 100644 (file)
@@ -82,6 +82,7 @@ static char *sym_name(const struct sym_entry *s)
 
 static bool is_ignored_symbol(const char *name, char type)
 {
+       /* Symbol names that exactly match to the following are ignored.*/
        static const char * const ignored_symbols[] = {
                /*
                 * Symbols which vary between passes. Passes 1 and 2 must have
@@ -104,6 +105,7 @@ static bool is_ignored_symbol(const char *name, char type)
                NULL
        };
 
+       /* Symbol names that begin with the following are ignored.*/
        static const char * const ignored_prefixes[] = {
                "$",                    /* local symbols for ARM, MIPS, etc. */
                ".LASANPC",             /* s390 kasan local symbols */
@@ -113,6 +115,7 @@ static bool is_ignored_symbol(const char *name, char type)
                NULL
        };
 
+       /* Symbol names that end with the following are ignored.*/
        static const char * const ignored_suffixes[] = {
                "_from_arm",            /* arm */
                "_from_thumb",          /* arm */
@@ -120,9 +123,15 @@ static bool is_ignored_symbol(const char *name, char type)
                NULL
        };
 
+       /* Symbol names that contain the following are ignored.*/
+       static const char * const ignored_matches[] = {
+               ".long_branch.",        /* ppc stub */
+               ".plt_branch.",         /* ppc stub */
+               NULL
+       };
+
        const char * const *p;
 
-       /* Exclude symbols which vary between passes. */
        for (p = ignored_symbols; *p; p++)
                if (!strcmp(name, *p))
                        return true;
@@ -138,6 +147,11 @@ static bool is_ignored_symbol(const char *name, char type)
                        return true;
        }
 
+       for (p = ignored_matches; *p; p++) {
+               if (strstr(name, *p))
+                       return true;
+       }
+
        if (type == 'U' || type == 'u')
                return true;
        /* exclude debugging symbols */