Skip to content

Commit

Permalink
Added -fpermissive for ctor iteration comparison.
Browse files Browse the repository at this point in the history
FIXME: When calling call_ctors in loader.s, kernel hangs.
  • Loading branch information
IPlayZed committed Feb 3, 2022
1 parent 81a5a71 commit 7e4c977
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# g++ parameters
GPP_PARAMS = -m32 -Wall -fno-use-cxa-atexit -nostdlib -fno-builtin -fno-rtti -fno-exceptions -fno-leading-underscore
GPP_PARAMS = -m32 -Wall -fno-use-cxa-atexit -nostdlib -fno-builtin -fno-rtti -fno-exceptions -fno-leading-underscore -fpermissive
# assembler parameters
AS_PARAMS = --32
# linker parameters
Expand Down Expand Up @@ -36,4 +36,4 @@ sunix.iso: sunix.bin
cp grub.cfg ${ISO_GRUB_DIR}
grub-mkrescue --output=$@ ${ISO_DIR}
rm -rf iso
mv $@ ../out
mv $@ ../out
6 changes: 5 additions & 1 deletion src/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@ void printf(char* str)
}
}

/* For composite object static/global objects (like class instances) we must call the compiler
* generated constructors.
* We just iterate through them.
* */
extern LANG_C void call_ctors()
{
for(ctor* i = &start_ctors; i != (ctor*)end_ctors; i++)
for(ctor* i = &start_ctors; i != end_ctors; i++)
{
(*i)();
}
Expand Down
5 changes: 3 additions & 2 deletions src/loader.s
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
.global loader

loader:
mov $kernel_stack_ptr, %esp # set stack pointer, as kernel_main is a cpp program and it expects the stack pointer to be set
mov $kernel_stack_ptr, %esp # set stack pointer, as kernel_main is a cpp program and it expects the stack pointer to be set.

call call_ctors
# FIXME: When this is called, kernel doesn't run?
#call call_ctors # Call the compiler generated constructors.

push %eax # The (GRUB2) bootloader stores the multiboot structure's RAM adress in the AX register during loading the kernel of choice, which contains valuable information, like the size of the RAM. We should push this to the stack in order to access it later.
push %ebx # The (GRUB2) bootloader stores the MULTIBOOT_FLAG value in the BX register.
Expand Down

0 comments on commit 7e4c977

Please sign in to comment.