public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH 1/1] riscv: Fix efi header size for RV32
@ 2020-11-12 13:43 Leo Liang
  2020-11-12 14:05 ` Heinrich Schuchardt
  0 siblings, 1 reply; 3+ messages in thread
From: Leo Liang @ 2020-11-12 13:43 UTC (permalink / raw)
  To: u-boot

Date: Thu, 12 Nov 2020 10:09:52 +0800
From: Leo Yu-Chi Liang <ycliang@andestech.com>
Subject: [PATCH 1/1] riscv: Fix efi header size for RV32

This patch depends on Atish's patch.
(https://patchwork.ozlabs.org/project/uboot/patch/20201013192331.3236458-1-atish.patra at wdc.com/)

Modify the size of the Optional Header "Windows-Specific Fields" to fit with the specification.
(https://docs.microsoft.com/en-us/windows/win32/debug/pe-format)

Signed-off-by: Leo Yu-Chi Liang <ycliang@andestech.com>
Cc: rick at andestech.com
Cc: alankao at andestech.com
Cc: atish.patra at wdc.com
Cc: xypron.glpk at gmx.de
Cc: bmeng.cn at gmail.com
---
 arch/riscv/lib/crt0_riscv_efi.S | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/arch/riscv/lib/crt0_riscv_efi.S b/arch/riscv/lib/crt0_riscv_efi.S
index 4aaa49ad07..48ff89553b 100644
--- a/arch/riscv/lib/crt0_riscv_efi.S
+++ b/arch/riscv/lib/crt0_riscv_efi.S
@@ -15,13 +15,13 @@
 #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	IMAGE_FILE_MACHINE_RISCV64
-#define PE_MAGIC        IMAGE_NT_OPTIONAL_HDR64_MAGIC
+#define PE_MAGIC    IMAGE_NT_OPTIONAL_HDR64_MAGIC
 #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	IMAGE_FILE_MACHINE_RISCV32
-#define PE_MAGIC        IMAGE_NT_OPTIONAL_HDR32_MAGIC
+#define PE_MAGIC    IMAGE_NT_OPTIONAL_HDR32_MAGIC
 #endif
 
 
@@ -50,7 +50,7 @@ coff_header:
 		 IMAGE_FILE_LOCAL_SYMS_STRIPPED | \
 		 IMAGE_FILE_DEBUG_STRIPPED)
 optional_header:
-	.short	PE_MAGIC			/* PE32+ format */
+	.short	PE_MAGIC			/* PE32(+) format */
 	.byte	0x02				/* MajorLinkerVersion */
 	.byte	0x14				/* MinorLinkerVersion */
 	.long	_edata - _start			/* SizeOfCode */
@@ -63,7 +63,11 @@ optional_header:
 #endif
 
 extra_header_fields:
+#if __riscv_xlen == 32
+	.long	0				/* ImageBase */
+#else
 	.quad	0				/* ImageBase */
+#endif
 	.long	0x20				/* SectionAlignment */
 	.long	0x8				/* FileAlignment */
 	.short	0				/* MajorOperatingSystemVersion */
@@ -83,10 +87,17 @@ extra_header_fields:
 	.long	0				/* CheckSum */
 	.short	IMAGE_SUBSYSTEM_EFI_APPLICATION /* Subsystem */
 	.short	0				/* DllCharacteristics */
+#if __riscv_xlen == 32
+	.long	0				/* SizeOfStackReserve */
+	.long	0				/* SizeOfStackCommit */
+	.long	0				/* SizeOfHeapReserve */
+	.long	0				/* SizeOfHeapCommit */
+#else
 	.quad	0				/* SizeOfStackReserve */
 	.quad	0				/* SizeOfStackCommit */
 	.quad	0				/* SizeOfHeapReserve */
 	.quad	0				/* SizeOfHeapCommit */
+#endif
 	.long	0				/* LoaderFlags */
 	.long	0x6				/* NumberOfRvaAndSizes */
 
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 1/1] riscv: Fix efi header size for RV32
  2020-11-12 13:43 [PATCH 1/1] riscv: Fix efi header size for RV32 Leo Liang
@ 2020-11-12 14:05 ` Heinrich Schuchardt
  2020-11-17  7:51   ` Leo Liang
  0 siblings, 1 reply; 3+ messages in thread
From: Heinrich Schuchardt @ 2020-11-12 14:05 UTC (permalink / raw)
  To: u-boot

On 12.11.20 14:43, Leo Liang wrote:
> Date: Thu, 12 Nov 2020 10:09:52 +0800
> From: Leo Yu-Chi Liang <ycliang@andestech.com>
> Subject: [PATCH 1/1] riscv: Fix efi header size for RV32
>
> This patch depends on Atish's patch.
> (https://patchwork.ozlabs.org/project/uboot/patch/20201013192331.3236458-1-atish.patra at wdc.com/)
>
> Modify the size of the Optional Header "Windows-Specific Fields" to fit with the specification.
> (https://docs.microsoft.com/en-us/windows/win32/debug/pe-format)

With both patches applied on RISCV-64 I get SizeOfOptionalHeader = 0xa0
instead of expected 0xf0.

Best regards

Heinrich

>
> Signed-off-by: Leo Yu-Chi Liang <ycliang@andestech.com>
> Cc: rick at andestech.com
> Cc: alankao at andestech.com
> Cc: atish.patra at wdc.com
> Cc: xypron.glpk at gmx.de
> Cc: bmeng.cn at gmail.com
> ---
>  arch/riscv/lib/crt0_riscv_efi.S | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/arch/riscv/lib/crt0_riscv_efi.S b/arch/riscv/lib/crt0_riscv_efi.S
> index 4aaa49ad07..48ff89553b 100644
> --- a/arch/riscv/lib/crt0_riscv_efi.S
> +++ b/arch/riscv/lib/crt0_riscv_efi.S
> @@ -15,13 +15,13 @@
>  #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	IMAGE_FILE_MACHINE_RISCV64
> -#define PE_MAGIC        IMAGE_NT_OPTIONAL_HDR64_MAGIC
> +#define PE_MAGIC    IMAGE_NT_OPTIONAL_HDR64_MAGIC
>  #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	IMAGE_FILE_MACHINE_RISCV32
> -#define PE_MAGIC        IMAGE_NT_OPTIONAL_HDR32_MAGIC
> +#define PE_MAGIC    IMAGE_NT_OPTIONAL_HDR32_MAGIC
>  #endif
>
>
> @@ -50,7 +50,7 @@ coff_header:
>  		 IMAGE_FILE_LOCAL_SYMS_STRIPPED | \
>  		 IMAGE_FILE_DEBUG_STRIPPED)
>  optional_header:
> -	.short	PE_MAGIC			/* PE32+ format */
> +	.short	PE_MAGIC			/* PE32(+) format */
>  	.byte	0x02				/* MajorLinkerVersion */
>  	.byte	0x14				/* MinorLinkerVersion */
>  	.long	_edata - _start			/* SizeOfCode */
> @@ -63,7 +63,11 @@ optional_header:
>  #endif
>
>  extra_header_fields:
> +#if __riscv_xlen == 32
> +	.long	0				/* ImageBase */
> +#else
>  	.quad	0				/* ImageBase */
> +#endif
>  	.long	0x20				/* SectionAlignment */
>  	.long	0x8				/* FileAlignment */
>  	.short	0				/* MajorOperatingSystemVersion */
> @@ -83,10 +87,17 @@ extra_header_fields:
>  	.long	0				/* CheckSum */
>  	.short	IMAGE_SUBSYSTEM_EFI_APPLICATION /* Subsystem */
>  	.short	0				/* DllCharacteristics */
> +#if __riscv_xlen == 32
> +	.long	0				/* SizeOfStackReserve */
> +	.long	0				/* SizeOfStackCommit */
> +	.long	0				/* SizeOfHeapReserve */
> +	.long	0				/* SizeOfHeapCommit */
> +#else
>  	.quad	0				/* SizeOfStackReserve */
>  	.quad	0				/* SizeOfStackCommit */
>  	.quad	0				/* SizeOfHeapReserve */
>  	.quad	0				/* SizeOfHeapCommit */
> +#endif
>  	.long	0				/* LoaderFlags */
>  	.long	0x6				/* NumberOfRvaAndSizes */
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/1] riscv: Fix efi header size for RV32
  2020-11-12 14:05 ` Heinrich Schuchardt
@ 2020-11-17  7:51   ` Leo Liang
  0 siblings, 0 replies; 3+ messages in thread
From: Leo Liang @ 2020-11-17  7:51 UTC (permalink / raw)
  To: u-boot

On Thu, Nov 12, 2020 at 03:05:23PM +0100, Heinrich Schuchardt wrote:
> On 12.11.20 14:43, Leo Liang wrote:
> > Date: Thu, 12 Nov 2020 10:09:52 +0800
> > From: Leo Yu-Chi Liang <ycliang@andestech.com>
> > Subject: [PATCH 1/1] riscv: Fix efi header size for RV32
> >
> > This patch depends on Atish's patch.
> > (https://patchwork.ozlabs.org/project/uboot/patch/20201013192331.3236458-1-atish.patra at wdc.com/)
> >
> > Modify the size of the Optional Header "Windows-Specific Fields" to fit with the specification.
> > (https://docs.microsoft.com/en-us/windows/win32/debug/pe-format)
> 
> With both patches applied on RISCV-64 I get SizeOfOptionalHeader = 0xa0
> instead of expected 0xf0.
> 
> Best regards
> 
> Heinrich
Hi Heinrich,

I will drop this patch and send a new patchset later.

Best regards,
Leo
> 
> >
> > Signed-off-by: Leo Yu-Chi Liang <ycliang@andestech.com>
> > Cc: rick at andestech.com
> > Cc: alankao at andestech.com
> > Cc: atish.patra at wdc.com
> > Cc: xypron.glpk at gmx.de
> > Cc: bmeng.cn at gmail.com
> > ---
> >  arch/riscv/lib/crt0_riscv_efi.S | 17 ++++++++++++++---
> >  1 file changed, 14 insertions(+), 3 deletions(-)
> >
> > diff --git a/arch/riscv/lib/crt0_riscv_efi.S b/arch/riscv/lib/crt0_riscv_efi.S
> > index 4aaa49ad07..48ff89553b 100644
> > --- a/arch/riscv/lib/crt0_riscv_efi.S
> > +++ b/arch/riscv/lib/crt0_riscv_efi.S
> > @@ -15,13 +15,13 @@
> >  #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	IMAGE_FILE_MACHINE_RISCV64
> > -#define PE_MAGIC        IMAGE_NT_OPTIONAL_HDR64_MAGIC
> > +#define PE_MAGIC    IMAGE_NT_OPTIONAL_HDR64_MAGIC
> >  #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	IMAGE_FILE_MACHINE_RISCV32
> > -#define PE_MAGIC        IMAGE_NT_OPTIONAL_HDR32_MAGIC
> > +#define PE_MAGIC    IMAGE_NT_OPTIONAL_HDR32_MAGIC
> >  #endif
> >
> >
> > @@ -50,7 +50,7 @@ coff_header:
> >  		 IMAGE_FILE_LOCAL_SYMS_STRIPPED | \
> >  		 IMAGE_FILE_DEBUG_STRIPPED)
> >  optional_header:
> > -	.short	PE_MAGIC			/* PE32+ format */
> > +	.short	PE_MAGIC			/* PE32(+) format */
> >  	.byte	0x02				/* MajorLinkerVersion */
> >  	.byte	0x14				/* MinorLinkerVersion */
> >  	.long	_edata - _start			/* SizeOfCode */
> > @@ -63,7 +63,11 @@ optional_header:
> >  #endif
> >
> >  extra_header_fields:
> > +#if __riscv_xlen == 32
> > +	.long	0				/* ImageBase */
> > +#else
> >  	.quad	0				/* ImageBase */
> > +#endif
> >  	.long	0x20				/* SectionAlignment */
> >  	.long	0x8				/* FileAlignment */
> >  	.short	0				/* MajorOperatingSystemVersion */
> > @@ -83,10 +87,17 @@ extra_header_fields:
> >  	.long	0				/* CheckSum */
> >  	.short	IMAGE_SUBSYSTEM_EFI_APPLICATION /* Subsystem */
> >  	.short	0				/* DllCharacteristics */
> > +#if __riscv_xlen == 32
> > +	.long	0				/* SizeOfStackReserve */
> > +	.long	0				/* SizeOfStackCommit */
> > +	.long	0				/* SizeOfHeapReserve */
> > +	.long	0				/* SizeOfHeapCommit */
> > +#else
> >  	.quad	0				/* SizeOfStackReserve */
> >  	.quad	0				/* SizeOfStackCommit */
> >  	.quad	0				/* SizeOfHeapReserve */
> >  	.quad	0				/* SizeOfHeapCommit */
> > +#endif
> >  	.long	0				/* LoaderFlags */
> >  	.long	0x6				/* NumberOfRvaAndSizes */
> >
> >
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-11-17  7:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-12 13:43 [PATCH 1/1] riscv: Fix efi header size for RV32 Leo Liang
2020-11-12 14:05 ` Heinrich Schuchardt
2020-11-17  7:51   ` Leo Liang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox