Commit a33a4efd2785dfda23216bc97e7b636cfd29b9f8

Authored by Bin Meng
Committed by Alexander Graf
1 parent fb8ebf52a4

riscv: efi: Generate Microsoft PE format compliant images

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.cn@gmail.com>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>

Showing 1 changed file with 6 additions and 6 deletions Side-by-side Diff

arch/riscv/lib/crt0_riscv_efi.S
... ... @@ -41,13 +41,13 @@
41 41 .short 2 /* nr_sections */
42 42 .long 0 /* TimeDateStamp */
43 43 .long 0 /* PointerToSymbolTable */
44   - .long 1 /* NumberOfSymbols */
  44 + .long 0 /* NumberOfSymbols */
45 45 .short section_table - optional_header /* SizeOfOptionalHeader */
46   - /*
47   - * Characteristics: IMAGE_FILE_DEBUG_STRIPPED |
48   - * IMAGE_FILE_EXECUTABLE_IMAGE | IMAGE_FILE_LINE_NUMS_STRIPPED
49   - */
50   - .short 0x206
  46 + /* Characteristics */
  47 + .short (IMAGE_FILE_EXECUTABLE_IMAGE | \
  48 + IMAGE_FILE_LINE_NUMS_STRIPPED | \
  49 + IMAGE_FILE_LOCAL_SYMS_STRIPPED | \
  50 + IMAGE_FILE_DEBUG_STRIPPED)
51 51 optional_header:
52 52 .short 0x20b /* PE32+ format */
53 53 .byte 0x02 /* MajorLinkerVersion */