Repository navigation
aarch64: page-align the UEFI loader image - #2182
Merged
Merged
Conversation
francescolavra
requested changes
Oct 11, 2026
francescolavra
left a comment
Member
There was a problem hiding this comment.
In both the commit message and the PR description, the statement "The header grows into the space .text no longer occupies, so the loader does not get any larger" is wrong and misleading. The loader is keeping the previous size just by chance. Remove all mentions of the loader size.
The PE header declares a SectionAlignment and a FileAlignment of 0x1000, and every field that locates .text is _start - IMAGE_BASE: SizeOfHeaders, AddressOfEntryPoint, BaseOfCode, and the section's VirtualAddress and PointerToRawData. With _start aligned to 8 those fields read 0x200, which the format does not allow of either a section's virtual address or SizeOfHeaders. Firmware that enforces the alignment when it applies memory attributes to a loaded image rejects the loader and asserts in DxeCore before it runs; the edk2 build Oracle Cloud Infrastructure ships as of 2026-05-22 does. Aligning _start to a page makes the declared and actual layout agree.
AngeloRubens
force-pushed
the
aarch64-uefi-align
branch
from
October 11, 2026 08:08
a874254 to
ac55b6d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The PE header of the aarch64 UEFI loader declares a SectionAlignment and a
FileAlignment of 0x1000, but _start is aligned to 8, so SizeOfHeaders and the
virtual address of .text both come out as 0x200. The format does not allow
either of them to be unaligned with respect to the values declared above.
Firmware that enforces this when it applies memory attributes to a loaded image
rejects the loader before it runs. The edk2 build that Oracle Cloud
Infrastructure ships as of 2026-05-22 asserts in DxeCore:
Aligning _start to a page makes the declared and the actual layout agree. Every
field that locates .text derives from _start - IMAGE_BASE, so they all move
together.
Tested on a VM.Standard.A1.Flex instance in eu-milan-1. Before the change the
firmware asserts as above; after it, the loader runs and reaches
ExitBootServices.
Console of the instance, captured with oci compute console-history, before the
change:
The same image on a 1 OCPU / 1 GB shape fails identically, only the address
differs (0x7E358000), so the shape of the instance is not a factor.
After the change, on the same shape, the firmware starts the image and the
loader reaches the end of its work:
Header fields before and after, read from the built binary: