"correct" way to generate EFI binaries?
Alexander von Gluck IV
kallisti5@unixzen.com
Wed Jul 8 17:53:19 GMT 2020
July 8, 2020 12:23 PM, "Alexander von Gluck IV" <kallisti5@unixzen.com> wrote:
> 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)
>
lol. Whell there's the problem:
http://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=include/coff/arm.h;h=93ce49c1d05114b7d4b1cdb5b88fd8a1f4f0e68e;hb=HEAD#l78
78 #define ARMMAGIC 0xa00 /* I just made this up */
It looks like you have to use "wince" arm to get a semi-valid EFI booloader via ARMPEMAGIC?
http://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=bfd/coffcode.h;h=0910f918d13bf46394e3d3f3da40055fd2aa7a79;
hb=HEAD#l2754
Is there anyway to override the Pe machine type at build time?
Not sure of the correct fix here.
-- Alex
More information about the Binutils
mailing list