Opened 3 years ago

Last modified 3 years ago

#16824 new bug

riscv64 UEFI executable has inconsistent header

Reported by: JohnAZoidberg Owned by: nobody
Priority: normal Milestone: Unscheduled
Component: System/Boot Loader/EFI Version: R1/beta2
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

The riscv64 UEFI executable has inconsistent header and therefore cannot be loaded by the EDK2 implementation of UEFI. Apparently Uboot doesn't care about this detail but EDK2 validates it.

Specifically NumberOfRvaAndSizes should be the number of data directory entries. It is set to 6 but there are actually 16.

See source: https://git.haiku-os.org/haiku/tree/src/system/boot/platform/efi/arch/riscv64/crt0-efi-riscv64.S#n90 See PE executable spec: https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#optional-header-windows-specific-fields-image-only

This was probably a typo 0x6 -> 16 (or 0x10).

When fixing up the binary manually and changing the byte to 0x10 EDK2 can successfully load and start the executable.

This is the check of EDK2: https://github.com/tianocore/edk2/blob/stable/202011/MdePkg/Library/BasePeCoffLib/BasePeCoff.c#L313-L321 And the related issue in the riscv64 port of EDK2: https://github.com/riscv/riscv-edk2-platforms/issues/13

Change History (1)

comment:1 by diver, 3 years ago

Component: - GeneralSystem/Boot Loader/EFI
Keywords: riscv uefi removed
Note: See TracTickets for help on using tickets.