flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Compiler Internals > EFI possible bug

Author
Thread Post new topic Reply to topic
pfranz



Joined: 13 Jan 2007
Posts: 49
Location: Italy

EFI possible bug

I am trying to run .efi files in my Shell v2.2 on EFI 2.13. I boot the EFI shell, and some files run, some others report a load error like "command status: load error.
For example, this works:

Code:
format pe64 efi
entry main

include 'uefi.inc'

main:
 mov [efi_ptr],rdx

    uefi_call_wrapper ConOutOutputStringConOut_hello

mov qword [uefi_rsptmp],rsp
 and esp0xfffffff0
 sub rsp4*8              ; reserve space for 4 arguments

 lea rdx, [_hello2]
 mov rcx, [efi_ptr]
 mov rcx, [rcx + EFI_SYSTEM_TABLE.ConOut]
 call [rcx + SIMPLE_TEXT_OUTPUT_INTERFACE.OutputString]

mov qword rsp,[uefi_rsptmp]
exitmov eaxEFI_SUCCESS
    retn

section '.data' data readable writeable

_hello                                  du 'Hello World',13,10,0
_hello2      du 'Hello World 2',13,10,'(From EFI app written in FASM)',13,10,0

section '.reloc' fixups data discardable

but if you comment out the line with "uefi_call_wrapper" it doesn't load anymore. Adding DLL to format doesn't change that much.
I attach the file "uefi.inc"

edit by revolution: Added code tags


Description:
Download
Filename: uefi.inc
Filesize: 9.93 KB
Downloaded: 27 Time(s)

Post 22 Mar 2018, 15:00
View user's profile Send private message Reply with quote
pfranz



Joined: 13 Jan 2007
Posts: 49
Location: Italy

uefi version is 2.31 not 2.13
Post 23 Mar 2018, 05:40
View user's profile Send private message Reply with quote
pfranz



Joined: 13 Jan 2007
Posts: 49
Location: Italy

removed "efi" from format to test with .exe files. Windows 8.1 fails to load in exactly the same way UEFI does, so it is not a UEFI loader problem. It seems that fasm(1.73.02) generates incorrect pe32+ files with these kind of .text, .data, and .reloc sections(one of each type in that order, first two non empty)
Post 24 Mar 2018, 09:21
View user's profile Send private message Reply with quote
pfranz



Joined: 13 Jan 2007
Posts: 49
Location: Italy

tried fasm 1.71.34, same behaviour
Post 24 Mar 2018, 12:09
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6825
Location: Kraków, Poland

Isn't it simply a problem with an empty .reloc section. You may try one of the simple workarounds posted previously.
Post 24 Mar 2018, 17:35
View user's profile Send private message Visit poster's website Reply with quote
pfranz



Joined: 13 Jan 2007
Posts: 49
Location: Italy

thanks, it works.Still I d suggest you insert this workaround with a warning in fasm, as it is not a windows problem only
Post 24 Mar 2018, 21:07
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >

Forum Rules:
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 vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2018, Tomasz Grysztar.
Powered by rwasa.