Today I had to re-start coding from scratch as my laptop died (and I'm too lazy to make backups). I've set up a cross compiler for x86_64 on my Mac. Now I'm getting grub error 13 and, yes, I did try what it says on the Wiki...
My code is extremely simple so far. First, I took the RDOS grub disk image. My "entry.s" file is simply:
Code: Select all
[section .__mbHeader]
MODULEALIGN equ 1 << 0
MEMINFO equ 1 << 1
FLAGS equ MODULEALIGN | MEMINFO
MAGIC equ 0x1BADB002
CHECKSUM equ ~(MAGIC | FLAGS)
align 0x4
dd MAGIC
dd FLAGS
dd CHECKSUM
[section .setup]
[global _start]
_start:
jmp $
Code: Select all
OUTPUT_FORMAT(elf32-i386)
ENTRY(_start)
SECTIONS {
. = 0x00100000;
.__mbHeader : {
*(.__mbHeader)
}
.text ALIGN(0x1000) : {
*(.setup)
}
/DISCARD/ :
{
*(.comment)
*(.eh_frame)
}
}
Yes, I do link it with a 64 bit linker, as my cross compiler is 64 bits, but I believe that should work fine for compiling 32 bit applications... right?/opt/local/bin/yasm -f elf32 -o entry.o entry.s
/usr/local/cross/bin/x86_64-elf-ld -melf_i386 -T Link.ld -o kernel ./entry.o
All looks fine, except that I get a grub error 13: Invalid or unsupported executable format.
Some information about the kernel binary:
$ /usr/local/cross/bin/x86_64-elf-objdump -s kernel/kernel
kernel/kernel: file format elf32-i386
Contents of section .__mbHeader:
100000 02b0ad1b 03000000 fc4f52e4 .........OR.
Contents of section .text:
101000 ebfe0000 00000000 00000000 00000000 ................
What's the issue? Is there something wrong with my multiboot header?$ /usr/local/cross/bin/x86_64-elf-objdump -f kernel/kernel
kernel/kernel: file format elf32-i386
architecture: i386, flags 0x00000112:
EXEC_P, HAS_SYMS, D_PAGED
start address 0x00101000
Thanks in advance