summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorMasahiro Yamada <masahiroy@kernel.org>2022-05-12 01:45:04 +0900
committerMasahiro Yamada <masahiroy@kernel.org>2022-05-24 00:52:12 +0900
commit69c4cc99bbcbf3ef2e1901b569954e9226180840 (patch)
treea01c7c41bb04f6c7ea0a775ced598dac866faf9d /scripts
parent2a66c3124afd2782015d160f8bad693488ce68de (diff)
downloadlinux-69c4cc99bbcbf3ef2e1901b569954e9226180840.tar.gz
linux-69c4cc99bbcbf3ef2e1901b569954e9226180840.tar.bz2
linux-69c4cc99bbcbf3ef2e1901b569954e9226180840.zip
modpost: add sym_find_with_module() helper
find_symbol() returns the first symbol found in the hash table. This table is global, so it may return a symbol from an unexpected module. There is a case where we want to search for a symbol with a given name in a specified module. Add sym_find_with_module(), which receives the module pointer as the second argument. It is equivalent to find_module() if NULL is passed as the module pointer. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nicolas Schier <nicolas@fjasle.eu> Tested-by: Nathan Chancellor <nathan@kernel.org> Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # LLVM-14 (x86-64)
Diffstat (limited to 'scripts')
-rw-r--r--scripts/mod/modpost.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index a78b75f0eeb0..f36f02d4b79b 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -266,7 +266,7 @@ static void sym_add_unresolved(const char *name, struct module *mod, bool weak)
list_add_tail(&sym->list, &mod->unresolved_symbols);
}
-static struct symbol *find_symbol(const char *name)
+static struct symbol *sym_find_with_module(const char *name, struct module *mod)
{
struct symbol *s;
@@ -275,12 +275,17 @@ static struct symbol *find_symbol(const char *name)
name++;
for (s = symbolhash[tdb_hash(name) % SYMBOL_HASH_SIZE]; s; s = s->next) {
- if (strcmp(s->name, name) == 0)
+ if (strcmp(s->name, name) == 0 && (!mod || s->module == mod))
return s;
}
return NULL;
}
+static struct symbol *find_symbol(const char *name)
+{
+ return sym_find_with_module(name, NULL);
+}
+
struct namespace_list {
struct list_head list;
char namespace[];