* How use linux_kernel init_calls system in a modular application?
@ 2011-09-22 19:19 dboml
0 siblings, 0 replies; only message in thread
From: dboml @ 2011-09-22 19:19 UTC (permalink / raw)
To: gcc-help
Hello,
I develop a modular application like this:
main.c
main.h
modul1/module1.c
modul1/module1.h
modul2/module2.c
modul2/module2.h
modul3/module3.c
modul3/module3.h
so in main.c, i need to include all modules header like this:
#ifdef USE_MODULE_1
#include modul1/module1.H
#endif
#ifdef USE_MODULE_2
#include modul2/module2.H
#endif
#ifdef USE_MODULE_3
#include modul3/module3.H
#endif
int main () {
#ifdef USE_MODULE_1
module1_init();
#endif
#ifdef USE_MODULE_2
module2_init();
#endif
#ifdef USE_MODULE_3
module3_init();
#endif
}
So, i decide to use the system in linux KERNEL initCalls.
It is based on linker sections where are stor init modules functions.
in main.h:
typedef int (*initcall_t)(void);
#define MODULE_INIT(fn) static initcall_t __initcall_##fn __used
__attribute__((__section__(".initcall.init"))) = fn;
in modul1/module1.c :
MODULE_INIT(module1_init)
And then, use it in main.c
main(){
for (fn = __initcall_start; fn < __initcall_end; fn++)
do_one_initcall(*fn);
}
My question is: how configure the linker for my linux app?
For the moment i "don't use" any special linker script.
Can't find a good tutorial....
Thanks for any help.
David.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-09-22 19:19 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-22 19:19 How use linux_kernel init_calls system in a modular application? dboml
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).