Commit 1b24d807 authored by Kai Germaschewski's avatar Kai Germaschewski

kbuild: Always generate the module name automatically.

Rusty introduced no_module_init() to provide a way of putting
the module name into a special section. People didn't like that,
and it's doable without user visible changes ;)

I didn't keep any compatibility define for no_module_init (and removed
the current occurences) in order to make sure it doesn't spread anyway.
parent cebce9d8
......@@ -144,11 +144,6 @@ extern struct kernel_param __setup_start, __setup_end;
#define device_initcall(fn) module_init(fn)
#define late_initcall(fn) module_init(fn)
/* Each module knows its own name. */
#define __DEFINE_MODULE_NAME \
char __module_name[] __attribute__((section(".modulename"))) = \
__stringify(KBUILD_MODNAME)
/* These macros create a dummy inline: gcc 2.9x does not count alias
as usage, hence the `unused function' warning when __init functions
are declared static. We use the dummy __*_module_inline functions
......@@ -157,13 +152,10 @@ extern struct kernel_param __setup_start, __setup_end;
/* Each module must use one module_init(), or one no_module_init */
#define module_init(initfn) \
__DEFINE_MODULE_NAME; \
static inline initcall_t __inittest(void) \
{ return initfn; } \
int __initfn(void) __attribute__((alias(#initfn)));
#define no_module_init __DEFINE_MODULE_NAME
/* This is only required if you want to be unloadable. */
#define module_exit(exitfn) \
static inline exitcall_t __exittest(void) \
......
......@@ -40,6 +40,11 @@ struct kernel_symbol
#ifdef MODULE
#ifdef KBUILD_MODNAME
static const char __module_name[] __attribute__((section(".gnu.linkonce.modulename"))) = \
__stringify(KBUILD_MODNAME);
#endif
#define MODULE_GENERIC_TABLE(gtype,name) \
static const unsigned long __module_##gtype##_size \
__attribute__ ((unused)) = sizeof(struct gtype##_id); \
......@@ -309,8 +314,6 @@ extern int module_dummy_usage;
/* Used as "int init_module(void) { ... }". Get funky to insert modname. */
#define init_module(voidarg) \
__initfn(void); \
char __module_name[] __attribute__((section(".modulename"))) = \
__stringify(KBUILD_MODNAME); \
int __initfn(void)
#define cleanup_module(voidarg) __exitfn(void)
#endif
......
......@@ -864,7 +864,7 @@ static struct module *load_module(void *umod,
/* Internal symbols */
DEBUGP("Symbol table in section %u\n", i);
symindex = i;
} else if (strcmp(secstrings+sechdrs[i].sh_name, ".modulename")
} else if (strcmp(secstrings+sechdrs[i].sh_name, ".gnu.linkonce.modulename")
== 0) {
/* This module's name */
DEBUGP("Module name in section %u\n", i);
......
......@@ -19,5 +19,3 @@ EXPORT_SYMBOL(zlib_deflateReset);
EXPORT_SYMBOL(zlib_deflateCopy);
EXPORT_SYMBOL(zlib_deflateParams);
MODULE_LICENSE("GPL");
no_module_init;
......@@ -20,5 +20,3 @@ EXPORT_SYMBOL(zlib_inflateReset);
EXPORT_SYMBOL(zlib_inflateSyncPoint);
EXPORT_SYMBOL(zlib_inflateIncomp);
MODULE_LICENSE("GPL");
no_module_init;
......@@ -124,14 +124,14 @@ depfile = $(subst $(comma),_,$(@D)/.$(@F).d)
# than one module. In that case KBUILD_MODNAME will be set to foo_bar,
# where foo and bar are the name of the modules.
basename_flags = -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F)))
modname_flags = -DKBUILD_MODNAME=$(subst $(comma),_,$(subst -,_,$(modname)))
modname_flags = $(if $(filter 1,$(words $(modname))),-DKBUILD_MODNAME=$(subst $(comma),_,$(subst -,_,$(modname))))
c_flags = -Wp,-MD,$(depfile) $(CFLAGS) $(NOSTDINC_FLAGS) \
$(modkern_cflags) $(EXTRA_CFLAGS) $(CFLAGS_$(*F).o) \
$(basename_flags) $(modname_flags) $(export_flags)
# Finds the multi-part object the current object will be linked into
modname-multi = $(subst $(space),_,$(sort $(foreach m,$(multi-used),\
$(if $(filter $(subst $(obj)/,,$*.o), $($(m:.o=-objs)) $($(m:.o=-y))),$(m:.o=)))))
modname-multi = $(sort $(foreach m,$(multi-used),\
$(if $(filter $(subst $(obj)/,,$*.o), $($(m:.o=-objs)) $($(m:.o=-y))),$(m:.o=))))
# Shipped files
# ===========================================================================
......
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