module: Move is_arm_mapping_symbol() to module_symbol.h
authorTiezhu Yang <yangtiezhu@loongson.cn>
Fri, 31 Mar 2023 09:15:52 +0000 (17:15 +0800)
committerLuis Chamberlain <mcgrof@kernel.org>
Fri, 14 Apr 2023 00:15:49 +0000 (17:15 -0700)
In order to avoid duplicated code, move is_arm_mapping_symbol() to
include/linux/module_symbol.h, then remove is_arm_mapping_symbol()
in the other places.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
include/linux/module_symbol.h [new file with mode: 0644]
kernel/module/kallsyms.c
scripts/mod/modpost.c

diff --git a/include/linux/module_symbol.h b/include/linux/module_symbol.h
new file mode 100644 (file)
index 0000000..9fa4173
--- /dev/null
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef _LINUX_MODULE_SYMBOL_H
+#define _LINUX_MODULE_SYMBOL_H
+
+/* This ignores the intensely annoying "mapping symbols" found in ELF files. */
+static inline int is_arm_mapping_symbol(const char *str)
+{
+       if (str[0] == '.' && str[1] == 'L')
+               return true;
+       return str[0] == '$' &&
+              (str[1] == 'a' || str[1] == 'd' || str[1] == 't' || str[1] == 'x')
+              && (str[2] == '\0' || str[2] == '.');
+}
+
+#endif /* _LINUX_MODULE_SYMBOL_H */
index a9045fe55bcd9f657da94e6b8db20e3fd3df456a..5de3207f18afbb83e1abab297debd543eb762311 100644 (file)
@@ -6,6 +6,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/module_symbol.h>
 #include <linux/kallsyms.h>
 #include <linux/buildid.h>
 #include <linux/bsearch.h>
@@ -243,19 +244,6 @@ void init_build_id(struct module *mod, const struct load_info *info)
 }
 #endif
 
-/*
- * This ignores the intensely annoying "mapping symbols" found
- * in ARM ELF files: $a, $t and $d.
- */
-static inline int is_arm_mapping_symbol(const char *str)
-{
-       if (str[0] == '.' && str[1] == 'L')
-               return true;
-       return str[0] == '$' &&
-              (str[1] == 'a' || str[1] == 'd' || str[1] == 't' || str[1] == 'x')
-              && (str[2] == '\0' || str[2] == '.');
-}
-
 static const char *kallsyms_symbol_name(struct mod_kallsyms *kallsyms, unsigned int symnum)
 {
        return kallsyms->strtab + kallsyms->symtab[symnum].st_name;
index 79a27cc5f0b1d99c277e20d3f7cb2635d7a34bf3..7241db81ffde6250325fca420f7b805f14c2a706 100644 (file)
@@ -22,6 +22,7 @@
 #include <errno.h>
 #include "modpost.h"
 #include "../../include/linux/license.h"
+#include "../../include/linux/module_symbol.h"
 
 /* Are we using CONFIG_MODVERSIONS? */
 static bool modversions;
@@ -1112,15 +1113,6 @@ static int secref_whitelist(const struct sectioncheck *mismatch,
        return 1;
 }
 
-static inline int is_arm_mapping_symbol(const char *str)
-{
-       if (str[0] == '.' && str[1] == 'L')
-               return true;
-       return str[0] == '$' &&
-              (str[1] == 'a' || str[1] == 'd' || str[1] == 't' || str[1] == 'x')
-              && (str[2] == '\0' || str[2] == '.');
-}
-
 /*
  * If there's no name there, ignore it; likewise, ignore it if it's
  * one of the magic symbols emitted used by current ARM tools.