Commit b3e8b708 authored by Kai Germaschewski's avatar Kai Germaschewski

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.
parent 8ed38d8d
...@@ -75,6 +75,7 @@ struct module { ...@@ -75,6 +75,7 @@ struct module {
struct module *next; struct module *next;
const char *name; const char *name;
struct symbol *unres; struct symbol *unres;
int seen;
}; };
static struct module *modules; static struct module *modules;
...@@ -317,6 +318,39 @@ add_versions(struct buffer *b, struct module *mod) ...@@ -317,6 +318,39 @@ add_versions(struct buffer *b, struct module *mod)
buf_printf(b, "};\n"); 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 void
write_if_changed(struct buffer *b, const char *fname) write_if_changed(struct buffer *b, const char *fname)
{ {
...@@ -387,6 +421,7 @@ main(int argc, char **argv) ...@@ -387,6 +421,7 @@ main(int argc, char **argv)
add_header(&buf); add_header(&buf);
add_versions(&buf, mod); add_versions(&buf, mod);
add_depends(&buf, mod, modules);
sprintf(fname, "%s.ver.c", mod->name); sprintf(fname, "%s.ver.c", mod->name);
write_if_changed(&buf, fname); write_if_changed(&buf, fname);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment