From b01c8e438890485160d63195ebc91e08943ca9af Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Thu, 2 Feb 2023 09:32:47 +0000 Subject: [PATCH] Avoid sbverify warning about gap in section table. We have a .setup section in the EFI image that contains the remainder of the Linux boot header and the real-mode setup code to support booting via an intermediate bootloader. This sits between the PE header and the .text section. We don't want the EFI loader to load this section, so simply increase the SizeOfHeader field in the PE header to cover it. --- boot/header.S | 3 +-- build32/ldscripts/memtest_efi.lds | 3 ++- build64/ldscripts/memtest_efi.lds | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/boot/header.S b/boot/header.S index 2177713..23e9a14 100644 --- a/boot/header.S +++ b/boot/header.S @@ -144,7 +144,7 @@ extra_header_fields: .long 0 # Win32VersionValue .long _virt_img_size # SizeOfImage - .long end_of_headers # SizeOfHeaders + .long _file_head_size # SizeOfHeaders .long 0 # CheckSum .word 10 # Subsystem (EFI application) .word 0 # DllCharacteristics @@ -241,7 +241,6 @@ boot_flag: .word 0xAA55 .org 512 -end_of_headers: .section ".reloc" .long 0 // Page RVA diff --git a/build32/ldscripts/memtest_efi.lds b/build32/ldscripts/memtest_efi.lds index 4b83fdd..2c84de5 100644 --- a/build32/ldscripts/memtest_efi.lds +++ b/build32/ldscripts/memtest_efi.lds @@ -38,6 +38,7 @@ SECTIONS { _real_reloc_size = _real_reloc_end - _file_reloc_start; _real_sbat_size = _real_sbat_end - _file_sbat_start; + _file_head_size = _file_text_start; _file_text_size = _file_text_end - _file_text_start; _file_reloc_size = _file_reloc_end - _file_reloc_start; _file_sbat_size = _file_sbat_end - _file_sbat_start; @@ -45,7 +46,7 @@ SECTIONS { _sys_size = (_real_text_size + 15) >> 4; _init_size = _real_text_size + _bss_size; - _virt_head_size = ((_file_text_start + 4095) >> 12) << 12; + _virt_head_size = ((_file_head_size + 4095) >> 12) << 12; _virt_text_size = ((_init_size + 4095) >> 12) << 12; _virt_reloc_size = ((_file_reloc_size + 4095) >> 12) << 12; _virt_sbat_size = ((_file_sbat_size + 4095) >> 12) << 12; diff --git a/build64/ldscripts/memtest_efi.lds b/build64/ldscripts/memtest_efi.lds index 784382b..14d1a49 100644 --- a/build64/ldscripts/memtest_efi.lds +++ b/build64/ldscripts/memtest_efi.lds @@ -38,6 +38,7 @@ SECTIONS { _real_reloc_size = _real_reloc_end - _file_reloc_start; _real_sbat_size = _real_sbat_end - _file_sbat_start; + _file_head_size = _file_text_start; _file_text_size = _file_text_end - _file_text_start; _file_reloc_size = _file_reloc_end - _file_reloc_start; _file_sbat_size = _file_sbat_end - _file_sbat_start; @@ -45,7 +46,7 @@ SECTIONS { _sys_size = (_real_text_size + 15) >> 4; _init_size = _real_text_size + _bss_size; - _virt_head_size = ((_file_text_start + 4095) >> 12) << 12; + _virt_head_size = ((_file_head_size + 4095) >> 12) << 12; _virt_text_size = ((_init_size + 4095) >> 12) << 12; _virt_reloc_size = ((_file_reloc_size + 4095) >> 12) << 12; _virt_sbat_size = ((_file_sbat_size + 4095) >> 12) << 12;