diff mbox series

[5/8] scripts/kallsyms: move compiler-generated symbol patterns to mksysmap

Message ID 20230308115243.82592-5-masahiroy@kernel.org (mailing list archive)
State New, archived
Headers show
Series [1/8] scripts/kallsyms: remove redundant code for omitting U and N | expand

Commit Message

Masahiro Yamada March 8, 2023, 11:52 a.m. UTC
scripts/kallsyms.c maintains compiler-generated symbols, but we end up
with something similar in scripts/mksysmap to avoid the "Inconsistent
kallsyms data" error. For example, commit c17a2538704f ("mksysmap: Fix
the mismatch of 'L0' symbols in System.map").

They were separately maintained prior to commit 94ff2f63d6a3 ("kbuild:
reuse mksysmap output for kallsyms").

Now that scripts/kallsyms.c parses the output of scripts/mksysmap,
it makes more sense to collect all the ignored patterns to mksysmap.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/kallsyms.c | 59 ----------------------------------------------
 scripts/mksysmap   | 43 +++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 59 deletions(-)

Comments

Nick Desaulniers April 7, 2023, 8:16 p.m. UTC | #1
On Wed, Mar 8, 2023 at 3:53 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> scripts/kallsyms.c maintains compiler-generated symbols, but we end up
> with something similar in scripts/mksysmap to avoid the "Inconsistent
> kallsyms data" error. For example, commit c17a2538704f ("mksysmap: Fix
> the mismatch of 'L0' symbols in System.map").
>
> They were separately maintained prior to commit 94ff2f63d6a3 ("kbuild:
> reuse mksysmap output for kallsyms").
>
> Now that scripts/kallsyms.c parses the output of scripts/mksysmap,
> it makes more sense to collect all the ignored patterns to mksysmap.

Cool, thanks for the patch!
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
>
>  scripts/kallsyms.c | 59 ----------------------------------------------
>  scripts/mksysmap   | 43 +++++++++++++++++++++++++++++++++
>  2 files changed, 43 insertions(+), 59 deletions(-)
>
> diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c
> index e572fda6fe42..97d514c0fc8f 100644
> --- a/scripts/kallsyms.c
> +++ b/scripts/kallsyms.c
> @@ -102,65 +102,6 @@ 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[] = {
> -               "_SDA_BASE_",           /* ppc */
> -               "_SDA2_BASE_",          /* ppc */
> -               NULL
> -       };
> -
> -       /* Symbol names that begin with the following are ignored.*/
> -       static const char * const ignored_prefixes[] = {
> -               "__efistub_",           /* arm64 EFI stub namespace */
> -               "__kvm_nvhe_$",         /* arm64 local symbols in non-VHE KVM namespace */
> -               "__kvm_nvhe_.L",        /* arm64 local symbols in non-VHE KVM namespace */
> -               "__AArch64ADRPThunk_",  /* arm64 lld */
> -               "__ARMV5PILongThunk_",  /* arm lld */
> -               "__ARMV7PILongThunk_",
> -               "__ThumbV7PILongThunk_",
> -               "__LA25Thunk_",         /* mips lld */
> -               "__microLA25Thunk_",
> -               "__kcfi_typeid_",       /* CFI type identifiers */
> -               NULL
> -       };
> -
> -       /* Symbol names that end with the following are ignored.*/
> -       static const char * const ignored_suffixes[] = {
> -               "_from_arm",            /* arm */
> -               "_from_thumb",          /* arm */
> -               "_veneer",              /* arm */
> -               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;
> -
> -       for (p = ignored_symbols; *p; p++)
> -               if (!strcmp(name, *p))
> -                       return true;
> -
> -       for (p = ignored_prefixes; *p; p++)
> -               if (!strncmp(name, *p, strlen(*p)))
> -                       return true;
> -
> -       for (p = ignored_suffixes; *p; p++) {
> -               int l = strlen(name) - strlen(*p);
> -
> -               if (l >= 0 && !strcmp(name + l, *p))
> -                       return true;
> -       }
> -
> -       for (p = ignored_matches; *p; p++) {
> -               if (strstr(name, *p))
> -                       return true;
> -       }
> -
>         if (type == 'u' || type == 'n')
>                 return true;
>
> diff --git a/scripts/mksysmap b/scripts/mksysmap
> index 1efd61ee0bac..d8ad6ff69320 100755
> --- a/scripts/mksysmap
> +++ b/scripts/mksysmap
> @@ -36,6 +36,28 @@ ${NM} -n ${1} | sed >${2} -e "
>  # local labels, .LBB, .Ltmpxxx, .L__unnamed_xx, .LASANPC, etc.
>  / \.L/d
>
> +# arm64 EFI stub namespace
> +/ __efistub_/d
> +
> +# arm64 local symbols in non-VHE KVM namespace
> +/ __kvm_nvhe_\$/d
> +/ __kvm_nvhe_\.L/d
> +
> +# arm64 lld
> +/ __AArch64ADRPThunk_/d
> +
> +# arm lld
> +/ __ARMV5PILongThunk_/d
> +/ __ARMV7PILongThunk_/d
> +/ __ThumbV7PILongThunk_/d
> +
> +# mips lld
> +/ __LA25Thunk_/d
> +/ __microLA25Thunk_/d
> +
> +# CFI type identifiers
> +/ __kcfi_typeid_/d
> +
>  # CRC from modversions
>  / __crc_/d
>
> @@ -45,6 +67,15 @@ ${NM} -n ${1} | sed >${2} -e "
>  # EXPORT_SYMBOL (namespace)
>  / __kstrtabns_/d
>
> +# ---------------------------------------------------------------------------
> +# Ignored suffixes
> +#  (do not forget '$' after each pattern)
> +
> +# arm
> +/_from_arm$/d
> +/_from_thumb$/d
> +/_veneer$/d
> +
>  # ---------------------------------------------------------------------------
>  # Ignored symbols (exact match)
>  #  (do not forget a space before and '$' after each pattern)
> @@ -52,6 +83,18 @@ ${NM} -n ${1} | sed >${2} -e "
>  # for LoongArch?
>  / L0$/d
>
> +# ppc
> +/ _SDA_BASE_$/d
> +/ _SDA2_BASE_$/d
> +
> +# ---------------------------------------------------------------------------
> +# Ignored patterns
> +#  (symbols that contain the pattern are ignored)
> +
> +# ppc stub
> +/\.long_branch\./d
> +/\.plt_branch\./d
> +
>  # ---------------------------------------------------------------------------
>  # Ignored kallsyms symbols
>  #
> --
> 2.34.1
>
diff mbox series

Patch

diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c
index e572fda6fe42..97d514c0fc8f 100644
--- a/scripts/kallsyms.c
+++ b/scripts/kallsyms.c
@@ -102,65 +102,6 @@  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[] = {
-		"_SDA_BASE_",		/* ppc */
-		"_SDA2_BASE_",		/* ppc */
-		NULL
-	};
-
-	/* Symbol names that begin with the following are ignored.*/
-	static const char * const ignored_prefixes[] = {
-		"__efistub_",		/* arm64 EFI stub namespace */
-		"__kvm_nvhe_$",		/* arm64 local symbols in non-VHE KVM namespace */
-		"__kvm_nvhe_.L",	/* arm64 local symbols in non-VHE KVM namespace */
-		"__AArch64ADRPThunk_",	/* arm64 lld */
-		"__ARMV5PILongThunk_",	/* arm lld */
-		"__ARMV7PILongThunk_",
-		"__ThumbV7PILongThunk_",
-		"__LA25Thunk_",		/* mips lld */
-		"__microLA25Thunk_",
-		"__kcfi_typeid_",	/* CFI type identifiers */
-		NULL
-	};
-
-	/* Symbol names that end with the following are ignored.*/
-	static const char * const ignored_suffixes[] = {
-		"_from_arm",		/* arm */
-		"_from_thumb",		/* arm */
-		"_veneer",		/* arm */
-		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;
-
-	for (p = ignored_symbols; *p; p++)
-		if (!strcmp(name, *p))
-			return true;
-
-	for (p = ignored_prefixes; *p; p++)
-		if (!strncmp(name, *p, strlen(*p)))
-			return true;
-
-	for (p = ignored_suffixes; *p; p++) {
-		int l = strlen(name) - strlen(*p);
-
-		if (l >= 0 && !strcmp(name + l, *p))
-			return true;
-	}
-
-	for (p = ignored_matches; *p; p++) {
-		if (strstr(name, *p))
-			return true;
-	}
-
 	if (type == 'u' || type == 'n')
 		return true;
 
diff --git a/scripts/mksysmap b/scripts/mksysmap
index 1efd61ee0bac..d8ad6ff69320 100755
--- a/scripts/mksysmap
+++ b/scripts/mksysmap
@@ -36,6 +36,28 @@  ${NM} -n ${1} | sed >${2} -e "
 # local labels, .LBB, .Ltmpxxx, .L__unnamed_xx, .LASANPC, etc.
 / \.L/d
 
+# arm64 EFI stub namespace
+/ __efistub_/d
+
+# arm64 local symbols in non-VHE KVM namespace
+/ __kvm_nvhe_\$/d
+/ __kvm_nvhe_\.L/d
+
+# arm64 lld
+/ __AArch64ADRPThunk_/d
+
+# arm lld
+/ __ARMV5PILongThunk_/d
+/ __ARMV7PILongThunk_/d
+/ __ThumbV7PILongThunk_/d
+
+# mips lld
+/ __LA25Thunk_/d
+/ __microLA25Thunk_/d
+
+# CFI type identifiers
+/ __kcfi_typeid_/d
+
 # CRC from modversions
 / __crc_/d
 
@@ -45,6 +67,15 @@  ${NM} -n ${1} | sed >${2} -e "
 # EXPORT_SYMBOL (namespace)
 / __kstrtabns_/d
 
+# ---------------------------------------------------------------------------
+# Ignored suffixes
+#  (do not forget '$' after each pattern)
+
+# arm
+/_from_arm$/d
+/_from_thumb$/d
+/_veneer$/d
+
 # ---------------------------------------------------------------------------
 # Ignored symbols (exact match)
 #  (do not forget a space before and '$' after each pattern)
@@ -52,6 +83,18 @@  ${NM} -n ${1} | sed >${2} -e "
 # for LoongArch?
 / L0$/d
 
+# ppc
+/ _SDA_BASE_$/d
+/ _SDA2_BASE_$/d
+
+# ---------------------------------------------------------------------------
+# Ignored patterns
+#  (symbols that contain the pattern are ignored)
+
+# ppc stub
+/\.long_branch\./d
+/\.plt_branch\./d
+
 # ---------------------------------------------------------------------------
 # Ignored kallsyms symbols
 #