aboutsummaryrefslogtreecommitdiff
path: root/arch/riscv/lib
diff options
context:
space:
mode:
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>2022-01-14 21:40:15 +0100
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>2022-01-15 10:57:22 +0100
commit9ef5ccaa712238f4ccd3c55f8a7ae6ca28a5a5bf (patch)
tree1dffd5c549da54da3d08f1be67adc6a0183f9fd9 /arch/riscv/lib
parentdfbc2be47edcb5190d161390b50d2dcc5086710e (diff)
downloadu-boot-9ef5ccaa712238f4ccd3c55f8a7ae6ca28a5a5bf.zip
u-boot-9ef5ccaa712238f4ccd3c55f8a7ae6ca28a5a5bf.tar.gz
u-boot-9ef5ccaa712238f4ccd3c55f8a7ae6ca28a5a5bf.tar.bz2
efi_loader: fix SectionAlignment, FileAlignment
The alignment of sections in the EFI binaries generated by U-Boot is incorrect. According to the PE-COFF specification [1] the minimum value for FileAlignment is 512. If the value of SectionAlignment is less then the page size, it must equal FileAlignment. Let's set both values to 512 for the ARM and RISC-V architectures. [1] https://docs.microsoft.com/en-us/windows/win32/debug/pe-format Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Diffstat (limited to 'arch/riscv/lib')
-rw-r--r--arch/riscv/lib/crt0_riscv_efi.S5
-rw-r--r--arch/riscv/lib/elf_riscv32_efi.lds4
-rw-r--r--arch/riscv/lib/elf_riscv64_efi.lds4
3 files changed, 7 insertions, 6 deletions
diff --git a/arch/riscv/lib/crt0_riscv_efi.S b/arch/riscv/lib/crt0_riscv_efi.S
index 3e62e8e..a01e08a 100644
--- a/arch/riscv/lib/crt0_riscv_efi.S
+++ b/arch/riscv/lib/crt0_riscv_efi.S
@@ -71,8 +71,8 @@ extra_header_fields:
#else
.quad 0 /* ImageBase */
#endif
- .long 0x20 /* SectionAlignment */
- .long 0x8 /* FileAlignment */
+ .long 0x200 /* SectionAlignment */
+ .long 0x200 /* FileAlignment */
.short 0 /* MajorOperatingSystemVersion */
.short 0 /* MinorOperatingSystemVersion */
.short 1 /* MajorImageVersion */
@@ -148,6 +148,7 @@ section_table:
.short 0 /* NumberOfLineNumbers (0 for executables) */
.long 0xe0500020 /* Characteristics (section flags) */
+ .align 9
_start:
addi sp, sp, -(SIZE_LONG * 3)
SAVE_LONG(a0, 0)
diff --git a/arch/riscv/lib/elf_riscv32_efi.lds b/arch/riscv/lib/elf_riscv32_efi.lds
index 629705f..c3e0d20 100644
--- a/arch/riscv/lib/elf_riscv32_efi.lds
+++ b/arch/riscv/lib/elf_riscv32_efi.lds
@@ -20,7 +20,7 @@ SECTIONS
*(.gnu.linkonce.t.*)
*(.srodata)
*(.rodata*)
- . = ALIGN(16);
+ . = ALIGN(512);
}
_etext = .;
_text_size = . - _text;
@@ -46,7 +46,7 @@ SECTIONS
*(.bss)
*(.bss.*)
*(COMMON)
- . = ALIGN(16);
+ . = ALIGN(512);
_bss_end = .;
_edata = .;
}
diff --git a/arch/riscv/lib/elf_riscv64_efi.lds b/arch/riscv/lib/elf_riscv64_efi.lds
index aece030..ecb9139 100644
--- a/arch/riscv/lib/elf_riscv64_efi.lds
+++ b/arch/riscv/lib/elf_riscv64_efi.lds
@@ -20,7 +20,7 @@ SECTIONS
*(.gnu.linkonce.t.*)
*(.srodata)
*(.rodata*)
- . = ALIGN(16);
+ . = ALIGN(512);
}
_etext = .;
_text_size = . - _text;
@@ -46,7 +46,7 @@ SECTIONS
*(.bss)
*(.bss.*)
*(COMMON)
- . = ALIGN(16);
+ . = ALIGN(512);
_bss_end = .;
_edata = .;
}