From b3e8b7081800ec0452e432d01ae55bc327da4b5f Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Fri, 14 Feb 2003 08:31:02 -0600 Subject: kbuild: Add dependency info to modules During postprocessing, we get the information which modules we depend on (i.e. which modules export symbols we need to import) for free, so we record it in .modinfo. This may allow us to remove the "depmod" program at a later time, though for now it remains working as usual. --- scripts/modpost.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'scripts') diff --git a/scripts/modpost.c b/scripts/modpost.c index 78953ae06c4f..fb8a54414b87 100644 --- a/scripts/modpost.c +++ b/scripts/modpost.c @@ -75,6 +75,7 @@ struct module { struct module *next; const char *name; struct symbol *unres; + int seen; }; static struct module *modules; @@ -317,6 +318,39 @@ add_versions(struct buffer *b, struct module *mod) buf_printf(b, "};\n"); } +void +add_depends(struct buffer *b, struct module *mod, struct module *modules) +{ + struct symbol *s; + struct module *m; + int first = 1; + + for (m = modules; m; m = m->next) { + if (strcmp(m->name, "vmlinux") == 0) + m->seen = 1; + else + m->seen = 0; + } + + buf_printf(b, "\n"); + buf_printf(b, "static const char __module_depends[]\n"); + buf_printf(b, "__attribute__((section(\".modinfo\"))) =\n"); + buf_printf(b, "\"depends="); + for (s = mod->unres; s; s = s->next) { + if (!s->module) + continue; + + if (s->module->seen) + continue; + + s->module->seen = 1; + buf_printf(b, "%s%s", first ? "" : ",", + strrchr(s->module->name, '/') + 1); + first = 0; + } + buf_printf(b, "\";\n"); +} + void write_if_changed(struct buffer *b, const char *fname) { @@ -387,6 +421,7 @@ main(int argc, char **argv) add_header(&buf); add_versions(&buf, mod); + add_depends(&buf, mod, modules); sprintf(fname, "%s.ver.c", mod->name); write_if_changed(&buf, fname); -- cgit v1.2.3