'qemu-system-i386: Error loading uncompressed kernel without PVH ELF Note

Im trying to boot my OS to qemu with this code:

qemu-system-i386 -kernel MyOS/mykernel.elf

But I keep getting this error:

qemu-system-i386: Error loading uncompressed kernel without PVH ELF Note

Here is the code i use to build:

i686-elf-gcc -std=gnu99 -ffreestanding -g -c MyOS/start.s -o MyOS/start.o
i686-elf-gcc -std=gnu99 -ffreestanding -g -c MyOS/kernel.c -o MyOS/kernel.o
i686-elf-gcc -ffreestanding -nostdlib -g -T MyOS/linker.ld MyOS/start.o MyOS/kernel.o -o MyOS/mykernel.elf -lgcc
qemu-system-i386 -kernel MyOS/mykernel.elf

My files:

kernel.c/o

start.s/o

linker.ld

mykernel.elf

Can anyone help? If you need the code incase if its the code's fault or something, just reply stating that.



Solution 1:[1]

Try adding this to the command line

-machine type=pc-i440fx-3.1

Source: https://forum.osdev.org/viewtopic.php?f=1&t=33638

Alternatively have a look at this How can I create a PVH "kernel" that will be run by qemu

Hope this helps

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Harkirat