aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Robinson <andr345@gmail.com>2009-05-09 12:44:30 +0200
committerAndreas Robinson <andr345@gmail.com>2009-05-12 12:55:40 +0200
commita29305a4a8218b5c2ef2fb88538812674c566723 (patch)
tree3d901132325954347a8e1b792cb33c6fb1cc9ffd
parent2f776f6b60ab2b2d8b8cbb061821113dbefe4aae (diff)
downloadmodule-init-tools-a29305a4a8218b5c2ef2fb88538812674c566723.tar.gz
depmod: rewrite load_symbols() to not use callback
load_symbols() in moduleops no longer has to call add_symbol() in depmod. Data is now returned in a string table. Signed-off-by: Andreas Robinson <andr345@gmail.com>
-rw-r--r--depmod.c9
-rw-r--r--depmod.h1
-rw-r--r--moduleops.h2
-rw-r--r--moduleops_core.c21
4 files changed, 22 insertions, 11 deletions
diff --git a/depmod.c b/depmod.c
index 3544b89..da4ff44 100644
--- a/depmod.c
+++ b/depmod.c
@@ -670,9 +670,16 @@ static struct module *sort_modules(const char *dirname, struct module *list)
static struct module *parse_modules(struct module *list)
{
struct module *i;
+ struct string_table *syms;
+ int j;
for (i = list; i; i = i->next) {
- i->ops->load_symbols(i);
+ syms = i->ops->load_symbols(i);
+ if (syms) {
+ for (j = 0; j < syms->cnt; j++)
+ add_symbol(syms->str[j], i);
+ free(syms);
+ }
i->ops->fetch_tables(i);
}
diff --git a/depmod.h b/depmod.h
index 32cab3d..4d92c98 100644
--- a/depmod.h
+++ b/depmod.h
@@ -5,7 +5,6 @@
struct module;
/* Functions provided by depmod.c */
-void add_symbol(const char *name, struct module *owner);
struct module *find_symbol(const char *name, const char *modname, int weak);
void add_dep(struct module *mod, struct module *depends_on);
diff --git a/moduleops.h b/moduleops.h
index 67c60ca..55e2320 100644
--- a/moduleops.h
+++ b/moduleops.h
@@ -16,7 +16,7 @@ struct kernel_symbol64 {
struct module_ops
{
- void (*load_symbols)(struct module *module);
+ struct string_table *(*load_symbols)(struct module *module);
void (*calculate_deps)(struct module *module);
void (*fetch_tables)(struct module *module);
char *(*get_aliases)(struct module *module, unsigned long *size);
diff --git a/moduleops_core.c b/moduleops_core.c
index 0313e27..2454199 100644
--- a/moduleops_core.c
+++ b/moduleops_core.c
@@ -7,12 +7,15 @@ static void *PERBIT(load_section)(ElfPERBIT(Ehdr) *hdr,
return PERBIT(get_section)(hdr, 0, secname, secsize, conv);
}
-static void PERBIT(load_symbols)(struct module *module)
+static struct string_table *PERBIT(load_symbols)(struct module *module)
{
struct PERBIT(kernel_symbol) *ksyms;
+ struct string_table *symtbl;
char *ksymstrings;
unsigned long i, size;
+ symtbl = NULL;
+
/* New-style: strings are in this section. */
ksymstrings = PERBIT(load_section)(module->data, "__ksymtab_strings",
&size, module->conv);
@@ -22,8 +25,8 @@ static void PERBIT(load_symbols)(struct module *module)
/* Skip any zero padding. */
while (!ksymstrings[i])
if (++i >= size)
- return;
- add_symbol(ksymstrings+i, module);
+ return symtbl;
+ symtbl = NOFAIL(strtbl_add(ksymstrings + i, symtbl));
i += strlen(ksymstrings+i);
}
/* GPL symbols too */
@@ -34,22 +37,24 @@ static void PERBIT(load_symbols)(struct module *module)
/* Skip any zero padding. */
while (!ksymstrings[i])
if (++i >= size)
- return;
- add_symbol(ksymstrings+i, module);
+ return symtbl;
+ symtbl = NOFAIL(strtbl_add(ksymstrings + i, symtbl));
i += strlen(ksymstrings+i);
}
- return;
+ return symtbl;
}
/* Old-style. */
ksyms = PERBIT(load_section)(module->data, "__ksymtab", &size,
module->conv);
for (i = 0; i < size / sizeof(struct PERBIT(kernel_symbol)); i++)
- add_symbol(ksyms[i].name, module);
+ symtbl = NOFAIL(strtbl_add(ksyms[i].name, symtbl));
ksyms = PERBIT(load_section)(module->data, "__gpl_ksymtab", &size,
module->conv);
for (i = 0; i < size / sizeof(struct PERBIT(kernel_symbol)); i++)
- add_symbol(ksyms[i].name, module);
+ symtbl = NOFAIL(strtbl_add(ksyms[i].name, symtbl));
+
+ return symtbl;
}
static char *PERBIT(get_aliases)(struct module *module, unsigned long *size)