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

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
prabuinet

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

Post 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!!! :)
mikeleany

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

Post 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.)
mikeleany

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

Post 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.
prabuinet

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

Post 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
Post Reply