Re: Executing C Kernel #101
Posted: Sun Aug 14, 2011 2:35 pm
Yes, sbss and ebss are two labels, and they point to start and end of the bss section. (At least this is what this piece of a linker script defines them to be.)
The Place to Start for Operating System Developers
http://f.osdev.org/
Code: Select all
class Test
{
public:
Test()
{
mem = reinterpret_cast<unsigned short *>(0xB8000);
* mem++ = 0x4041;
}
~Test()
{
* mem++ = 0x4042;
}
private:
unsigned short * mem;
};
Test test;
extern unsigned long StartConstructors;
extern unsigned long EndConstructors;
extern unsigned long StartDestructors;
extern unsigned long EndDestructors;
extern "C" void Main( void* mbd, unsigned int magic )
{
if ( magic != 0x2BADB002 )
{
}
for(unsigned long *constructor(&StartConstructors); constructor < &EndConstructors; ++constructor)
((void (*) (void)) (*constructor)) ();
char * boot_loader_name =(char*) ((long*)mbd)[16];
for(unsigned long *destructor(&StartDestructors); destructor < &EndDestructors; ++destructor)
((void (*) (void)) (*destructor)) ();
}
I believe you have to invoke it yourself. The compiler certainly doesn't know when your OS has "exited".Haroogan wrote:
EDIT: I've noticed that "__cxa_finalize" is never invoked too.