Page 1 of 1
qemu doesnt run .elf file, needs PVH ELF note
Posted: Mon May 24, 2021 12:22 pm
by thegremlin
I am following Zesterer's Barebones tutorial (
https://wiki.osdev.org/User:Zesterer/Bare_Bones)and i am now trying to run the .elf file produced using qemu
Whenever i run the command
Code: Select all
qemu-system-i386 -kernel mykernel.elf
i get the error
Code: Select all
qemu-system-i386: Error loading uncompressed kernel without PVH ELF Note
while i thing that i understand why this is happening, i do not know how to fix it, and the suggestions i found online about using the flag
had qemu try to boot from rom indefinitely
how can i solve this problem? thank you in advance
Re: qemu doesnt run .elf file, needs PVH ELF note
Posted: Wed May 26, 2021 4:14 am
by acccidiccc
is your kernel mulitboot compliant? qemu caused the same message when I gave it a non multiboot kernel. I can replicate your problem with my own non multiboot compilant kernel. apparently pvh is a boot protocol. QEMU probably only supports some boot protocols. apparently somebody got the same message with the linux kernel, which uses its own protocol.
Code: Select all
grub-file --is-x86-multiboot mykernel.elf
put it in the makefile. if it cause an error 1. it is not compliant. did you copy paste or type from hand. maybe a typo?
probably this will return a negative code. if not, that is pretty weird.
Re: qemu doesnt run .elf file, needs PVH ELF note
Posted: Mon Aug 16, 2021 1:42 am
by f23yg
I tried to slove this problem by modifying the link scritp file
linker.ld and everything worked fine. If anybody know why, please tell me.I just simply move multiboot header from rodata area to text area. The version of binutil and gcc is 2.37 and 11.2.0 respectively.
Code: Select all
* The bootloader will start execution at the symbol designated as the entry point. In this case, that's 'start' (defined in start.s) */
ENTRY(start)
/* Tell the linker part of the compiler where the various sections of the kernel will be put in the final kernel executable. */
SECTIONS
{
/* Begin putting sections at 1 Megabyte (1M), a good place for kernels to be loaded at by the bootloader. */
/* This is because memory below 1 Megabyte is reserved for other x86-related things, so we can't use it */
. = 1M;
/* We align all sections in the executable at multiples of 4 Kilobytes (4K). This will become useful later in development when we add paging */
/* First put the multiboot header, as it's required to be near the start of the executable otherwise the bootloader won't find it */
/* The Multiboot header is Read-Only data, so we can put it in a '.rodata' section. */
.text BLOCK(4K) : ALIGN(4K)
{
*(.multiboot)
*(.text)
}
/* Read-only data. */
.rodata BLOCK(4K) : ALIGN(4K)
{
*(.rodata)
}
/* Read-write data (initialized) */
.data BLOCK(4K) : ALIGN(4K)
{
*(.data)
}
/* Read-write data (uninitialized) and stack */
.bss BLOCK(4K) : ALIGN(4K)
{
*(COMMON)
*(.bss)
}
}
Re: qemu doesnt run .elf file, needs PVH ELF note
Posted: Thu Aug 19, 2021 6:06 pm
by Octocontrabass
f23yg wrote:If anybody know why, please tell me.
The Multiboot header must be contained completely within the first 8192 bytes of the OS image. When you tried to move it to the .rodata section, it ended up outside the first 8192 bytes, so QEMU couldn't find it.