diff options
| author | Rusty Russell <rusty@rustcorp.com.au> | 2002-12-01 02:15:26 -0800 |
|---|---|---|
| committer | James Bottomley <jejb@raven.il.steeleye.com> | 2002-12-01 02:15:26 -0800 |
| commit | c99f5cea7036f066e9cdefade80a85f0c4f13d93 (patch) | |
| tree | 9f22f0cd5b16e8da9930261325903546351c0595 /include/linux | |
| parent | 1504317a0d85ff9cbf729d9d4ff3886aacc7a695 (diff) | |
[PATCH] module names fix
By Kai Germaschewski:
"Well, I have another solution, which doesn't need additional Makefile
magic or anything.
I just put the module name into each .o file where <linux/module.h> is
included. Putting it into the section .gnu.linkonce.modname has the effect
that even for multi-part modules, we only end up with one copy of the
name.
Caveat: I'm using the preprocessor macro KBUILD_MODNAME to know what to
put into .gnu.linkonce.modname. The following used to happen:
(drivers/isdn/eicon/Makefile)
divas-objs := common.o Divas_mod.o ...
eicon-objs := common.o eicon_mod.o ...
Divas_mod.o is compiled with -DKBUILD_MODNAME=divas
eicon_mod.o is compiled with -DKBUILD_MODNAME=eicon
common.o is compiled with -DKBUILD_MODNAME=divas_eicon
So in the case above, both divas.o and eicon.o would end up with
a .gnu.linkonce.modname section containing "divas_eicon"
My fix to this is to not define KBUILD_MODNAME when compiling an object
whilch will be linked into more than one module - so common.o gets no
.gnu.linkonce.modname section at all. Works fine here.
Now, doing this I remove one of the reasons why we would need modules
linked as '.ko' ;), but it seems much cleaner than generating a temporary
file, using objcopy etc."
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/init.h | 16 | ||||
| -rw-r--r-- | include/linux/module.h | 12 |
2 files changed, 6 insertions, 22 deletions
diff --git a/include/linux/init.h b/include/linux/init.h index 52db706d0ed0..e2bf29a635bf 100644 --- a/include/linux/init.h +++ b/include/linux/init.h @@ -125,14 +125,6 @@ extern struct kernel_param __setup_start, __setup_end; */ #define module_exit(x) __exitcall(x); -/** - * no_module_init - code needs no initialization. - * - * The equivalent of declaring an empty init function which returns 0. - * Every module must have exactly one module_init() or no_module_init - * invocation. */ -#define no_module_init - #else /* MODULE */ /* Don't use these in modules, but some people do... */ @@ -144,11 +136,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 +144,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) \ diff --git a/include/linux/module.h b/include/linux/module.h index 7729a4e10fb9..0362a206ccd9 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -46,6 +46,11 @@ struct kernel_symbol #ifdef MODULE +#ifdef KBUILD_MODNAME +static const char __module_name[MODULE_NAME_LEN] __attribute__((section(".gnu.linkonce.modname"))) = \ + __stringify(KBUILD_MODNAME); +#endif + /* For replacement modutils, use an alias not a pointer. */ #define MODULE_GENERIC_TABLE(gtype,name) \ static const unsigned long __module_##gtype##_size \ @@ -315,12 +320,7 @@ extern int module_dummy_usage; /* Old-style "I'll just call it init_module and it'll be run at insert". Use module_init(myroutine) instead. */ #ifdef MODULE -/* 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 init_module(voidarg) __initfn(void) #define cleanup_module(voidarg) __exitfn(void) #endif |
