Page 1 of 1

multiboot linker script

Posted: Thu Aug 07, 2008 1:29 pm
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.

Re: multiboot linker script

Posted: Thu Aug 07, 2008 1:32 pm
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.

Re: multiboot linker script

Posted: Tue Aug 12, 2008 2:04 pm
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.