Skip to content

Commit 2672519

Browse files
nivedita76Ingo Molnar
authored andcommitted
efi/x86: Add kernel preferred address to PE header
Store the kernel's link address as ImageBase in the PE header. Note that the PE specification requires the ImageBase to be 64k aligned. The preferred address should almost always satisfy that, except for 32-bit kernel if the configuration has been customized. Signed-off-by: Arvind Sankar <[email protected]> Signed-off-by: Ard Biesheuvel <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Link: https://lore.kernel.org/r/[email protected] Link: https://lore.kernel.org/r/[email protected]
1 parent 1887c9b commit 2672519

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

arch/x86/boot/header.S

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,12 @@ optional_header:
138138
#endif
139139

140140
extra_header_fields:
141+
# PE specification requires ImageBase to be 64k aligned
142+
.set image_base, (LOAD_PHYSICAL_ADDR + 0xffff) & ~0xffff
141143
#ifdef CONFIG_X86_32
142-
.long 0 # ImageBase
144+
.long image_base # ImageBase
143145
#else
144-
.quad 0 # ImageBase
146+
.quad image_base # ImageBase
145147
#endif
146148
.long 0x20 # SectionAlignment
147149
.long 0x20 # FileAlignment

0 commit comments

Comments
 (0)