* [U-Boot] [PATCH v2 1/6] efi_loader: Generate Microsoft PE format compliant images
@ 2018-10-02 14:39 Bin Meng
2018-10-02 14:39 ` [U-Boot] [PATCH v2 2/6] x86: efi: payload: Generate Microsoft PE format compliant image Bin Meng
` (6 more replies)
0 siblings, 7 replies; 22+ messages in thread
From: Bin Meng @ 2018-10-02 14:39 UTC (permalink / raw)
To: u-boot
Per Microsoft PE Format documentation [1], PointerToSymbolTable and
NumberOfSymbols should be zero for an image in the COFF file header.
Currently U-Boot is generating *.efi images (eg: helloworld.efi) in
which these two members are not zero.
This updates the build rules to tell linker to remove the symbol
table completely so that we can generate compliant *.efi images.
[1] https://docs.microsoft.com/zh-cn/windows/desktop/Debug/pe-format
Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
Changes in v2: None
scripts/Makefile.lib | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 4dceb6d..a4f16bb 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -381,7 +381,7 @@ $(obj)/%.efi: $(obj)/%_efi.so
quiet_cmd_efi_ld = LD $@
cmd_efi_ld = $(LD) -nostdlib -znocombreloc -T $(EFI_LDS_PATH) -shared \
- -Bsymbolic $^ -o $@
+ -Bsymbolic -s $^ -o $@
EFI_LDS_PATH = $(srctree)/arch/$(ARCH)/lib/$(EFI_LDS)
--
2.7.4
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [U-Boot] [PATCH v2 2/6] x86: efi: payload: Generate Microsoft PE format compliant image
2018-10-02 14:39 [U-Boot] [PATCH v2 1/6] efi_loader: Generate Microsoft PE format compliant images Bin Meng
@ 2018-10-02 14:39 ` Bin Meng
2018-10-02 18:20 ` Heinrich Schuchardt
2018-10-16 19:09 ` [U-Boot] [U-Boot, v2, " Alexander Graf
2018-10-02 14:39 ` [U-Boot] [PATCH v2 3/6] x86: efi: app: " Bin Meng
` (5 subsequent siblings)
6 siblings, 2 replies; 22+ messages in thread
From: Bin Meng @ 2018-10-02 14:39 UTC (permalink / raw)
To: u-boot
Per Microsoft PE Format documentation [1], PointerToSymbolTable and
NumberOfSymbols should be zero for an image in the COFF file header.
Currently U-Boot is generating u-boot-payload.efi image in which
these two members are not zero.
This updates the build rules to tell linker to remove the symbol
table completely so that we can generate compliant *.efi images.
[1] https://docs.microsoft.com/zh-cn/windows/desktop/Debug/pe-format
Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
---
Changes in v2: None
arch/x86/config.mk | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/config.mk b/arch/x86/config.mk
index cc94071..9ddf429 100644
--- a/arch/x86/config.mk
+++ b/arch/x86/config.mk
@@ -33,7 +33,7 @@ PLATFORM_LDFLAGS += -m $(if $(IS_32BIT),elf_i386,elf_x86_64)
# This is used in the top-level Makefile which does not include
# PLATFORM_LDFLAGS
-LDFLAGS_EFI_PAYLOAD := -Bsymbolic -Bsymbolic-functions -shared --no-undefined
+LDFLAGS_EFI_PAYLOAD := -Bsymbolic -Bsymbolic-functions -shared --no-undefined -s
OBJCOPYFLAGS_EFI := -j .text -j .sdata -j .data -j .dynamic -j .dynsym \
-j .rel -j .rela -j .reloc
--
2.7.4
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [U-Boot] [PATCH v2 3/6] x86: efi: app: Generate Microsoft PE format compliant image
2018-10-02 14:39 [U-Boot] [PATCH v2 1/6] efi_loader: Generate Microsoft PE format compliant images Bin Meng
2018-10-02 14:39 ` [U-Boot] [PATCH v2 2/6] x86: efi: payload: Generate Microsoft PE format compliant image Bin Meng
@ 2018-10-02 14:39 ` Bin Meng
2018-10-02 18:21 ` Heinrich Schuchardt
2018-10-16 19:10 ` [U-Boot] [U-Boot, v2, " Alexander Graf
2018-10-02 14:39 ` [U-Boot] [PATCH v2 4/6] pe.h: Add characteristics defines Bin Meng
` (4 subsequent siblings)
6 siblings, 2 replies; 22+ messages in thread
From: Bin Meng @ 2018-10-02 14:39 UTC (permalink / raw)
To: u-boot
Per Microsoft PE Format documentation [1], PointerToSymbolTable and
NumberOfSymbols should be zero for an image in the COFF file header.
Currently U-Boot is generating u-boot-app.efi in which these two
members are not zero.
This updates the build rules to tell linker to remove the symbol
table completely 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>
---
Changes in v2: None
arch/x86/config.mk | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/config.mk b/arch/x86/config.mk
index 9ddf429..68bec15 100644
--- a/arch/x86/config.mk
+++ b/arch/x86/config.mk
@@ -64,7 +64,7 @@ CPPFLAGS_crt0-efi-$(EFIARCH).o += $(CFLAGS_EFI)
ifeq ($(CONFIG_EFI_APP),y)
PLATFORM_CPPFLAGS += $(CFLAGS_EFI)
-LDFLAGS_FINAL += -znocombreloc -shared
+LDFLAGS_FINAL += -znocombreloc -shared -s
LDSCRIPT := $(LDSCRIPT_EFI)
else
--
2.7.4
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [U-Boot] [PATCH v2 4/6] pe.h: Add characteristics defines
2018-10-02 14:39 [U-Boot] [PATCH v2 1/6] efi_loader: Generate Microsoft PE format compliant images Bin Meng
2018-10-02 14:39 ` [U-Boot] [PATCH v2 2/6] x86: efi: payload: Generate Microsoft PE format compliant image Bin Meng
2018-10-02 14:39 ` [U-Boot] [PATCH v2 3/6] x86: efi: app: " Bin Meng
@ 2018-10-02 14:39 ` Bin Meng
2018-10-02 17:23 ` Heinrich Schuchardt
2018-10-16 19:09 ` [U-Boot] [U-Boot,v2,4/6] " Alexander Graf
2018-10-02 14:39 ` [U-Boot] [PATCH v2 5/6] arm: efi: Generate Microsoft PE format compliant images Bin Meng
` (3 subsequent siblings)
6 siblings, 2 replies; 22+ messages in thread
From: Bin Meng @ 2018-10-02 14:39 UTC (permalink / raw)
To: u-boot
This adds characteristics macros as defined by the Microsoft PE
Format documentation [1].
[1] https://docs.microsoft.com/zh-cn/windows/desktop/Debug/pe-format
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
---
Changes in v2:
- new patch to add characteristics defines in pe.h
include/asm-generic/pe.h | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/include/asm-generic/pe.h b/include/asm-generic/pe.h
index 9a8b5e8..faae534 100644
--- a/include/asm-generic/pe.h
+++ b/include/asm-generic/pe.h
@@ -11,6 +11,24 @@
#ifndef _ASM_PE_H
#define _ASM_PE_H
+/* Characteristics */
+#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
+
/* Subsystem type */
#define IMAGE_SUBSYSTEM_EFI_APPLICATION 10
#define IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11
--
2.7.4
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [U-Boot] [PATCH v2 5/6] arm: efi: Generate Microsoft PE format compliant images
2018-10-02 14:39 [U-Boot] [PATCH v2 1/6] efi_loader: Generate Microsoft PE format compliant images Bin Meng
` (2 preceding siblings ...)
2018-10-02 14:39 ` [U-Boot] [PATCH v2 4/6] pe.h: Add characteristics defines Bin Meng
@ 2018-10-02 14:39 ` Bin Meng
2018-10-02 17:20 ` Heinrich Schuchardt
2018-10-16 19:09 ` [U-Boot] [U-Boot, v2, " Alexander Graf
2018-10-02 14:39 ` [U-Boot] [PATCH v2 6/6] riscv: " Bin Meng
` (2 subsequent siblings)
6 siblings, 2 replies; 22+ messages in thread
From: Bin Meng @ 2018-10-02 14:39 UTC (permalink / raw)
To: u-boot
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 ARM 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>
---
Changes in v2:
- use macros in pe.h for the characteristics field
arch/arm/lib/crt0_aarch64_efi.S | 12 ++++++------
arch/arm/lib/crt0_arm_efi.S | 16 ++++++++--------
2 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/arch/arm/lib/crt0_aarch64_efi.S b/arch/arm/lib/crt0_aarch64_efi.S
index 0db4360..cb205fa 100644
--- a/arch/arm/lib/crt0_aarch64_efi.S
+++ b/arch/arm/lib/crt0_aarch64_efi.S
@@ -28,13 +28,13 @@ 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
- */
- .short 0x206
+ /* Characteristics */
+ .short (IMAGE_FILE_EXECUTABLE_IMAGE | \
+ IMAGE_FILE_LINE_NUMS_STRIPPED | \
+ IMAGE_FILE_LOCAL_SYMS_STRIPPED | \
+ IMAGE_FILE_DEBUG_STRIPPED)
optional_header:
.short 0x20b /* PE32+ format */
.byte 0x02 /* MajorLinkerVersion */
diff --git a/arch/arm/lib/crt0_arm_efi.S b/arch/arm/lib/crt0_arm_efi.S
index 23db49f..5470e2f 100644
--- a/arch/arm/lib/crt0_arm_efi.S
+++ b/arch/arm/lib/crt0_arm_efi.S
@@ -27,16 +27,16 @@ 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_32BIT_MACHINE |
- * IMAGE_FILE_DEBUG_STRIPPED | IMAGE_FILE_EXECUTABLE_IMAGE |
- * IMAGE_FILE_LINE_NUMS_STRIPPED
- */
- .short 0x306
+ /* Characteristics */
+ .short (IMAGE_FILE_EXECUTABLE_IMAGE | \
+ IMAGE_FILE_LINE_NUMS_STRIPPED | \
+ IMAGE_FILE_LOCAL_SYMS_STRIPPED | \
+ IMAGE_FILE_32BIT_MACHINE | \
+ IMAGE_FILE_DEBUG_STRIPPED)
optional_header:
- .short 0x10b /* PE32+ format */
+ .short 0x10b /* PE32 format */
.byte 0x02 /* MajorLinkerVersion */
.byte 0x14 /* MinorLinkerVersion */
.long _edata - _start /* SizeOfCode */
--
2.7.4
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [U-Boot] [PATCH v2 6/6] riscv: efi: Generate Microsoft PE format compliant images
2018-10-02 14:39 [U-Boot] [PATCH v2 1/6] efi_loader: Generate Microsoft PE format compliant images Bin Meng
` (3 preceding siblings ...)
2018-10-02 14:39 ` [U-Boot] [PATCH v2 5/6] arm: efi: Generate Microsoft PE format compliant images Bin Meng
@ 2018-10-02 14:39 ` Bin Meng
2018-10-02 18:19 ` Heinrich Schuchardt
2018-10-16 19:09 ` [U-Boot] [U-Boot, v2, " Alexander Graf
2018-10-16 14:36 ` [U-Boot] [PATCH v2 1/6] efi_loader: " Alexander Graf
2018-10-16 19:09 ` [U-Boot] [U-Boot, v2, " Alexander Graf
6 siblings, 2 replies; 22+ messages in thread
From: Bin Meng @ 2018-10-02 14:39 UTC (permalink / raw)
To: u-boot
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>
---
Changes in v2:
- use macros in pe.h for the characteristics field
arch/riscv/lib/crt0_riscv_efi.S | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/arch/riscv/lib/crt0_riscv_efi.S b/arch/riscv/lib/crt0_riscv_efi.S
index 18f61f5..b7b5329 100644
--- a/arch/riscv/lib/crt0_riscv_efi.S
+++ b/arch/riscv/lib/crt0_riscv_efi.S
@@ -41,13 +41,13 @@ 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
- */
- .short 0x206
+ /* Characteristics */
+ .short (IMAGE_FILE_EXECUTABLE_IMAGE | \
+ IMAGE_FILE_LINE_NUMS_STRIPPED | \
+ IMAGE_FILE_LOCAL_SYMS_STRIPPED | \
+ IMAGE_FILE_DEBUG_STRIPPED)
optional_header:
.short 0x20b /* PE32+ format */
.byte 0x02 /* MajorLinkerVersion */
--
2.7.4
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [U-Boot] [PATCH v2 5/6] arm: efi: Generate Microsoft PE format compliant images
2018-10-02 14:39 ` [U-Boot] [PATCH v2 5/6] arm: efi: Generate Microsoft PE format compliant images Bin Meng
@ 2018-10-02 17:20 ` Heinrich Schuchardt
2018-10-16 19:09 ` [U-Boot] [U-Boot, v2, " Alexander Graf
1 sibling, 0 replies; 22+ messages in thread
From: Heinrich Schuchardt @ 2018-10-02 17:20 UTC (permalink / raw)
To: u-boot
On 10/02/2018 04:39 PM, 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 ARM 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>
>
> ---
>
> Changes in v2:
> - use macros in pe.h for the characteristics field
>
> arch/arm/lib/crt0_aarch64_efi.S | 12 ++++++------
> arch/arm/lib/crt0_arm_efi.S | 16 ++++++++--------
> 2 files changed, 14 insertions(+), 14 deletions(-)
^ permalink raw reply [flat|nested] 22+ messages in thread
* [U-Boot] [PATCH v2 4/6] pe.h: Add characteristics defines
2018-10-02 14:39 ` [U-Boot] [PATCH v2 4/6] pe.h: Add characteristics defines Bin Meng
@ 2018-10-02 17:23 ` Heinrich Schuchardt
2018-10-16 19:09 ` [U-Boot] [U-Boot,v2,4/6] " Alexander Graf
1 sibling, 0 replies; 22+ messages in thread
From: Heinrich Schuchardt @ 2018-10-02 17:23 UTC (permalink / raw)
To: u-boot
On 10/02/2018 04:39 PM, Bin Meng wrote:
> This adds characteristics macros as defined by the Microsoft PE
> Format documentation [1].
>
> [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>
>
> ---
>
> Changes in v2:
> - new patch to add characteristics defines in pe.h
^ permalink raw reply [flat|nested] 22+ messages in thread
* [U-Boot] [PATCH v2 6/6] riscv: efi: Generate Microsoft PE format compliant images
2018-10-02 14:39 ` [U-Boot] [PATCH v2 6/6] riscv: " Bin Meng
@ 2018-10-02 18:19 ` Heinrich Schuchardt
2018-10-03 0:05 ` Bin Meng
2018-10-16 19:09 ` [U-Boot] [U-Boot, v2, " Alexander Graf
1 sibling, 1 reply; 22+ messages in thread
From: Heinrich Schuchardt @ 2018-10-02 18:19 UTC (permalink / raw)
To: u-boot
On 10/02/2018 04:39 PM, 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.cn@gmail.com>
>
> ---
>
> Changes in v2:
> - use macros in pe.h for the characteristics field
>
> arch/riscv/lib/crt0_riscv_efi.S | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/arch/riscv/lib/crt0_riscv_efi.S b/arch/riscv/lib/crt0_riscv_efi.S
> index 18f61f5..b7b5329 100644
> --- a/arch/riscv/lib/crt0_riscv_efi.S
> +++ b/arch/riscv/lib/crt0_riscv_efi.S
> @@ -41,13 +41,13 @@ coff_header:
> .short 2 /* nr_sections */
> .long 0 /* TimeDateStamp */
> .long 0 /* PointerToSymbolTable */
> - .long 1 /* NumberOfSymbols */
> + .long 0 /* NumberOfSymbols */
Looking at the top of the file it is meant both for 32bit and for 64bit
systems:
#if __riscv_xlen == 64
#define SIZE_LONG 8
#define SAVE_LONG(reg, idx) sd reg, (idx*SIZE_LONG)(sp)
#define LOAD_LONG(reg, idx) ld reg, (idx*SIZE_LONG)(sp)
#define PE_MACHINE 0x5064
#else
#define SIZE_LONG 4
#define SAVE_LONG(reg, idx) sw reg, (idx*SIZE_LONG)(sp)
#define LOAD_LONG(reg, idx) lw reg, (idx*SIZE_LONG)(sp)
#define PE_MACHINE 0x5032
#endif
But for 32bit and 64bit we cannot use the same values of characteristics
and we need different optional header formats.
For the ARM and the x86 architecture this has resulted in separate files
crt0*.S - one for 32bit, the other for 64bit.
Shouldn't we go the same way for RISC-V?
> .short section_table - optional_header /* SizeOfOptionalHeader */
> - /*
> - * Characteristics: IMAGE_FILE_DEBUG_STRIPPED |
> - * IMAGE_FILE_EXECUTABLE_IMAGE | IMAGE_FILE_LINE_NUMS_STRIPPED
> - */
> - .short 0x206
> + /* Characteristics */
> + .short (IMAGE_FILE_EXECUTABLE_IMAGE | \
> + IMAGE_FILE_LINE_NUMS_STRIPPED | \
> + IMAGE_FILE_LOCAL_SYMS_STRIPPED | \
> + IMAGE_FILE_DEBUG_STRIPPED)
These values suit 64bit only.
As currently we only have a defconfig for a 64bit system -
ax25-ae350_defconfig - let's merge this patch.
@Bin:
Your "riscv: Add QEMU virt board support" patch series adds a 32bit
board. Please, consider adding a separate 32bit crt0*.S there.
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> optional_header:
> .short 0x20b /* PE32+ format */
> .byte 0x02 /* MajorLinkerVersion */
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* [U-Boot] [PATCH v2 2/6] x86: efi: payload: Generate Microsoft PE format compliant image
2018-10-02 14:39 ` [U-Boot] [PATCH v2 2/6] x86: efi: payload: Generate Microsoft PE format compliant image Bin Meng
@ 2018-10-02 18:20 ` Heinrich Schuchardt
2018-10-16 19:09 ` [U-Boot] [U-Boot, v2, " Alexander Graf
1 sibling, 0 replies; 22+ messages in thread
From: Heinrich Schuchardt @ 2018-10-02 18:20 UTC (permalink / raw)
To: u-boot
On 10/02/2018 04:39 PM, Bin Meng wrote:
> Per Microsoft PE Format documentation [1], PointerToSymbolTable and
> NumberOfSymbols should be zero for an image in the COFF file header.
> Currently U-Boot is generating u-boot-payload.efi image in which
> these two members are not zero.
>
> This updates the build rules to tell linker to remove the symbol
> table completely so that we can generate compliant *.efi images.
>
> [1] https://docs.microsoft.com/zh-cn/windows/desktop/Debug/pe-format
>
> Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
^ permalink raw reply [flat|nested] 22+ messages in thread
* [U-Boot] [PATCH v2 3/6] x86: efi: app: Generate Microsoft PE format compliant image
2018-10-02 14:39 ` [U-Boot] [PATCH v2 3/6] x86: efi: app: " Bin Meng
@ 2018-10-02 18:21 ` Heinrich Schuchardt
2018-10-16 19:10 ` [U-Boot] [U-Boot, v2, " Alexander Graf
1 sibling, 0 replies; 22+ messages in thread
From: Heinrich Schuchardt @ 2018-10-02 18:21 UTC (permalink / raw)
To: u-boot
On 10/02/2018 04:39 PM, Bin Meng wrote:
> Per Microsoft PE Format documentation [1], PointerToSymbolTable and
> NumberOfSymbols should be zero for an image in the COFF file header.
> Currently U-Boot is generating u-boot-app.efi in which these two
> members are not zero.
>
> This updates the build rules to tell linker to remove the symbol
> table completely 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>
^ permalink raw reply [flat|nested] 22+ messages in thread
* [U-Boot] [PATCH v2 6/6] riscv: efi: Generate Microsoft PE format compliant images
2018-10-02 18:19 ` Heinrich Schuchardt
@ 2018-10-03 0:05 ` Bin Meng
0 siblings, 0 replies; 22+ messages in thread
From: Bin Meng @ 2018-10-03 0:05 UTC (permalink / raw)
To: u-boot
Hi Heinrich,
On Wed, Oct 3, 2018 at 2:19 AM Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> On 10/02/2018 04:39 PM, 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.cn@gmail.com>
> >
> > ---
> >
> > Changes in v2:
> > - use macros in pe.h for the characteristics field
> >
> > arch/riscv/lib/crt0_riscv_efi.S | 12 ++++++------
> > 1 file changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/arch/riscv/lib/crt0_riscv_efi.S b/arch/riscv/lib/crt0_riscv_efi.S
> > index 18f61f5..b7b5329 100644
> > --- a/arch/riscv/lib/crt0_riscv_efi.S
> > +++ b/arch/riscv/lib/crt0_riscv_efi.S
> > @@ -41,13 +41,13 @@ coff_header:
> > .short 2 /* nr_sections */
> > .long 0 /* TimeDateStamp */
> > .long 0 /* PointerToSymbolTable */
> > - .long 1 /* NumberOfSymbols */
> > + .long 0 /* NumberOfSymbols */
>
> Looking at the top of the file it is meant both for 32bit and for 64bit
> systems:
>
> #if __riscv_xlen == 64
> #define SIZE_LONG 8
> #define SAVE_LONG(reg, idx) sd reg, (idx*SIZE_LONG)(sp)
> #define LOAD_LONG(reg, idx) ld reg, (idx*SIZE_LONG)(sp)
> #define PE_MACHINE 0x5064
> #else
> #define SIZE_LONG 4
> #define SAVE_LONG(reg, idx) sw reg, (idx*SIZE_LONG)(sp)
> #define LOAD_LONG(reg, idx) lw reg, (idx*SIZE_LONG)(sp)
> #define PE_MACHINE 0x5032
> #endif
>
> But for 32bit and 64bit we cannot use the same values of characteristics
> and we need different optional header formats.
>
> For the ARM and the x86 architecture this has resulted in separate files
> crt0*.S - one for 32bit, the other for 64bit.
>
> Shouldn't we go the same way for RISC-V?
>
You observation is correct. We should use separate files to support
32-bit and 64-bit.
> > .short section_table - optional_header /* SizeOfOptionalHeader */
> > - /*
> > - * Characteristics: IMAGE_FILE_DEBUG_STRIPPED |
> > - * IMAGE_FILE_EXECUTABLE_IMAGE | IMAGE_FILE_LINE_NUMS_STRIPPED
> > - */
> > - .short 0x206
> > + /* Characteristics */
> > + .short (IMAGE_FILE_EXECUTABLE_IMAGE | \
> > + IMAGE_FILE_LINE_NUMS_STRIPPED | \
> > + IMAGE_FILE_LOCAL_SYMS_STRIPPED | \
> > + IMAGE_FILE_DEBUG_STRIPPED)
>
> These values suit 64bit only.
>
> As currently we only have a defconfig for a 64bit system -
> ax25-ae350_defconfig - let's merge this patch.
>
> @Bin:
> Your "riscv: Add QEMU virt board support" patch series adds a 32bit
> board. Please, consider adding a separate 32bit crt0*.S there.
>
Sure, will do it in coming patches.
> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
>
> > optional_header:
> > .short 0x20b /* PE32+ format */
> > .byte 0x02 /* MajorLinkerVersion */
> >
Regards,
Bin
^ permalink raw reply [flat|nested] 22+ messages in thread
* [U-Boot] [PATCH v2 1/6] efi_loader: Generate Microsoft PE format compliant images
2018-10-02 14:39 [U-Boot] [PATCH v2 1/6] efi_loader: Generate Microsoft PE format compliant images Bin Meng
` (4 preceding siblings ...)
2018-10-02 14:39 ` [U-Boot] [PATCH v2 6/6] riscv: " Bin Meng
@ 2018-10-16 14:36 ` Alexander Graf
2018-10-16 15:37 ` Bin Meng
2018-10-16 19:09 ` [U-Boot] [U-Boot, v2, " Alexander Graf
6 siblings, 1 reply; 22+ messages in thread
From: Alexander Graf @ 2018-10-16 14:36 UTC (permalink / raw)
To: u-boot
On 02.10.18 16:39, Bin Meng wrote:
> Per Microsoft PE Format documentation [1], PointerToSymbolTable and
> NumberOfSymbols should be zero for an image in the COFF file header.
> Currently U-Boot is generating *.efi images (eg: helloworld.efi) in
> which these two members are not zero.
>
> This updates the build rules to tell linker to remove the symbol
> table completely so that we can generate compliant *.efi images.
>
> [1] https://docs.microsoft.com/zh-cn/windows/desktop/Debug/pe-format
>
> Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
I couldn't find a cover letter for this series, so I'll just reply here
for the whole set:
Which tree do you want to have this applied through?
Alex
^ permalink raw reply [flat|nested] 22+ messages in thread
* [U-Boot] [PATCH v2 1/6] efi_loader: Generate Microsoft PE format compliant images
2018-10-16 14:36 ` [U-Boot] [PATCH v2 1/6] efi_loader: " Alexander Graf
@ 2018-10-16 15:37 ` Bin Meng
2018-10-16 15:40 ` Alexander Graf
0 siblings, 1 reply; 22+ messages in thread
From: Bin Meng @ 2018-10-16 15:37 UTC (permalink / raw)
To: u-boot
Hi Alex,
On Tue, Oct 16, 2018 at 10:36 PM Alexander Graf <agraf@suse.de> wrote:
>
>
>
> On 02.10.18 16:39, Bin Meng wrote:
> > Per Microsoft PE Format documentation [1], PointerToSymbolTable and
> > NumberOfSymbols should be zero for an image in the COFF file header.
> > Currently U-Boot is generating *.efi images (eg: helloworld.efi) in
> > which these two members are not zero.
> >
> > This updates the build rules to tell linker to remove the symbol
> > table completely so that we can generate compliant *.efi images.
> >
> > [1] https://docs.microsoft.com/zh-cn/windows/desktop/Debug/pe-format
> >
> > Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> > Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> > Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
>
> I couldn't find a cover letter for this series, so I'll just reply here
> for the whole set:
>
> Which tree do you want to have this applied through?
>
There is no cover letter for this series. In patchwork, this series is
assigned to you so I assume this should go through the efi tree.
Regards,
Bin
^ permalink raw reply [flat|nested] 22+ messages in thread
* [U-Boot] [PATCH v2 1/6] efi_loader: Generate Microsoft PE format compliant images
2018-10-16 15:37 ` Bin Meng
@ 2018-10-16 15:40 ` Alexander Graf
2018-10-16 15:51 ` Bin Meng
0 siblings, 1 reply; 22+ messages in thread
From: Alexander Graf @ 2018-10-16 15:40 UTC (permalink / raw)
To: u-boot
On 16.10.18 17:37, Bin Meng wrote:
> Hi Alex,
>
> On Tue, Oct 16, 2018 at 10:36 PM Alexander Graf <agraf@suse.de> wrote:
>>
>>
>>
>> On 02.10.18 16:39, Bin Meng wrote:
>>> Per Microsoft PE Format documentation [1], PointerToSymbolTable and
>>> NumberOfSymbols should be zero for an image in the COFF file header.
>>> Currently U-Boot is generating *.efi images (eg: helloworld.efi) in
>>> which these two members are not zero.
>>>
>>> This updates the build rules to tell linker to remove the symbol
>>> table completely so that we can generate compliant *.efi images.
>>>
>>> [1] https://docs.microsoft.com/zh-cn/windows/desktop/Debug/pe-format
>>>
>>> Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
>>> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
>>> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
>>
>> I couldn't find a cover letter for this series, so I'll just reply here
>> for the whole set:
>>
>> Which tree do you want to have this applied through?
>>
>
> There is no cover letter for this series. In patchwork, this series is
> assigned to you so I assume this should go through the efi tree.
Ok, in that case, are you intending to send a follow-up patch for
riscv32 or do you want to do a v3?
Alex
^ permalink raw reply [flat|nested] 22+ messages in thread
* [U-Boot] [PATCH v2 1/6] efi_loader: Generate Microsoft PE format compliant images
2018-10-16 15:40 ` Alexander Graf
@ 2018-10-16 15:51 ` Bin Meng
0 siblings, 0 replies; 22+ messages in thread
From: Bin Meng @ 2018-10-16 15:51 UTC (permalink / raw)
To: u-boot
Hi Alex,
On Tue, Oct 16, 2018 at 11:40 PM Alexander Graf <agraf@suse.de> wrote:
>
>
>
> On 16.10.18 17:37, Bin Meng wrote:
> > Hi Alex,
> >
> > On Tue, Oct 16, 2018 at 10:36 PM Alexander Graf <agraf@suse.de> wrote:
> >>
> >>
> >>
> >> On 02.10.18 16:39, Bin Meng wrote:
> >>> Per Microsoft PE Format documentation [1], PointerToSymbolTable and
> >>> NumberOfSymbols should be zero for an image in the COFF file header.
> >>> Currently U-Boot is generating *.efi images (eg: helloworld.efi) in
> >>> which these two members are not zero.
> >>>
> >>> This updates the build rules to tell linker to remove the symbol
> >>> table completely so that we can generate compliant *.efi images.
> >>>
> >>> [1] https://docs.microsoft.com/zh-cn/windows/desktop/Debug/pe-format
> >>>
> >>> Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> >>> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> >>> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> >>
> >> I couldn't find a cover letter for this series, so I'll just reply here
> >> for the whole set:
> >>
> >> Which tree do you want to have this applied through?
> >>
> >
> > There is no cover letter for this series. In patchwork, this series is
> > assigned to you so I assume this should go through the efi tree.
>
> Ok, in that case, are you intending to send a follow-up patch for
> riscv32 or do you want to do a v3?
>
No, the riscv32 is totally unrelated. It can be a separate patch (series).
Regards,
Bin
^ permalink raw reply [flat|nested] 22+ messages in thread
* [U-Boot] [U-Boot, v2, 5/6] arm: efi: Generate Microsoft PE format compliant images
2018-10-02 14:39 ` [U-Boot] [PATCH v2 5/6] arm: efi: Generate Microsoft PE format compliant images Bin Meng
2018-10-02 17:20 ` Heinrich Schuchardt
@ 2018-10-16 19:09 ` Alexander Graf
1 sibling, 0 replies; 22+ messages in thread
From: Alexander Graf @ 2018-10-16 19:09 UTC (permalink / raw)
To: u-boot
> 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 ARM 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>
Thanks, applied to efi-next
Alex
^ permalink raw reply [flat|nested] 22+ messages in thread
* [U-Boot] [U-Boot, v2, 6/6] riscv: efi: Generate Microsoft PE format compliant images
2018-10-02 14:39 ` [U-Boot] [PATCH v2 6/6] riscv: " Bin Meng
2018-10-02 18:19 ` Heinrich Schuchardt
@ 2018-10-16 19:09 ` Alexander Graf
1 sibling, 0 replies; 22+ messages in thread
From: Alexander Graf @ 2018-10-16 19:09 UTC (permalink / raw)
To: u-boot
> 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>
Thanks, applied to efi-next
Alex
^ permalink raw reply [flat|nested] 22+ messages in thread
* [U-Boot] [U-Boot, v2, 2/6] x86: efi: payload: Generate Microsoft PE format compliant image
2018-10-02 14:39 ` [U-Boot] [PATCH v2 2/6] x86: efi: payload: Generate Microsoft PE format compliant image Bin Meng
2018-10-02 18:20 ` Heinrich Schuchardt
@ 2018-10-16 19:09 ` Alexander Graf
1 sibling, 0 replies; 22+ messages in thread
From: Alexander Graf @ 2018-10-16 19:09 UTC (permalink / raw)
To: u-boot
> Per Microsoft PE Format documentation [1], PointerToSymbolTable and
> NumberOfSymbols should be zero for an image in the COFF file header.
> Currently U-Boot is generating u-boot-payload.efi image in which
> these two members are not zero.
>
> This updates the build rules to tell linker to remove the symbol
> table completely so that we can generate compliant *.efi images.
>
> [1] https://docs.microsoft.com/zh-cn/windows/desktop/Debug/pe-format
>
> Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Thanks, applied to efi-next
Alex
^ permalink raw reply [flat|nested] 22+ messages in thread
* [U-Boot] [U-Boot,v2,4/6] pe.h: Add characteristics defines
2018-10-02 14:39 ` [U-Boot] [PATCH v2 4/6] pe.h: Add characteristics defines Bin Meng
2018-10-02 17:23 ` Heinrich Schuchardt
@ 2018-10-16 19:09 ` Alexander Graf
1 sibling, 0 replies; 22+ messages in thread
From: Alexander Graf @ 2018-10-16 19:09 UTC (permalink / raw)
To: u-boot
> This adds characteristics macros as defined by the Microsoft PE
> Format documentation [1].
>
> [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>
Thanks, applied to efi-next
Alex
^ permalink raw reply [flat|nested] 22+ messages in thread
* [U-Boot] [U-Boot, v2, 1/6] efi_loader: Generate Microsoft PE format compliant images
2018-10-02 14:39 [U-Boot] [PATCH v2 1/6] efi_loader: Generate Microsoft PE format compliant images Bin Meng
` (5 preceding siblings ...)
2018-10-16 14:36 ` [U-Boot] [PATCH v2 1/6] efi_loader: " Alexander Graf
@ 2018-10-16 19:09 ` Alexander Graf
6 siblings, 0 replies; 22+ messages in thread
From: Alexander Graf @ 2018-10-16 19:09 UTC (permalink / raw)
To: u-boot
> Per Microsoft PE Format documentation [1], PointerToSymbolTable and
> NumberOfSymbols should be zero for an image in the COFF file header.
> Currently U-Boot is generating *.efi images (eg: helloworld.efi) in
> which these two members are not zero.
>
> This updates the build rules to tell linker to remove the symbol
> table completely so that we can generate compliant *.efi images.
>
> [1] https://docs.microsoft.com/zh-cn/windows/desktop/Debug/pe-format
>
> Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Thanks, applied to efi-next
Alex
^ permalink raw reply [flat|nested] 22+ messages in thread
* [U-Boot] [U-Boot, v2, 3/6] x86: efi: app: Generate Microsoft PE format compliant image
2018-10-02 14:39 ` [U-Boot] [PATCH v2 3/6] x86: efi: app: " Bin Meng
2018-10-02 18:21 ` Heinrich Schuchardt
@ 2018-10-16 19:10 ` Alexander Graf
1 sibling, 0 replies; 22+ messages in thread
From: Alexander Graf @ 2018-10-16 19:10 UTC (permalink / raw)
To: u-boot
> Per Microsoft PE Format documentation [1], PointerToSymbolTable and
> NumberOfSymbols should be zero for an image in the COFF file header.
> Currently U-Boot is generating u-boot-app.efi in which these two
> members are not zero.
>
> This updates the build rules to tell linker to remove the symbol
> table completely 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>
Thanks, applied to efi-next
Alex
^ permalink raw reply [flat|nested] 22+ messages in thread
end of thread, other threads:[~2018-10-16 19:10 UTC | newest]
Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-02 14:39 [U-Boot] [PATCH v2 1/6] efi_loader: Generate Microsoft PE format compliant images Bin Meng
2018-10-02 14:39 ` [U-Boot] [PATCH v2 2/6] x86: efi: payload: Generate Microsoft PE format compliant image Bin Meng
2018-10-02 18:20 ` Heinrich Schuchardt
2018-10-16 19:09 ` [U-Boot] [U-Boot, v2, " Alexander Graf
2018-10-02 14:39 ` [U-Boot] [PATCH v2 3/6] x86: efi: app: " Bin Meng
2018-10-02 18:21 ` Heinrich Schuchardt
2018-10-16 19:10 ` [U-Boot] [U-Boot, v2, " Alexander Graf
2018-10-02 14:39 ` [U-Boot] [PATCH v2 4/6] pe.h: Add characteristics defines Bin Meng
2018-10-02 17:23 ` Heinrich Schuchardt
2018-10-16 19:09 ` [U-Boot] [U-Boot,v2,4/6] " Alexander Graf
2018-10-02 14:39 ` [U-Boot] [PATCH v2 5/6] arm: efi: Generate Microsoft PE format compliant images Bin Meng
2018-10-02 17:20 ` Heinrich Schuchardt
2018-10-16 19:09 ` [U-Boot] [U-Boot, v2, " Alexander Graf
2018-10-02 14:39 ` [U-Boot] [PATCH v2 6/6] riscv: " Bin Meng
2018-10-02 18:19 ` Heinrich Schuchardt
2018-10-03 0:05 ` Bin Meng
2018-10-16 19:09 ` [U-Boot] [U-Boot, v2, " Alexander Graf
2018-10-16 14:36 ` [U-Boot] [PATCH v2 1/6] efi_loader: " Alexander Graf
2018-10-16 15:37 ` Bin Meng
2018-10-16 15:40 ` Alexander Graf
2018-10-16 15:51 ` Bin Meng
2018-10-16 19:09 ` [U-Boot] [U-Boot, v2, " Alexander Graf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.