Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
wolfram
Posts: 19 Joined: Wed Aug 19, 2009 11:37 am
Location: Saint-Petersburg, Russia
Post
by wolfram » Wed Aug 19, 2009 11:50 am
I try to write a higher half kernel. I think to use manipulation with sections. I wrote a linker script, but when I try to load my kernel with GRUB, GRUB says me "Selected item can't fit into memory".
My ld script:
Code: Select all
OUTPUT_FORMAT("elf32-i386")
ENTRY(_start)
SECTIONS
{
. = 0x00100000;
.loader :
{
*(.loader)
}
. = 0xc0000000;
.text ALIGN(0x1000) :
{
_sttext = . - 0xc0000000;
*(.text)
*(.rodata)
}
.data ALIGN(0x1000) :
{
_stdata = . - 0xc0000000;
*(.data)
}
.bss ALIGN(0x1000) :
{
*(.bss)
*(COMMON)
}
_sztext = SIZEOF(.text);
_szdata = SIZEOF(.data);
}
I think somebody helps to stupid noob.
P.S. Sorry for my bad English, English is not my native language.
Last edited by
wolfram on Thu Aug 20, 2009 1:20 pm, edited 1 time in total.
manonthemoon
Member
Posts: 65 Joined: Sat Jul 04, 2009 9:39 pm
Post
by manonthemoon » Wed Aug 19, 2009 12:17 pm
I believe GRUB is trying to load your kernel at location 0xC0000000, which obviously requires too much memory.
Try changing each section to something like this:
Code: Select all
.text ALIGN(0x1000) : AT(ADDR(.text) - 0xC0000000)
EDIT: See the linker script on the
Higher Half bare bones page. I just updated the Wiki to include this error.
wolfram
Posts: 19 Joined: Wed Aug 19, 2009 11:37 am
Location: Saint-Petersburg, Russia
Post
by wolfram » Thu Aug 20, 2009 2:15 am
Thanks. I changed sections and now my ld-script looks as
Code: Select all
OUTPUT_FORMAT("elf32-i386")
ENTRY(_start)
SECTIONS
{
. = 0x00100000;
.loader :
{
*(.loader)
}
. = 0xC0100000 + SIZEOF(.loader);
.text ALIGN(0x1000) : AT(ADDR(.text) - 0xC0000000)
{
_sttext = .;
*(.text)
*(.rodata*)
_sztext = SIZEOF(.text);
}
.data ALIGN(0x1000) : AT(ADDR(.data) - 0xC0000000)
{
_stdata = .;
*(.data)
_szdata = SIZEOF(.data);
}
.bss : AT(ADDR(.bss) - 0xC0000000)
{
*(.bss)
*(COMMON)
}
}
Now GRUB loads my kernel correctly.