diff options
author | Brian Gerst <bgerst@quark.didntduck.org> | 2004-09-07 17:53:23 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-09-07 17:53:23 -0700 |
commit | 2390fd2b793dd6bcde7f7c6738ba2e6ba51a36d9 (patch) | |
tree | 36d2c680363ba00ddcf857d1d228a546f52a5651 /scripts | |
parent | 2bb56b4e432b8192633bf98b9d6bbb68554439d0 (diff) | |
download | history-2390fd2b793dd6bcde7f7c6738ba2e6ba51a36d9.tar.gz |
[PATCH] Remove in-kernel init_module/cleanup_module stubs
This patch removes the default stubs for init_module and cleanup_module,
and checks for NULL instead. It changes modpost to only create references
to those functions if they actually exist.
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/mod/modpost.c | 29 | ||||
-rw-r--r-- | scripts/mod/modpost.h | 2 |
2 files changed, 15 insertions, 16 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 65072d76a101e3..2a174e504c22bb 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -376,6 +376,10 @@ handle_modversions(struct module *mod, struct elf_info *info, add_exported_symbol(symname + strlen(KSYMTAB_PFX), mod, NULL); } + if (strcmp(symname, MODULE_SYMBOL_PREFIX "init_module") == 0) + mod->has_init = 1; + if (strcmp(symname, MODULE_SYMBOL_PREFIX "cleanup_module") == 0) + mod->has_cleanup = 1; break; } } @@ -410,9 +414,6 @@ read_symbols(char *modname) if (is_vmlinux(modname)) { unsigned int fake_crc = 0; have_vmlinux = 1; - /* May not have this if !CONFIG_MODULE_UNLOAD: fake it. - If it appears, we'll get the real CRC. */ - add_exported_symbol("cleanup_module", mod, &fake_crc); add_exported_symbol("struct_module", mod, &fake_crc); mod->skip = 1; } @@ -431,14 +432,8 @@ read_symbols(char *modname) * never passed as an argument to an exported function, so * the automatic versioning doesn't pick it up, but it's really * important anyhow */ - if (modversions) { + if (modversions) mod->unres = alloc_symbol("struct_module", mod->unres); - - /* Always version init_module and cleanup_module, in - * case module doesn't have its own. */ - mod->unres = alloc_symbol("init_module", mod->unres); - mod->unres = alloc_symbol("cleanup_module", mod->unres); - } } #define SZ 500 @@ -479,7 +474,7 @@ buf_write(struct buffer *buf, const char *s, int len) /* Header for the generated file */ void -add_header(struct buffer *b) +add_header(struct buffer *b, struct module *mod) { buf_printf(b, "#include <linux/module.h>\n"); buf_printf(b, "#include <linux/vermagic.h>\n"); @@ -491,10 +486,12 @@ add_header(struct buffer *b) buf_printf(b, "struct module __this_module\n"); buf_printf(b, "__attribute__((section(\".gnu.linkonce.this_module\"))) = {\n"); buf_printf(b, " .name = __stringify(KBUILD_MODNAME),\n"); - buf_printf(b, " .init = init_module,\n"); - buf_printf(b, "#ifdef CONFIG_MODULE_UNLOAD\n"); - buf_printf(b, " .exit = cleanup_module,\n"); - buf_printf(b, "#endif\n"); + if (mod->has_init) + buf_printf(b, " .init = init_module,\n"); + if (mod->has_cleanup) + buf_printf(b, "#ifdef CONFIG_MODULE_UNLOAD\n" + " .exit = cleanup_module,\n" + "#endif\n"); buf_printf(b, "};\n"); } @@ -723,7 +720,7 @@ main(int argc, char **argv) buf.pos = 0; - add_header(&buf); + add_header(&buf, mod); add_versions(&buf, mod); add_depends(&buf, mod, modules); add_moddevtable(&buf, mod); diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index ddb013d9fd9872..4871343e192a51 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -74,6 +74,8 @@ struct module { struct symbol *unres; int seen; int skip; + int has_init; + int has_cleanup; struct buffer dev_table_buf; }; |