Skip to content

Commit 76085af

Browse files
ardbiesheuvelwilldeacon
authored andcommitted
efi/libstub/arm64: align PE/COFF sections to segment alignment
The arm64 kernel's segment alignment is fixed at 64 KB for any page size, and relocatable kernels are able to fix up any misalignment of the kernel image with respect to the 2 MB section alignment that is mandated by the arm64 boot protocol. Let's increase the PE/COFF section alignment to the same value, so that kernels loaded by the UEFI PE/COFF loader are guaranteed to end up at an address that doesn't require any reallocation to be done if the kernel is relocatable. Signed-off-by: Ard Biesheuvel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent f4be140 commit 76085af

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

arch/arm64/kernel/efi-header.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ optional_header:
3232

3333
extra_header_fields:
3434
.quad 0 // ImageBase
35-
.long SZ_4K // SectionAlignment
35+
.long SEGMENT_ALIGN // SectionAlignment
3636
.long PECOFF_FILE_ALIGNMENT // FileAlignment
3737
.short 0 // MajorOperatingSystemVersion
3838
.short 0 // MinorOperatingSystemVersion

arch/arm64/kernel/vmlinux.lds.S

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ SECTIONS
170170
*(.altinstr_replacement)
171171
}
172172

173-
. = ALIGN(PAGE_SIZE);
173+
. = ALIGN(SEGMENT_ALIGN);
174174
__inittext_end = .;
175175
__initdata_begin = .;
176176

@@ -241,6 +241,7 @@ SECTIONS
241241
. += INIT_DIR_SIZE;
242242
init_pg_end = .;
243243

244+
. = ALIGN(SEGMENT_ALIGN);
244245
__pecoff_data_size = ABSOLUTE(. - __initdata_begin);
245246
_end = .;
246247

0 commit comments

Comments
 (0)