roadmap BUILT

196. A physical address on elf::Segment, or a second ELF reader forever

The field is built. uefi_loader calls elf::Elf::parse with no reader of its own. That is proved by booting under OVMF, not by reading. The field alone was not enough, for a reason nobody predicted: Elf::parse refused the image as writable-and-executable. Milestone 208 (the x86_64 kernel image ships an RWX segment, and it is the reason a second ELF reader exists) split the linker script, which removed that.

What survives in uefi_loader/src/image.rs is not a reader: it is physical_span over elf::Segment::paddr plus this loader's own wording for every elf::Error, in an exhaustive match so growing the enum breaks the build. Elf::parse deliberately does not provide physical_span, because a program loader maps at p_vaddr and a firmware loader places at p_paddr, and on this image they are unrelated.

The reasoning below is kept because the reason nobody predicted is the useful half of this block.

The gate is discharged, and is recorded here rather than deleted. It read Gate: DECISION, because crates/elf is a shared definition, which AGENTS.md rule 7 makes global to the tree and therefore calef's rather than a lane's. It was answered when the paddr field shipped on 2026-08-31.

In brief. The UEFI loader carries its own forty-line ELF reader for one reason: crates/elf's Segment exposes no p_paddr, and in this kernel p_vaddr and p_paddr are genuinely unrelated (.ap_trampoline's p_vaddr is 0x8000 against a p_paddr of 0x12b000, measured; see BUGS). A loader placing an image in physical memory needs the physical address, so it re-implements the parse.

Two readers of one format is the defect, and it is the shape rule 7 exists to prevent: the agreement between them is a comment, not a type.

What is being decided

Whether elf::Segment widens to carry p_paddr. It is a small change to a crate the kernel's own loader depends on, which is what makes it calef's rather than small.

Decided 2026-08-31: widen it, as a plain u64. The field is in the format and the crate is simply not exposing it, which makes this a gap rather than a design change.

And the typed version is deliberately not done here. Making the virtual/physical confusion unrepresentable is milestone 200 (a virtual address and a physical address stop being the same type), which is tree-wide and ratified its own names. Typing elf::Segment's two fields alone would claim a distinction the rest of the tree does not make, and a newtype whose value every consumer immediately unwraps is not a mechanism. So this milestone adds the field with the hazard in its doc comment, and milestone 200 makes the mistake unsayable everywhere at once.

BUGS

Follow-on

Index row

The UEFI loader carries its own forty-line ELF reader because crates/elf exposes no p_paddr, and in this kernel p_vaddr and p_paddr are genuinely unrelated. Two readers of one format is the defect rule 7 exists to prevent. Gate: DECISION, because a shared definition is global to the tree; recommends widening.