grub: Error 13 when i added 255 function!

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
kokarez
Posts: 2
Joined: Sat Jul 16, 2011 9:24 am

grub: Error 13 when i added 255 function!

Post 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
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

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

Post 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.
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
kokarez
Posts: 2
Joined: Sat Jul 16, 2011 9:24 am

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

Post 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?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

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

Post 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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Post Reply