Higher Half and GRUB loading problems [solved]

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.
Post Reply
wolfram
Posts: 19
Joined: Wed Aug 19, 2009 11:37 am
Location: Saint-Petersburg, Russia

Higher Half and GRUB loading problems [solved]

Post by wolfram »

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
Member
Posts: 65
Joined: Sat Jul 04, 2009 9:39 pm

Re: Higher Half and GRUB loading problems

Post by manonthemoon »

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

Re: Higher Half and GRUB loading problems

Post by wolfram »

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.
Post Reply