calling constructor seems to end up in an endless loop
Posted: Sat Aug 21, 2010 4:33 am
Hi folks,
I have a problem at the very beginning of my kernel when I call my (C++) constructors.
First of all, here's a general overview of what I'm doing:
After having loaded my kernel by grub, I use Tim Robinson's GDT trick in order to let my kernel appear in higher half at address 0xC0000000 (segments base address 0x40000000, kernel is linked to address 0xC0000000, see http://www.osdever.net/tutorials/pdf/memory1.pdf). After that I enable paging, i.e. map my kernel's page frames to 0xC0000000 and finally I set up a "normal" GDT that uses segments starting at base address 0x00000000.
Now, calling the constructors come into play:
When I call my constructors after what I described so far, everything is fine.
But when I call the constructors right after using the GDT trick,it seems to end up in an endless loop (according to Bochs Debug CPU view, EIP looks like being in a loop...). More precisely, this seems to be right in the compiler generated code that is called to create the constructors (adding hlt instructions before and after that call brought me to that explanation...)
Does anyone have an idea?
I have a problem at the very beginning of my kernel when I call my (C++) constructors.
First of all, here's a general overview of what I'm doing:
After having loaded my kernel by grub, I use Tim Robinson's GDT trick in order to let my kernel appear in higher half at address 0xC0000000 (segments base address 0x40000000, kernel is linked to address 0xC0000000, see http://www.osdever.net/tutorials/pdf/memory1.pdf). After that I enable paging, i.e. map my kernel's page frames to 0xC0000000 and finally I set up a "normal" GDT that uses segments starting at base address 0x00000000.
Now, calling the constructors come into play:
When I call my constructors after what I described so far, everything is fine.
But when I call the constructors right after using the GDT trick,it seems to end up in an endless loop (according to Bochs Debug CPU view, EIP looks like being in a loop...). More precisely, this seems to be right in the compiler generated code that is called to create the constructors (adding hlt instructions before and after that call brought me to that explanation...)
Does anyone have an idea?