OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 3:20 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: qemu doesnt run .elf file, needs PVH ELF note
PostPosted: Mon May 24, 2021 12:22 pm 
Offline

Joined: Sun May 23, 2021 3:09 pm
Posts: 1
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:
qemu-system-i386 -kernel mykernel.elf
i get the error
Code:
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
Code:
-machine type=pc-i440fx-3.1
had qemu try to boot from rom indefinitely

how can i solve this problem? thank you in advance


Top
 Profile  
 
 Post subject: Re: qemu doesnt run .elf file, needs PVH ELF note
PostPosted: Wed May 26, 2021 4:14 am 
Offline
Member
Member
User avatar

Joined: Sun Mar 21, 2021 1:09 pm
Posts: 38
Location: current location
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:
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.

_________________
iustitiae iniustos iudicat


Top
 Profile  
 
 Post subject: Re: qemu doesnt run .elf file, needs PVH ELF note
PostPosted: Mon Aug 16, 2021 1:42 am 
Offline

Joined: Mon Aug 16, 2021 1:29 am
Posts: 1
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:
* 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)                                                                 
    }                                                                           
}                                                                               


Top
 Profile  
 
 Post subject: Re: qemu doesnt run .elf file, needs PVH ELF note
PostPosted: Thu Aug 19, 2021 6:06 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 44 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group