I am trying to create an 64 bit elf image, that I can load with grub. However, "grub-file --is-x86-multiboot2" command returns error. Here is my boot.S file;
Code: Select all
.set MULTIBOOT2_HEADER_MAGIC, 0xe85250d6
.set GRUB_MULTIBOOT_ARCHITECTURE_I386, 0
.set MULTIBOOT_HEADER_TAG_END, 0
.section .boot,"ax"
.code32
.align 8
multiboot_header:
.long MULTIBOOT2_HEADER_MAGIC
.long GRUB_MULTIBOOT_ARCHITECTURE_I386
.long multiboot_header_end - multiboot_header
.long -(MULTIBOOT2_HEADER_MAGIC + GRUB_MULTIBOOT_ARCHITECTURE_I386 + (multiboot_header_end - multiboot_header))
.short MULTIBOOT_HEADER_TAG_END
.short 0
.long 8
multiboot_header_end:
.globl _start
_start:
loop: hlt
jmp loop
Here is my linker file;
Code: Select all
ENTRY(_start)
SECTIONS {
. = 1M;
.boot ALIGN (4):
{
*(.boot)
}
}
As far as I can tell, this is supposed to create a valid elf image. According to objdump, my .boot section looks like this;x86_64-elf-gcc -MD -c boot.S -o boot.o -g -O2 -ffreestanding -mno-red-zone -Iinclude
x86_64-elf-gcc -T linker.ld -o kernel.elf -g -O2 -ffreestanding -mno-red-zone -nostdlib -lgcc boot.o
grub-file --is-x86-multiboot2 kernel.elf
Code: Select all
kernel/kernel.elf: file format elf64-x86-64
Contents of section .boot:
100000 d65052e8 00000000 18000000 12afad17 .PR.............
100010 00000000 08000000 f4ebfd ...........
Code: Select all
There are 11 section headers, starting at offset 0x100308:
Section Headers:
[Nr] Name Type Address Offset
Size EntSize Flags Link Info Align
[ 0] NULL 0000000000000000 00000000
0000000000000000 0000000000000000 0 0 0
[ 1] .boot PROGBITS 0000000000100000 00100000
000000000000001b 0000000000000000 AX 0 0 8
[ 2] .debug_line PROGBITS 0000000000000000 0010001b
000000000000004a 0000000000000000 0 0 1
[ 3] .debug_line_str PROGBITS 0000000000000000 00100065
0000000000000022 0000000000000001 MS 0 0 1
[ 4] .debug_info PROGBITS 0000000000000000 00100087
0000000000000028 0000000000000000 0 0 1
[ 5] .debug_abbrev PROGBITS 0000000000000000 001000af
0000000000000014 0000000000000000 0 0 1
[ 6] .debug_aranges PROGBITS 0000000000000000 001000d0
0000000000000030 0000000000000000 0 0 16
[ 7] .debug_str PROGBITS 0000000000000000 00100100
000000000000002e 0000000000000001 MS 0 0 1
[ 8] .symtab SYMTAB 0000000000000000 00100130
00000000000000d8 0000000000000018 9 8 8
[ 9] .strtab STRTAB 0000000000000000 00100208
000000000000008c 0000000000000000 0 0 1
[10] .shstrtab STRTAB 0000000000000000 00100294
0000000000000071 0000000000000000 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
L (link order), O (extra OS processing required), G (group), T (TLS),
C (compressed), x (unknown), o (OS specific), E (exclude),
l (large), p (processor specific)
I don't know what I am doing wrong here, so any help is appreciated. Thanks in advance,
Best Regards,