diff mbox series

[1/2] x86/boot: Order sections by their RVAs

Message ID 82e66a8c9ae70e416eb8ae5229cf5a93f17921b9.1707141974.git.baskov@ispras.ru
State New
Headers show
Series x86/boot: EFISTUB section alignment | expand

Commit Message

Evgeniy Baskov Feb. 5, 2024, 2:44 p.m. UTC
Image loaders which check the contiguity of executable images consider
sections adjacent in the section table to be adjacent in virtual memory.

Sort sections by their RVAs in PE section table.

Signed-off-by: Evgeniy Baskov <baskov@ispras.ru>
---
 arch/x86/boot/header.S | 56 +++++++++++++++++++++---------------------
 1 file changed, 28 insertions(+), 28 deletions(-)
diff mbox series

Patch

diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
index b2771710ed98..097b84ab288c 100644
--- a/arch/x86/boot/header.S
+++ b/arch/x86/boot/header.S
@@ -153,6 +153,34 @@  section_table:
 		IMAGE_SCN_MEM_READ		| \
 		IMAGE_SCN_MEM_DISCARDABLE	# Characteristics
 
+	.ascii	".text"
+	.byte	0
+	.byte	0
+	.byte	0
+	.long	ZO__data
+	.long	setup_size
+	.long	ZO__data			# Size of initialized data
+						# on disk
+	.long	setup_size
+	.long	0				# PointerToRelocations
+	.long	0				# PointerToLineNumbers
+	.word	0				# NumberOfRelocations
+	.word	0				# NumberOfLineNumbers
+	.long	IMAGE_SCN_CNT_CODE		| \
+		IMAGE_SCN_MEM_READ		| \
+		IMAGE_SCN_MEM_EXECUTE		# Characteristics
+
+	.ascii	".data\0\0\0"
+	.long	ZO__end - ZO__data		# VirtualSize
+	.long	setup_size + ZO__data		# VirtualAddress
+	.long	ZO__edata - ZO__data		# SizeOfRawData
+	.long	setup_size + ZO__data		# PointerToRawData
+
+	.long	0, 0, 0
+	.long	IMAGE_SCN_CNT_INITIALIZED_DATA	| \
+		IMAGE_SCN_MEM_READ		| \
+		IMAGE_SCN_MEM_WRITE		# Characteristics
+
 #ifdef CONFIG_EFI_MIXED
 	.asciz	".compat"
 
@@ -185,34 +213,6 @@  pecompat_fstart:
 	.set	pecompat_vsize, 0
 	.set	pecompat_fstart, setup_size
 #endif
-	.ascii	".text"
-	.byte	0
-	.byte	0
-	.byte	0
-	.long	ZO__data
-	.long	setup_size
-	.long	ZO__data			# Size of initialized data
-						# on disk
-	.long	setup_size
-	.long	0				# PointerToRelocations
-	.long	0				# PointerToLineNumbers
-	.word	0				# NumberOfRelocations
-	.word	0				# NumberOfLineNumbers
-	.long	IMAGE_SCN_CNT_CODE		| \
-		IMAGE_SCN_MEM_READ		| \
-		IMAGE_SCN_MEM_EXECUTE		# Characteristics
-
-	.ascii	".data\0\0\0"
-	.long	ZO__end - ZO__data		# VirtualSize
-	.long	setup_size + ZO__data		# VirtualAddress
-	.long	ZO__edata - ZO__data		# SizeOfRawData
-	.long	setup_size + ZO__data		# PointerToRawData
-
-	.long	0, 0, 0
-	.long	IMAGE_SCN_CNT_INITIALIZED_DATA	| \
-		IMAGE_SCN_MEM_READ		| \
-		IMAGE_SCN_MEM_WRITE		# Characteristics
-
 	.set	section_count, (. - section_table) / 40
 #endif /* CONFIG_EFI_STUB */