Page 1 of 1

c++ kernel and g++ (global objects and other things..

Posted: Sun May 16, 2004 11:00 pm
by prabuinet
I have problem with declaring global objects in my c++ kernel.
It creates an error while linkage, it says:

undefined symbols :
__dso_handle
__cs..atexit

"please help me
this seem to be a headache

I on work for my college project.
And note I am not using grub to load my kernel, So everying should be done
by myself (with you people's help)
help me !!!

(sorry! for bad English, Advanced thanks!!! :)

RE:c++ kernel and g++ (global objects and other things..

Posted: Sun May 16, 2004 11:00 pm
by mikeleany
This is because the constructors of your global objects have to be called BEFORE main(), and your destructors AFTER main().
__dso_handle can simply be null (it's used for shared object stuff)
for information on __cxa_atexit(), see http://www.linuxbase.org/spec/refspecs/ ... texit.html and the man page for atexit().
(The functions registered by __cxa_atexit will need to be called when your kernel shuts down.)

It will also put pointers to functions in the .ctors and possibly .dtors sections of your object files. You will need to make sure you call these functions at the appropriate times. For more information a google search for .ctors should help. (But be careful. Some of the tutorials, etc. you find might not be entirely accurate.)

RE:c++ kernel and g++ (global objects and other things..

Posted: Sun May 16, 2004 11:00 pm
by mikeleany
Forgot to mention, __dso_handle is of type (void *). Like I said, this should be null, so you should have a line like this:
void * __dso_handle = 0;
And, in case it wasn't clear, you will need to implement __cxa_atexit().
If you want to get around this don't use global objects or any initialized global variables.

RE:c++ kernel and g++ (global objects and other things..

Posted: Tue May 18, 2004 11:00 pm
by prabuinet
i will implement __cxa_atexit() myself ...
Thanks for your response!!!

And what r u doing ..?

I am just developing my POS (os) as my college accademic project.
Now i'm working with "pmcode" (that asm files demonstrating protected mode)
can you tell me whether SAD(System Analysis and Design) will help me
INFORMATION > ANALYSE > DESIGN > CODING > DEBUGGING
is this the right way for os development.

Thanks "xSadar" for your kind reply