summaryrefslogtreecommitdiff
path: root/arch/x86/boot/setup.ld
diff options
context:
space:
mode:
authorArd Biesheuvel <ardb@kernel.org>2023-09-15 17:16:32 +0000
committerIngo Molnar <mingo@kernel.org>2023-09-17 19:48:44 +0200
commit3e3eabe26dc88692d34cf76ca0e0dd331481cc15 (patch)
tree3da19d289431fd3d32f26870eece7d7d208b792e /arch/x86/boot/setup.ld
parent34951f3c28bdf6481d949a20413b2ce7693687b2 (diff)
x86/boot: Increase section and file alignment to 4k/512
Align x86 with other EFI architectures, and increase the section alignment to the EFI page size (4k), so that firmware is able to honour the section permission attributes and map code read-only and data non-executable. There are a number of requirements that have to be taken into account: - the sign tools get cranky when there are gaps between sections in the file view of the image - the virtual offset of each section must be aligned to the image's section alignment - the file offset *and size* of each section must be aligned to the image's file alignment - the image size must be aligned to the section alignment - each section's virtual offset must be greater than or equal to the size of the headers. In order to meet all these requirements, while avoiding the need for lots of padding to accommodate the .compat section, the latter is placed at an arbitrary offset towards the end of the image, but aligned to the minimum file alignment (512 bytes). The space before the .text section is therefore distributed between the PE header, the .setup section and the .compat section, leaving no gaps in the file coverage, making the signing tools happy. Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Link: https://lore.kernel.org/r/20230915171623.655440-18-ardb@google.com
Diffstat (limited to 'arch/x86/boot/setup.ld')
-rw-r--r--arch/x86/boot/setup.ld7
1 files changed, 4 insertions, 3 deletions
diff --git a/arch/x86/boot/setup.ld b/arch/x86/boot/setup.ld
index 6d389499565c..83bb7efad8ae 100644
--- a/arch/x86/boot/setup.ld
+++ b/arch/x86/boot/setup.ld
@@ -36,16 +36,17 @@ SECTIONS
. = ALIGN(16);
.data : { *(.data*) }
+ .pecompat : { *(.pecompat) }
+ PROVIDE(pecompat_fsize = setup_size - pecompat_fstart);
+
.signature : {
setup_sig = .;
LONG(0x5a5aaa55)
- /* Reserve some extra space for the compat section */
- setup_size = ALIGN(ABSOLUTE(.) + 32, 512);
+ setup_size = ALIGN(ABSOLUTE(.), 4096);
setup_sects = ABSOLUTE(setup_size / 512);
}
-
. = ALIGN(16);
.bss :
{