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.
system.inc issues
-
- Member
- Posts: 86
- Joined: Sat Jun 06, 2009 11:55 am
system.inc issues
my website: http://67.11.191.209/
my software: http://67.11.191.209/software
my OS: http://67.11.191.209/software/view.php? ... Synergy_OS
my software: http://67.11.191.209/software
my OS: http://67.11.191.209/software/view.php? ... Synergy_OS
Re: system.inc issues
I dont know the nasm syntax, but you could do something similar to this C pseudocodebrodeur235 wrote: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.
Code: Select all
// kmain.c
#define KMAIN_API /* nothing */
#include "system.inc"
// kmem.c
#include "system.inc"
// system.inc
#ifndef KMAIN_API
#define KMAIN_API extern
#endif
KMAIN_API kmain(void);
// and so on.
KMEM_API kmem_something(void);
KMEM_API kmem_something2(void);
KMAIN_API kmain2(void);
// etc.
-
- Member
- Posts: 86
- Joined: Sat Jun 06, 2009 11:55 am
Re: system.inc issues
That's a good idea. I was thinking about something else since I last posted the thread starter, but that idea's even better,
Brodeur235
Brodeur235
my website: http://67.11.191.209/
my software: http://67.11.191.209/software
my OS: http://67.11.191.209/software/view.php? ... Synergy_OS
my software: http://67.11.191.209/software
my OS: http://67.11.191.209/software/view.php? ... Synergy_OS