How use linux_kernel init_calls system in a modular application?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux