"Error 13: Invalid or unsupported executable format" error
Re: "Error 13: Invalid or unsupported executable format" error
thanks OdinPG. you have been more than useful. but the output_arch option in the link file does the same as the melf-i386... it doesn't work :S
I don't want to bother you. But if you don't mind. would you please test it in a 64 bit machine? If it's working on yours I'm going to start thinking this is a problem with grub. or something else.
I don't want to bother you. But if you don't mind. would you please test it in a 64 bit machine? If it's working on yours I'm going to start thinking this is a problem with grub. or something else.
- Combuster
- 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: "Error 13: Invalid or unsupported executable format" error
Yet another frequent problem. GCC Cross-Compiler
-
- Member
- Posts: 79
- Joined: Sun Jun 10, 2007 11:36 am
Re: "Error 13: Invalid or unsupported executable format" error
I tried to build it on my 64 bit machine, but i got the following errors:
I don't know why, but may be you got that too and fixed it?
Code: Select all
text_services.asm:169: error: short jump is out of range
text_services.asm:172: error: short jump is out of range
ld: text_services.o: No such file: No such file or directory
42
Re: "Error 13: Invalid or unsupported executable format" error
no. I didn't have that error. but try updating nasm to the latest version
Also I found this solutions in google:
"You need to add -O99 to the NASM variable."
Thanks for taking the time to test this. I'll try the gcc cross compiler guide... even thought I'm not using gcc... it's completely written in assembly language...
Also I found this solutions in google:
"You need to add -O99 to the NASM variable."
Thanks for taking the time to test this. I'll try the gcc cross compiler guide... even thought I'm not using gcc... it's completely written in assembly language...
-
- Member
- Posts: 79
- Joined: Sun Jun 10, 2007 11:36 am
Re: "Error 13: Invalid or unsupported executable format" error
Okay.
It compiles with the option "-O99". When I update the image (mount floppy image and copy kernels binary on it), I got the GRUB 13 Error. After this I used my on Floppy image an there the Error 28 "Selected item cannot fit into memory" occurs.
This Error occured, because your linker script was wrong: Now it looks like this:
Your compile script within src looks like this:
The file start.asm is the same as before, with SECTION .__mbHeader.
At last I copied the created kernel on your image and it seems that it is broken, because there Error 13 occurs.
Hope it helps...
Cheers Christian
PS: This is the way I created my floppy image:
It compiles with the option "-O99". When I update the image (mount floppy image and copy kernels binary on it), I got the GRUB 13 Error. After this I used my on Floppy image an there the Error 28 "Selected item cannot fit into memory" occurs.
This Error occured, because your linker script was wrong: Now it looks like this:
Code: Select all
/*OUTPUT_ARCH ( "i386" )
OUTPUT_FORMAT("binary")*/
OUTPUT_FORMAT("elf32-i386")
ENTRY(start)
phys = 0x00100000;
SECTIONS
{
/*
* http://wiki.osdev.org/Grub_Error_13
*/
. = phys;
/* .__mbHeader will begin @ 'phys' */
.__mbHeader : AT ( ADDR( .__mbHeader ) ) {
/* mboot = .;*/
*(.__mbHeader)
}
.text : AT(ADDR(.text)) {
code = .;
*(.text)
*(.rodata)
. = ALIGN(4096);
}
.data : AT(ADDR(.text) + (data - code))
{
data = .;
*(.data)
. = ALIGN(4096);
}
.bss : AT(ADDR(.text) + (bss - code))
{
bss = .;
*(.bss)
. = ALIGN(4096);
}
end = .;
}
Your compile script within src looks like this:
Code: Select all
rm *.o
nasm -O99 -f elf32 -o text_services.o text_services.asm
nasm -O99 -f elf32 -o kernel.o kernel.asm
nasm -O99 -f elf32 -o start.o start.asm
nasm -O99 -f elf32 -o system.o system.asm
nasm -O99 -f elf32 -o isr.o isr.asm
ld -T link.ld -melf_i386 -o kernel.bin start.o kernel.o text_services.o system.o isr.o
Code: Select all
; This is the kernel's entry point. We could either call main here,
; or we can use this to setup the stack or other nice stuff, like
; perhaps setting up the GDT and segments. Please note that interrupts
; are disabled at this point: More on interrupts later!
[BITS 32]
SECTION .__mbHeader
; This part MUST be 4byte aligned, so we solve that issue using 'ALIGN 4'
ALIGN 4
mboot:
; Multiboot macros to make a few lines later more readable
MULTIBOOT_PAGE_ALIGN equ 1<<0
MULTIBOOT_MEMORY_INFO equ 1<<1
MULTIBOOT_AOUT_KLUDGE equ 1<<16
MULTIBOOT_HEADER_MAGIC equ 0x1BADB002
MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO | MULTIBOOT_AOUT_KLUDGE
MULTIBOOT_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
EXTERN code, bss, end
;...
Hope it helps...
Cheers Christian
PS: This is the way I created my floppy image:
Code: Select all
dd if=/dev/zero of=./floppy.ext2.img bs=1024 count=1440
/sbin/mke2fs -F ./floppy.ext2.img -L MyOS
mount ./floppy.ext2.img ./flp -o loop
mkdir ./flp/boot
mkdir ./flp/boot/grub
mkdir ./flp/modules
mkdir ./flp/system
mkdir ./flp/system/drivers
cp kernel.elf ./flp/boot
cp ./src/modules/initrd.tar ./flp/modules
cp /boot/grub/stage1 ./flp/boot/grub
cp /boot/grub/stage2 ./flp/boot/grub
cp menu.lst ./flp/boot/grub
umount ./flp
grep -v ^# ./grub.conf | /usr/sbin/grub --batch
42
Re: "Error 13: Invalid or unsupported executable format" error
thank you so much for taking this time. I really appreciate it...
I couldn't make it work either. and it's strange... it's working on a 32 bits machine (you tested it, I don't have a 32bit OS) and not working with 64 bit linkers (we both tried this).
This is the (partial) output of objdump -s:
This kernel is Not Working:
And this is working:
of course I could just install a 32 bit OS and start developing the kernel there... but the question is... Why? it should be posible to do it in a 64 bit OS. There must be an error in my linker script... or.... a bug somewhere... in anyway... I know I made a mistake... but I don't know where
I couldn't make it work either. and it's strange... it's working on a 32 bits machine (you tested it, I don't have a 32bit OS) and not working with 64 bit linkers (we both tried this).
This is the (partial) output of objdump -s:
This kernel is Not Working:
Code: Select all
kernelNW.bin: file format elf32-i386
Contents of section .__mbHeader:
100000 02b0ad1b 03000100 fb4f51e4 00001000 .........OQ.....
100010 20001000 00301000 00601000 20001000 ....0...`.. ...
Contents of section .text:
100020 0f011500 20100066 b810008e d88ec08e .... ..f........
100030 e08ee88e d0ea3c00 10000800 bc005010 ......<.......P.
...
Code: Select all
kernel.bin: file format elf32-i386
Contents of section .__mbHeader:
100000 02b0ad1b 03000100 fb4f51e4 00001000 .........OQ.....
100010 20001000 00201000 00501000 20001000 .... ...P.. ...
Contents of section .text:
100020 0f011500 10100066 b810008e d88ec08e .......f........
...
of course I could just install a 32 bit OS and start developing the kernel there... but the question is... Why? it should be posible to do it in a 64 bit OS. There must be an error in my linker script... or.... a bug somewhere... in anyway... I know I made a mistake... but I don't know where
-
- Member
- Posts: 79
- Joined: Sun Jun 10, 2007 11:36 am
Re: "Error 13: Invalid or unsupported executable format" error
Hmmm...
could you upload your current source code?
Further more try using a Crosscompiler, because there is a different version of "ld" within, what you use to link the kernel...
could you upload your current source code?
Further more try using a Crosscompiler, because there is a different version of "ld" within, what you use to link the kernel...
42
Re: "Error 13: Invalid or unsupported executable format" error
I was reading again you latest reply... so you actually made it work on the 64 bits machine using your own image instead of my floppy image? Maybe you loaded an updated grub version.
I thought I could do the same. but I was looking at your commands to create my own image witha newer grub but I have some missing files... for example:
what are you doing when you do this?
"grep -v ^# ./grub.conf | /usr/sbin/grub --batch"
Where is grub.conf and what does it have inside? and what about initrd.tar?
I followed this guide as you suggested:
http://wiki.osdev.org/GCC_Cross-Compiler
And used that linker. now I don't have to specify the output architecture cause I'm using the i586 linker. but it doesn't work anyway :S
I'm still getting the same error.
This is my current source code (using the cross compiler to compile 32 bit code):
http://rapidshare.com/files/307560009/e ... ar.gz.html
MD5: 1654F571D9A7616236F0B74EDC50AE13
I'm so embarrassed. I know developing an OS is not an easy task. But I feel useless not being able to solve this issue... Thanks for taking the time to help me
I thought I could do the same. but I was looking at your commands to create my own image witha newer grub but I have some missing files... for example:
what are you doing when you do this?
"grep -v ^# ./grub.conf | /usr/sbin/grub --batch"
Where is grub.conf and what does it have inside? and what about initrd.tar?
I followed this guide as you suggested:
http://wiki.osdev.org/GCC_Cross-Compiler
And used that linker. now I don't have to specify the output architecture cause I'm using the i586 linker. but it doesn't work anyway :S
I'm still getting the same error.
This is my current source code (using the cross compiler to compile 32 bit code):
http://rapidshare.com/files/307560009/e ... ar.gz.html
MD5: 1654F571D9A7616236F0B74EDC50AE13
I'm so embarrassed. I know developing an OS is not an easy task. But I feel useless not being able to solve this issue... Thanks for taking the time to help me
-
- Member
- Posts: 79
- Joined: Sun Jun 10, 2007 11:36 am
Re: "Error 13: Invalid or unsupported executable format" error
Good Morning from Germany,
initrd.tar is my initial ramdisk and could be ignored.
The file grub.conf looks like this:
The version of GRUB I am using is "0.97". This is the one which is also used by my Linux distribution.
What happens there...
The command starts GRUB within the batch-mode. This means that "/usr/sbin/grub" will be executed and everything within the file "grub.conf" will be executed as command within the grub-shell. It is similar to the following steps:
I took a short look at your code, and it seems that you update your image by creating a new one. But where do you install GRUB? I do this with the line "grep -v ^# ./grub.conf | /usr/sbin/grub --batch" after creating, formatting the image and copying all the content. If you want, I'll upload my image...
EDIT: Okay, you created the image before, so there is no need to install GRUB
I will have a look at your code later, because at the moment I am at work.
Hope it helps...
Cheers Christian
PS: My English isn't good
initrd.tar is my initial ramdisk and could be ignored.
The file grub.conf looks like this:
Code: Select all
device (fd0) ./floppy.ext2.img
root (fd0)
setup (fd0)
The version of GRUB I am using is "0.97". This is the one which is also used by my Linux distribution.
What happens there...
The command starts GRUB within the batch-mode. This means that "/usr/sbin/grub" will be executed and everything within the file "grub.conf" will be executed as command within the grub-shell. It is similar to the following steps:
Code: Select all
# start grub-shell
$> /usr/sbin/grub
# set image as device fd0
grub> device (fd0) /path/to/image
# set fd0 to root for grub
grub> root (fd0)
# install it
grub> setup (fd0)
# and quit the grub shell
grub> quit
EDIT: Okay, you created the image before, so there is no need to install GRUB
I will have a look at your code later, because at the moment I am at work.
Hope it helps...
Cheers Christian
PS: My English isn't good
42
Re: "Error 13: Invalid or unsupported executable format" error
I found it!!! I found the error!! :D I'm so happy I could just take the whole night to drink a few beers!!! too bad I have to work tomorrow...
I successfully converted my kernel image from elf32 to bin. And to do so I had to manually set the code, mboot,start labels... and guess what? that was it!
This is where I got it:
http://forum.osdev.org/viewtopic.php?f=1&t=21061
Look at the MB Header:
that was it. that should point to the mboot start too. instead of the .text section. I guess it really should be added to the wiki.
Another way to do exactly the same thing (and actually this is what I'm currently using) is to set the correct "code" address in the linker script:
thank you so much to everyone. REALLY. you have been really kind.
I successfully converted my kernel image from elf32 to bin. And to do so I had to manually set the code, mboot,start labels... and guess what? that was it!
This is where I got it:
http://forum.osdev.org/viewtopic.php?f=1&t=21061
Look at the MB Header:
Code: Select all
[BITS 32]
; This part MUST be 4byte aligned, so we solve that issue using 'ALIGN 4'
ALIGN 4
mboot:
; Multiboot macros to make a few lines later more readable
MULTIBOOT_PAGE_ALIGN equ 1<<0
MULTIBOOT_MEMORY_INFO equ 1<<1
MULTIBOOT_AOUT_KLUDGE equ 1<<16
MULTIBOOT_HEADER_MAGIC equ 0x1BADB002
MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO | MULTIBOOT_AOUT_KLUDGE
MULTIBOOT_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
; EXTERN code, bss, end
; This is the GRUB Multiboot header. A boot signature
dd MULTIBOOT_HEADER_MAGIC
dd MULTIBOOT_HEADER_FLAGS
dd MULTIBOOT_CHECKSUM
; AOUT kludge - must be physical addresses. Make a note of these:
; The linker script fills in the data for these ones!
dd mboot
dd code ;DOESN'T WORK
; dd $$ ;WORKS!
dd bss
dd end
dd start
Another way to do exactly the same thing (and actually this is what I'm currently using) is to set the correct "code" address in the linker script:
Code: Select all
OUTPUT_FORMAT("elf32-i386")
ENTRY(start)
phys = 0x00100000;
SECTIONS
{
/*
* http://wiki.osdev.org/Grub_Error_13
*/
. = phys;
/* .__mbHeader will begin @ 'phys' */
.__mbHeader : AT ( ADDR( .__mbHeader ) ) {
mboot = .;
code = .;
*(.__mbHeader)
}
.text : AT(ADDR(.text)) {
/*code = .;*/
*(.text)
*(.rodata)
. = ALIGN(4096);
}
.data : AT(ADDR(.text) + (data - code))
{
data = .;
*(.data)
. = ALIGN(4096);
}
.bss : AT(ADDR(.text) + (bss - code))
{
bss = .;
*(.bss)
. = ALIGN(4096);
}
end = .;
}
thank you so much to everyone. REALLY. you have been really kind.