From af3a25833a160e029441eaf5a93f7c8625544296 Mon Sep 17 00:00:00 2001 From: Heiner Kallweit Date: Wed, 1 Apr 2020 22:42:55 +0200 Subject: [PATCH 2/2] depmod: add depmod_load_harddeps Load explicitly declared hard dependency information from modules and add it to the symbol-derived dependencies. This will allow depmod-based tools to consider hard dependencies that are not code dependencies. Signed-off-by: Heiner Kallweit --- tools/depmod.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tools/depmod.c b/tools/depmod.c index 5419d4d..5771dc9 100644 --- a/tools/depmod.c +++ b/tools/depmod.c @@ -1522,6 +1522,41 @@ static struct symbol *depmod_symbol_find(const struct depmod *depmod, return hash_find(depmod->symbols, name); } +static void depmod_load_harddeps(struct depmod *depmod, struct mod *mod) +{ + + struct kmod_list *l; + + kmod_list_foreach(l, mod->info_list) { + const char *key = kmod_module_info_get_key(l); + const char *dep_name; + struct mod *dep; + char *value; + + if (!streq(key, "harddep")) + continue; + + value = strdup(kmod_module_info_get_value(l)); + if (value == NULL) + return; + + dep_name = strtok(value, " \t"); + + while (dep_name) { + dep = hash_find(depmod->modules_by_name, dep_name); + if (dep) + mod_add_dep_unique(mod, dep); + else + WRN("harddep: %s: unknown dependency %s\n", + mod->modname, dep_name); + + dep_name = strtok(NULL, " \t"); + } + + free(value); + } +} + static int depmod_load_modules(struct depmod *depmod) { struct mod **itr, **itr_end; @@ -1569,6 +1604,9 @@ static int depmod_load_module_dependencies(struct depmod *depmod, struct mod *mo struct kmod_list *l; DBG("do dependencies of %s\n", mod->path); + + depmod_load_harddeps(depmod, mod); + kmod_list_foreach(l, mod->dep_sym_list) { const char *name = kmod_module_dependency_symbol_get_symbol(l); uint64_t crc = kmod_module_dependency_symbol_get_crc(l); -- 2.26.0