c++ 'global' objects
Posted: Sun Mar 21, 2004 6:22 am
I've read the faq and it says for global objects to use 'new()'. How do you put an object in memory and wheres the best place to put it?
The Place to Start for Operating System Developers
https://forum.osdev.org/
Code: Select all
void *operator new(size_t bytes)
{
return malloc(bytes);
}
void operator delete(void *ptr)
{
free(ptr);
}Code: Select all
ENTRY (kernel_loader)
SECTIONS
{
...
.data ALIGN (0x1000) :
{
start_ctors = .;
*(.ctor*)
end_ctors = .;
*(.data)
}
...
}
Code: Select all
# calling global / static constructors
mov $start_ctors, %ebx
jmp 2f
1: call *(%ebx)
add $4, %ebx
2: cmp $end_ctors, %ebx
jb 1b