Commit 7ee168c0 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] Move __this_module to modpost

From: Brian Gerst <bgerst@didntduck.org>

Move the __this_module structure to the modpost code where it really
belongs.
parent a05fc485
...@@ -70,6 +70,7 @@ static const char __module_cat(name,__LINE__)[] \ ...@@ -70,6 +70,7 @@ static const char __module_cat(name,__LINE__)[] \
extern const struct gtype##_id __mod_##gtype##_table \ extern const struct gtype##_id __mod_##gtype##_table \
__attribute__ ((unused, alias(__stringify(name)))) __attribute__ ((unused, alias(__stringify(name))))
extern struct module __this_module;
#define THIS_MODULE (&__this_module) #define THIS_MODULE (&__this_module)
#else /* !MODULE */ #else /* !MODULE */
...@@ -481,21 +482,6 @@ static inline int unregister_module_notifier(struct notifier_block * nb) ...@@ -481,21 +482,6 @@ static inline int unregister_module_notifier(struct notifier_block * nb)
#endif /* CONFIG_MODULES */ #endif /* CONFIG_MODULES */
#ifdef MODULE
extern struct module __this_module;
#ifdef KBUILD_MODNAME
/* We make the linker do some of the work. */
struct module __this_module
__attribute__((section(".gnu.linkonce.this_module"))) = {
.name = __stringify(KBUILD_MODNAME),
.init = init_module,
#ifdef CONFIG_MODULE_UNLOAD
.exit = cleanup_module,
#endif
};
#endif /* KBUILD_MODNAME */
#endif /* MODULE */
#define symbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x) #define symbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x)
/* BELOW HERE ALL THESE ARE OBSOLETE AND WILL VANISH */ /* BELOW HERE ALL THESE ARE OBSOLETE AND WILL VANISH */
......
...@@ -35,6 +35,8 @@ targets += $(modules) ...@@ -35,6 +35,8 @@ targets += $(modules)
# Compile version info for unresolved symbols # Compile version info for unresolved symbols
modname = $(*F)
quiet_cmd_cc_o_c = CC $@ quiet_cmd_cc_o_c = CC $@
cmd_cc_o_c = $(CC) $(c_flags) $(CFLAGS_MODULE) \ cmd_cc_o_c = $(CC) $(c_flags) $(CFLAGS_MODULE) \
-c -o $@ $< -c -o $@ $<
......
...@@ -343,6 +343,9 @@ handle_modversions(struct module *mod, struct elf_info *info, ...@@ -343,6 +343,9 @@ handle_modversions(struct module *mod, struct elf_info *info,
/* ignore global offset table */ /* ignore global offset table */
if (strcmp(symname, "_GLOBAL_OFFSET_TABLE_") == 0) if (strcmp(symname, "_GLOBAL_OFFSET_TABLE_") == 0)
break; break;
/* ignore __this_module, it will be resolved shortly */
if (strcmp(symname, MODULE_SYMBOL_PREFIX "__this_module") == 0)
break;
#ifdef STT_REGISTER #ifdef STT_REGISTER
if (info->hdr->e_machine == EM_SPARC || if (info->hdr->e_machine == EM_SPARC ||
info->hdr->e_machine == EM_SPARCV9) { info->hdr->e_machine == EM_SPARCV9) {
...@@ -468,6 +471,15 @@ add_header(struct buffer *b) ...@@ -468,6 +471,15 @@ add_header(struct buffer *b)
buf_printf(b, "#include <linux/compiler.h>\n"); buf_printf(b, "#include <linux/compiler.h>\n");
buf_printf(b, "\n"); buf_printf(b, "\n");
buf_printf(b, "MODULE_INFO(vermagic, VERMAGIC_STRING);\n"); buf_printf(b, "MODULE_INFO(vermagic, VERMAGIC_STRING);\n");
buf_printf(b, "\n");
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");
buf_printf(b, "};\n");
} }
/* Record CRCs for unresolved symbols */ /* Record CRCs for unresolved symbols */
......
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