So, I compiled Bochs for debugging and started stepping though the booting of my OS. It made it though my boot code then jumped to my kernel at 0x00100000 witch should be the section .setup which sets up paging and jumps to .text at 0xc0000400 ( 0x00100400 physically )
the problem is my linker puts .text at 0x00100000 not .setup like it should, so it runs my kernel code w/o paging enabled ( which only runs for a few instructions before blowing up )
What I need is a linker script to put .setup first, then link .text to 0xc0000400 and put it on the file kernel.sys after .setup and at 1024bytes in to the file
here is my current linker:
Code: Select all
OUTPUT_FORMAT("binary")
ENTRY(start)
phys = 0x00100000;
virt = 0xC0000400;
SECTIONS
{
.setup phys : AT( phys )
{
setup = .; _setup = .; __setup = .;
*(.setup)
setupend = .;
. = ALIGN(1024);
}
.kernel virt : AT( ADDR(.setup) + SIZEOF(.setup) )
{
code = .; _code = .; __code = .;
*(.text)
codend = .;
. = ALIGN(0);
}
.data virt : AT( ADDR(.setup) + SIZEOF(.setup) + SIZEOF(.kernel) )
{
data = .; _data = .; __data = .;
*(.data)
dataend = .;
. = ALIGN(0);
}
.bss virt : AT( ADDR(.setup) + SIZEOF(.setup) + SIZEOF(.kernel) + SIZEOF(.data))
{
bss = .; _bss = .; __bss = .;
*(.bss)
bssend = .;
. = ALIGN(0);
}
.rodata virt : AT( ADDR(.setup) + SIZEOF(.setup) + SIZEOF(.kernel) + SIZEOF(.data) + SIZEOF(.bss) )
{
rodata = .; _rodata = .; __rodata = .;
*(.rodata)
rodataend = .;
. = ALIGN(0);
}
setuplength = SIZEOF(.setup);
bsslength = (bssend - bss) / 4;
kend = .; _kend = .; __kend = .;
}
thank you
EDIT: "witch" to "which"