And made modifications to my project but to no avail. I followed the bare bones and bare bones c++ tutorials
Help would be greatly appreciated!
Here's my loader.asm
Code: Select all
global loader ; making entry point visible to linker
extern kernel_main ; kmain is defined in kmain.cpp
extern start_ctors ; beginning and end
extern end_ctors ; of the respective
extern start_dtors ; ctors and dtors section,
extern end_dtors ; declared by the linker script
section .__mbHeader
align 0x4
; setting up the Multiboot header - see GRUB docs for details
MODULEALIGN equ 1<<0 ; align loaded modules on page boundaries
MEMINFO equ 1<<1 ; provide memory map
FLAGS equ MODULEALIGN | MEMINFO ; this is the Multiboot 'flag' field
MAGIC equ 0x1BADB002 ; 'magic number' lets bootloader find the header
CHECKSUM equ -(MAGIC + FLAGS) ; checksum required
section .text
align 4
dd MAGIC
dd FLAGS
dd CHECKSUM
; reserve initial kernel stack space
STACKSIZE equ 0x4000 ; that's 16k.
loader:
mov esp, stack + STACKSIZE ; set up the stack
push eax ; Multiboot magic number
push ebx ; Multiboot info structure
mov ebx, start_ctors ; call the constructors
jmp .ctors_until_end
.call_constructor:
call [ebx]
add ebx,4
.ctors_until_end:
cmp ebx, end_ctors
jb .call_constructor
call kernel_main ; call kernel proper
mov ebx, end_dtors ; call the destructors
jmp .dtors_until_end
.call_destructor:
sub ebx, 4
call [ebx]
.dtors_until_end:
cmp ebx, start_dtors
ja .call_destructor
cli
.hang:
hlt ; halt machine should kernel return
jmp .hang
section .bss
align 4
stack:
resb STACKSIZE ; reserve 16k stack on a doubleword boundary
Code: Select all
OUTPUT_FORMAT(elf32-i386)
ENTRY (loader)
SECTIONS
{
. = 0x00100000;
.__mbHeader : {
*(.__mbHeader)
}
.text ALIGN (0x1000) :
{
*(.text)
*(.gnu.linkonce.t*)
}
.rodata ALIGN (0x1000) :
{
start_ctors = .;
*(.ctor*)
end_ctors = .;
start_dtors = .;
*(.dtor*)
end_dtors = .;
*(.rodata*)
*(.gnu.linkonce.r*)
}
.data ALIGN (0x1000) :
{
*(.data)
*(.gnu.linkonce.d*)
}
.bss :
{
sbss = .;
*(COMMON)
*(.bss)
*(.gnu.linkonce.b*)
ebss = .;
}
/DISCARD/ :
{
*(.comment)
*(.eh_frame) /* discard this, unless you are implementing runtime support for C++ exceptions. */
}
}
Code: Select all
@echo off
echo Building PIKoS...
echo.
call clean
echo.
echo C++/ASM Compiler And Linker Errors/Warnings:
echo ______________________________________________________________________
i586-elf-g++ -o obj/kernel.o -c kernel.cpp -Wall -Wextra -nostdlib -fno-builtin -nostartfiles -nodefaultlibs -fno-exceptions -fno-rtti -fno-stack-protector
nasm -f elf -o obj/loader.o loader.asm
i586-elf-ld -T link.ld -o bin/kernel.bin obj/kernel.o obj/loader.o --oformat=binary
echo ______________________________________________________________________
if exist "bin/kernel.bin" (
cd bin
echo.
echo Creating Bootable Floppy Image...
makeimage.bat
echo.
echo Build Complete!
pause
exit
) else (
echo Build Failure!
pause
exit
)