Executing C Kernel #101
- xenos
- Member
- Posts: 1121
- Joined: Thu Aug 11, 2005 11:00 pm
- Libera.chat IRC: xenos1984
- Location: Tartu, Estonia
- Contact:
Re: Executing C Kernel #101
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.)
Re: Executing C Kernel #101
I've just implemented C++ bare bones:
Everything compiles and runs fine, but the problem is that Destructors for global objects are not invoked at all. You can see it in "Test" class. There was one post about it somewhere here, but still no solution. Shall I ignore that?
P. S. I've added ICPPABI stuff.
EDIT: I've noticed that "__cxa_finalize" is never invoked too.
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)) ();
}
P. S. I've added ICPPABI stuff.
EDIT: I've noticed that "__cxa_finalize" is never invoked too.
Re: Executing C Kernel #101
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.
- xenos
- Member
- Posts: 1121
- Joined: Thu Aug 11, 2005 11:00 pm
- Libera.chat IRC: xenos1984
- Location: Tartu, Estonia
- Contact:
Re: Executing C Kernel #101
Have you looked up the C++ article in the wiki? It describes the usage of global objects in a kernel quite well.
My personal preference is to use no global objects at all, and to create / destroy all objects when they are needed.
My personal preference is to use no global objects at all, and to create / destroy all objects when they are needed.