mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:48:12 +00:00
Kernel: Add bare minimum for global constructors (#707)
Add text.startup to the .text block, add .ctors as well. Use them in init.cpp to call global constructors after gtd and idt init. That way any funky constructors should be ok. Also defines some Itanium C++ ABI methods that probably shouldn't be, but without them the linker gets very angry. If the code ever actually tries to use __dso_handle or call __cxa_atexit, there's bigger problems with the kernel. Bit of a hack would be an understatement but hey. It works :)
This commit is contained in:
parent
d0c11bbcc3
commit
233ea7eb1d
2 changed files with 25 additions and 0 deletions
|
@ -192,6 +192,22 @@ extern "C" {
|
|||
multiboot_info_t* multiboot_info_ptr;
|
||||
}
|
||||
|
||||
typedef void (*ctor_func_t)();
|
||||
|
||||
// Defined in the linker script
|
||||
extern ctor_func_t start_ctors;
|
||||
extern ctor_func_t end_ctors;
|
||||
|
||||
// Define some Itanium C++ ABI methods to stop the linker from complaining
|
||||
// If we actually call these something has gone horribly wrong
|
||||
void* __dso_handle __attribute__((visibility ("hidden")));
|
||||
|
||||
extern "C" int __cxa_atexit ( void (*)(void *), void *, void *)
|
||||
{
|
||||
ASSERT_NOT_REACHED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" [[noreturn]] void init()
|
||||
{
|
||||
// this is only used one time, directly below here. we can't use this part
|
||||
|
@ -234,6 +250,10 @@ extern "C" [[noreturn]] void init()
|
|||
gdt_init();
|
||||
idt_init();
|
||||
|
||||
// call global constructors after gtd and itd init
|
||||
for (ctor_func_t* ctor = &start_ctors; ctor < &end_ctors; ctor++)
|
||||
(*ctor)();
|
||||
|
||||
keyboard = new KeyboardDevice;
|
||||
ps2mouse = new PS2MouseDevice;
|
||||
sb16 = new SB16;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue