multiboot linker script

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
uglyoldbob
Member
Member
Posts: 62
Joined: Tue Feb 13, 2007 10:46 am

multiboot linker script

Post by uglyoldbob »

I recently discovered a rather easy to make sure that a compiled kernel image is multiboot compliant.

Code: Select all

/* Link.ld */

OUTPUT_FORMAT("elf32-i386")
ENTRY(start)

SECTIONS
{
.text 0x0100000 :
{
. = ALIGN(4);
LONG(0x1BADB002)
LONG(0x00000003)
LONG(0xE4524FFB)
code = .; _code = .; __code = .;
*(.text)
*(.rodata)
. = ALIGN(4096);
}

.data :
{
data = .; _data = .; __data = .;
*(.data)
. = ALIGN(4096);
}

.rodata :
{
*(.rodata)
}

.bss :
{
bss = .; _bss = .; __bss = .;
*(.bss)
. = ALIGN(4096);
}


end = .; _end = .; __end = .;
kernel_end = .;
}
I don't know if this is the best way to do it, but it did work for me.
I have an 80386SX 20MHz 2MB RAM.
It is my testbed platform. Only has the 3.5" and 5.25" floppy drives.
xyzzy
Member
Member
Posts: 391
Joined: Wed Jul 25, 2007 8:45 am
Libera.chat IRC: aejsmith
Location: London, UK
Contact:

Re: multiboot linker script

Post by xyzzy »

I define the Multiboot header to be in a seperate section, then link that section at the start of .text in the linker script.
sawdust
Member
Member
Posts: 51
Joined: Thu Dec 20, 2007 4:04 pm

Re: multiboot linker script

Post by sawdust »

AlexExtreme wrote:I define the Multiboot header to be in a seperate section, then link that section at the start of .text in the linker script.
I agree.
Post Reply