Recent

Author Topic: Does anyone know why this code cannot show the hello world in uefi?  (Read 1665 times)

Laksen

  • Hero Member
  • *****
  • Posts: 758
    • J-Software
Re: Does anyone know why this code cannot show the hello world in uefi?
« Reply #15 on: April 16, 2024, 06:01:04 pm »
Good question. If you insist on including binutils in the flow one thing that seems to work on both new and older versions is to always use gas and ld:
Code: [Select]
fpc -XPx86_64-w64-mingw32- -Aas -n -O4 -Si -Sc -Sg -Xd -CX -XXs -Px86_64 -Rintel -Twin64 -Us system.pas
fpc -XPx86_64-w64-mingw32- -Aas -n -O4 -Si -Sc -Sg -Xd -CX -XXs -Px86_64 -Rintel -Twin64 uefimain.pas
x86_64-w64-mingw32-ld --gc-sections --oformat pei-x86-64 uefimain.o uefi.o system.o -e efi_main -o MAIN.EFI

That works here with -Cg and -r as well:
Code: [Select]
fpc -XPx86_64-w64-mingw32- -Aas -n -O4 -Si -Sc -Sg -Xd -CX -XXs -Px86_64 -Rintel -Twin64 -Cg -Us system.pas
fpc -XPx86_64-w64-mingw32- -Aas -n -O4 -Si -Sc -Sg -Xd -CX -XXs -Px86_64 -Rintel -Twin64 -Cg uefimain.pas
x86_64-w64-mingw32-ld --gc-sections -r --oformat pei-x86-64 uefimain.o uefi.o system.o -e efi_main -o MAIN.EFI

TYDQ

  • Jr. Member
  • **
  • Posts: 66
Re: Does anyone know why this code cannot show the hello world in uefi?
« Reply #16 on: April 17, 2024, 06:39:17 am »
Good question. If you insist on including binutils in the flow one thing that seems to work on both new and older versions is to always use gas and ld:
Code: [Select]
fpc -XPx86_64-w64-mingw32- -Aas -n -O4 -Si -Sc -Sg -Xd -CX -XXs -Px86_64 -Rintel -Twin64 -Us system.pas
fpc -XPx86_64-w64-mingw32- -Aas -n -O4 -Si -Sc -Sg -Xd -CX -XXs -Px86_64 -Rintel -Twin64 uefimain.pas
x86_64-w64-mingw32-ld --gc-sections --oformat pei-x86-64 uefimain.o uefi.o system.o -e efi_main -o MAIN.EFI

That works here with -Cg and -r as well:
Code: [Select]
fpc -XPx86_64-w64-mingw32- -Aas -n -O4 -Si -Sc -Sg -Xd -CX -XXs -Px86_64 -Rintel -Twin64 -Cg -Us system.pas
fpc -XPx86_64-w64-mingw32- -Aas -n -O4 -Si -Sc -Sg -Xd -CX -XXs -Px86_64 -Rintel -Twin64 -Cg uefimain.pas
x86_64-w64-mingw32-ld --gc-sections -r --oformat pei-x86-64 uefimain.o uefi.o system.o -e efi_main -o MAIN.EFI
Thank you,I edited your shell code and my UEFI program successfully show "Hello UEFI!"(Must use x86_64-w64-mingw32-ld to link all object files to PE dll,and then use objcopy to create UEFI bootable file to execute in the bare UEFI machine).My edited code is based on the code your post,It Is:
Code: Bash  [Select][+][-]
  1.         fpc -XPx86_64-w64-mingw32- -Aas -n -O4 -Si -Sc -Sg -Xd -CX -XXs -Px86_64 -Rintel -Twin64 -Cg -Us system.pas
  2.         fpc -XPx86_64-w64-mingw32- -Aas -n -O4 -Si -Sc -Sg -Xd -CX -XXs -Px86_64 -Rintel -Twin64 -Cg uefimain.pas
  3.         x86_64-w64-mingw32-ld --gc-sections -shared -Bsymbolic -nostdlib --oformat pei-x86-64 uefimain.o uefi.o system.o -e efi_main -o main.dll
  4.         objcopy -I pei-x86-64 -O efi-app-x86_64 main.dll bootx64.efi
(-Bsymbolic and -nostdlib is optional)

 

TinyPortal © 2005-2018