On 09/26/2018 08:03 AM, Bin Meng wrote: > Per Microsoft PE Format documentation [1], PointerToSymbolTable and > NumberOfSymbols should be zero for an image in the COFF file header. > Currently the COFF file header is hardcoded on RISC-V and these two > members are not zero. > > This updates the hardcoded structure to clear these two members, as > well as setting the flag IMAGE_FILE_LOCAL_SYMS_STRIPPED so that we > can generate compliant *.efi images. > > [1] https://docs.microsoft.com/zh-cn/windows/desktop/Debug/pe-format > > Signed-off-by: Bin Meng <bmeng...@gmail.com> > --- > > arch/riscv/lib/crt0_riscv_efi.S | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/arch/riscv/lib/crt0_riscv_efi.S b/arch/riscv/lib/crt0_riscv_efi.S > index 18f61f5..6d61b3a 100644 > --- a/arch/riscv/lib/crt0_riscv_efi.S > +++ b/arch/riscv/lib/crt0_riscv_efi.S > @@ -41,13 +41,14 @@ coff_header: > .short 2 /* nr_sections */ > .long 0 /* TimeDateStamp */ > .long 0 /* PointerToSymbolTable */ > - .long 1 /* NumberOfSymbols */ > + .long 0 /* NumberOfSymbols */ > .short section_table - optional_header /* SizeOfOptionalHeader */ > /* > * Characteristics: IMAGE_FILE_DEBUG_STRIPPED | > - * IMAGE_FILE_EXECUTABLE_IMAGE | IMAGE_FILE_LINE_NUMS_STRIPPED > + * IMAGE_FILE_EXECUTABLE_IMAGE | IMAGE_FILE_LINE_NUMS_STRIPPED | > + * IMAGE_FILE_LOCAL_SYMS_STRIPPED > */
Thanks for your patch. I think your code misses to set IMAGE_FILE_32BIT_MACHINE in dependence of the bitness of the system. I would prefer if these constants were defined in asm-generic/pe.h: #define IMAGE_FILE_RELOCS_STRIPPED 0x0001 #define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002 #define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004 #define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008 #define IMAGE_FILE_AGGRESSIVE_WS_TRIM 0x0010 #define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020 /* Reserved 0x0040 */ #define IMAGE_FILE_BYTES_REVERSED_LO 0x0080 #define IMAGE_FILE_32BIT_MACHINE 0x0100 #define IMAGE_FILE_DEBUG_STRIPPED 0x0200 #define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400 #define IMAGE_FILE_NET_RUN_FROM_SWAP 0x0800 #define IMAGE_FILE_SYSTEM 0x1000 #define IMAGE_FILE_DLL 0x2000 #define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000 #define IMAGE_FILE_BYTES_REVERSED_HI 0x8000 These values of "characteristics" I found in the wild: Windows: memtest.efi: Characteristics 0x22 Windows: bootmgfw.efi: Characteristics 0x2022 GRUB: bootx64.efi: Characteristics 0x20e EDK2: Characteristics 0x10e Characteristics 0x2022 Characteristics 0x2102 Characteristics 0x2e Best regards Heinrich > - .short 0x206 > + .short 0x20e > optional_header: > .short 0x20b /* PE32+ format */ > .byte 0x02 /* MajorLinkerVersion */ > _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot