Page 1 of 1

grub: Error 13 when i added 255 function!

Posted: Sat Jul 16, 2011 9:37 am
by kokarez
Hi,

I've my kernel who boot on grub. I trying to add 255 function to my kernel but grub raised "Error 13: Invalid or unsupported executable format".

If i add 10 function => my kernel boot
If i add 11 function => "Error 13: Invalid or unsupported executable format"

I don't understand the probleme.

Here is the output of "objdump -x yalc" (10 function:http://pastebin.com/rgkiHTiM and 255 function:http://pastebin.com/gXJcnXmp).

My linker:

Code: Select all

OUTPUT_FORMAT("elf32-i386")

ENTRY(_start)
SECTIONS
{
	. = 0x00100000;
	.multiboot : AT ( ADDR( .multiboot ) )  { *(.multiboot) }
	.text : AT(ADDR(.text)) { *(.text)  }
}
My boot.S:

Code: Select all

#define ASM
#include "multiboot.h"
   
.section .multiboot
.align 4
mboot:
    .long   MULTIBOOT_HEADER_MAGIC
    .long   MULTIBOOT_HEADER_FLAGS
    .long   -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)


.section .text
.global _start
_start:
    pushl %eax
    movl %ebx, %edx
    call init_kernel
I became crazy!

Thx

Re: grub: Error 13 when i added 255 function!

Posted: Sat Jul 16, 2011 10:38 am
by thepowersgang
Well, as the objdump output states, your multiboot header is being pushed past the end of the area that grub searches.

Try putting the *(.multiboot) above *(.text) and see if it works, but that linker script _should_ work, so try to pare it down as far as you can until you find what breaks it.

Re: grub: Error 13 when i added 255 function!

Posted: Sat Jul 16, 2011 11:03 am
by kokarez
(I try your method)

I(a friend) have found the solution.

Code: Select all

OUTPUT_FORMAT("elf32-i386")

ENTRY(_start)
SECTIONS
{
	. = 0x100000 + SIZEOF_HEADERS;
	PROVIDE(_start_text = .);
	.multiboot : { *(.multiboot) }
	.text : { *(.text) }
	PROVIDE(_end_text = .);
}
EDIT: it worked temporarily ...

But we did not understand why!
Anybody understands?

Re: grub: Error 13 when i added 255 function!

Posted: Sun Jul 17, 2011 9:33 am
by Combuster
It is because the multiboot header appears too deep down the file. Even though the multiboot section is listed first in both the script and in the section table, it is last in the output. You may be able to solve that problem by putting the file containing the multiboot header first.