[RFC PATCH 2/6] module: add module ELF section with module_init() pointer

From: Andreas Robinson
Date: Sun Feb 15 2009 - 13:21:24 EST


The linker script will append this section to the end of the list
of initcalls so that init/main.c:do_initcalls() can find it.
---
include/asm-generic/vmlinux.lds.h | 3 ++-
include/linux/init.h | 11 ++++++++++-
2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index c61fab1..d3c0787 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -428,7 +428,8 @@
*(.initcall6.init) \
*(.initcall6s.init) \
*(.initcall7.init) \
- *(.initcall7s.init)
+ *(.initcall7s.init) \
+ *(.mod_initcall.init)

#define PERCPU(align) \
. = ALIGN(align); \
diff --git a/include/linux/init.h b/include/linux/init.h
index 68cb026..62b854f 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -284,11 +284,20 @@ void __init parse_early_param(void);

#define security_initcall(fn) module_init(fn)

+#ifdef CONFIG_MODULE_STATIC
+#define module_initcall(fn) \
+ static initcall_t __initcall_##fn \
+ __used __section(.mod_initcall.init) = fn
+#else
+#define module_initcall(fn)
+#endif
+
/* Each module must use one module_init(). */
#define module_init(initfn) \
static inline initcall_t __inittest(void) \
{ return initfn; } \
- int init_module(void) __attribute__((alias(#initfn)));
+ int init_module(void) __attribute__((alias(#initfn))); \
+ module_initcall(initfn);

/* This is only required if you want to be unloadable. */
#define module_exit(exitfn) \
--
1.5.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/