"correct" way to generate EFI binaries?

Alexander von Gluck IV kallisti5@unixzen.com
Wed Jul 8 17:23:12 GMT 2020


July 8, 2020 8:37 AM, "Alexander von Gluck IV" <kallisti5@unixzen.com> wrote:
>
> Hello!
> 
> I see a lot of (external blog) documentation around using the
> efi-app-x86_64 output target for EFI binaries.
> 
> ...
>
> The (undocumented) efi-app-* target doesn't seem to exist
> in bfd for any other architectures. (likely leading to this confusion.)
> 
> I've been doing some digging, and it *appears* that the following
> is what folks are "supposed" to be using:
> 
> x86_64 --output-target=pei-x86-64 --subsystem=efi-app
> arm --output-target=pei-arm-little --subsystem=efi-app
> aarch64 ( no Pe in bfd :-( )
> riscv64 ( no Pe in bfd :-( )
> 
> However, EFI loaders generated with the above flags never
> seem to boot properly and have screwy headers:

Scratch that. x86_64 EFI is working in this model (just missing -j's)

It seems like pei-arm-little + efi-app is simply broken in binutils?
(2.32)

> file arm/release/system/boot/efi/haiku_loader.efi
> haiku_loader.efi: PE Unknown PE signature 0x742e, for MS Windows

efi_analyzer/efianalyze arm/release/system/boot/efi/haiku_loader.efi

Offset to PE: 0x80
Machine type: 0x0a00, Unknown machine type
PointerToSymbolTable should be 0.
NumberOfSymbols should be 0.
Characteristics: 0x0105
  * Relocation information was stripped from the file.
  * COFF line numbers were stripped from the file.
  * The computer supports 32-bit words.
Wrong OHS Magic 0x742e
Image type: (crash in EFI analyzer tool)


 -- Alex


More information about the Binutils mailing list