system.inc issues
Posted: Mon Aug 03, 2009 9:05 pm
I'm writing a system.inc header that I want all my kernel modules to include. So far the header just defines some %define's and %macro's, which is all fine and good. However a problem soon arises... Situation:
1.) I have a k_main module containing my k_main procedure.
2.) I have a k_mem module containing procedures that reference the k_main procedure for various, necessary purposes.
The second module (the k_mem) needs to know that k_main is defined externally (with an "extern k_main" statement), but the k_main module will generate an error stating: "error: symbol `_k_main' redefined". I understand this; please don't post a response explaining why this is happening.
The problem is that all kernel modules besides k_main will need to know that the k_main procedure label is external, so it seems like a good thing to put in the system.inc. However, this will generate the previously described error when assembling the header with the k_main module.
What is a good solution to this? I'm hoping I won't have to go to each individual module and pencil in exactly what procedures need to be defined externally for that one file... It just feels wrong..
Help appreciated,
Brodeur235
EDIT: Basically, I want to do it like this tutorial does it in C, except in asm. http://osdever.net/bkerndev/index.php. As the author creates new kernel modules, his system.h accumulates the function prototypes from that module, and they're all with an extern keyword. Then he includes system.h in the same file, yet GCC apparently does not throw a "function redeclared" error... Nasm does.
1.) I have a k_main module containing my k_main procedure.
2.) I have a k_mem module containing procedures that reference the k_main procedure for various, necessary purposes.
The second module (the k_mem) needs to know that k_main is defined externally (with an "extern k_main" statement), but the k_main module will generate an error stating: "error: symbol `_k_main' redefined". I understand this; please don't post a response explaining why this is happening.
The problem is that all kernel modules besides k_main will need to know that the k_main procedure label is external, so it seems like a good thing to put in the system.inc. However, this will generate the previously described error when assembling the header with the k_main module.
What is a good solution to this? I'm hoping I won't have to go to each individual module and pencil in exactly what procedures need to be defined externally for that one file... It just feels wrong..
Help appreciated,
Brodeur235
EDIT: Basically, I want to do it like this tutorial does it in C, except in asm. http://osdever.net/bkerndev/index.php. As the author creates new kernel modules, his system.h accumulates the function prototypes from that module, and they're all with an extern keyword. Then he includes system.h in the same file, yet GCC apparently does not throw a "function redeclared" error... Nasm does.