Names, updates, and an overflow fix#68
Merged
dancrossnyc merged 3 commits intomainfrom Apr 18, 2026
Merged
Conversation
It is possible to map a loadable ELF segment at the very top of virtual memory, and if we do so, then the end address of the resulting region will overflow and wrap around to 0. This is expected. The virtual memory code correctly handles this, but the loader uses `end - begin` to calculate the lengths of segments, and that can wrap when `end` is rounded "up" to 0. To make explicit that this is permissible (and to avoid panics in debug builds), we should use `.wrapping_sub` instead of bare subtraction. I should stress that, while this behavior is supported, it does not happen in practice, as no binary that we load with `phbl` maps anything in that region of the virtual address space; in that sense, this change is a no-op. But as a code hygiene issue, the program should be correct in all regards, and hence should handle this case explicitly. Signed-off-by: Dan Cross <cross@oxidecomputer.com>
ELF "sections" are not exactly the same thing as loadable "segments", and we should be clear with nomenclature. The ELF standard uses the term "segment" for what is described by the program headers, which are the things that we load, so we should, too. Signed-off-by: Dan Cross <cross@oxidecomputer.com>
Trivial update to a newer Rust version and updating dependencies via `cargo update`. Signed-off-by: Dan Cross <cross@oxidecomputer.com>
citrus-it
approved these changes
Apr 17, 2026
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.
Tested on sn6.