You're not including the built-in startup code when you link your kernel, and this is what calls the constructors and destructors of static and global objects. Also, if you have the following global variable, it won't be initialized:
int foo = bar(100);
Because function bar() would have to be called before main(). The following example of global declarations is also interesting:
int x = 5, y = 6;
int z = x + y;
With gcc (may be different with other compilers) z is computed at run-time, before main() is called, so it wouldn't work with your kernel either.
In order for all these things to work, you have to write your own functions to call the constructors and destructors (in my two examples, bar(100) and x + y are treated as constructors). Unfortunately, I haven't seen a good tutorial or document on how to do this. But even if there were, it would have to be compiler specific. The best one I've seen is the second half of the C++ tutorial at:
http://www.invalidsoftware.net/os/?the_id=11
There are a few problems with it. First, atexit() is a C and POSIX standard function, which does not do what the tutorial says (but you will still need a function like his atexit(), just call it a different name). Second, the constructors should be called starting from the end of the list and going toward the beginning, while the destructors should be called starting from the beginning and going to the end. This will make sure they are called in the proper order. Third, it says nothing about __cxa_atexit and __dso_handle. __cxa_atexit is (sort of) a C++ version of atexit. You will need to impliment it if you want your destructors called. __dso_handle has to do with dynamically shared libraries. Even though you're probably not using any for your kernel, you still need to define it. Just define it like this:
void * __dso_handle = 0;
You can find more about __cxa_atexit and atexit at the following sites:
http://www.linuxbase.org/spec/refspecs/ ... texit.html
http://www.opengroup.org/onlinepubs/007 ... texit.html
Also, a description of atexit can be found by typing "man atexit" at the command prompt in linux.
One last thing. You can ignore the final parameter of __cxa_atexit. It just has to do with dynamicly shared libraries.
I think I covered everything, but I might have missed a thing or two. If you don't understand something or have any other questions about it, just ask. I may write up a proper tutorial for it soon.