Repository navigation
Conversation
Contributor
|
Windows run, since the description notes it wasn't tested there: Windows 11 Pro 25H2 (10.0.26200.9457), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, full build with
AI-assisted: yes |
Collaborator
|
Closing: a |
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.
What
ElfReader::TranslateVirtualAddresscould wrap aPT_LOADfile offset and return a location in unrelated input bytes. A synthetic ELF withp_offset=0xfffffffffffff000,p_vaddr=0x2000,p_filesz=0x2000andDT_STRTAB=0x3600translates to file offset0x600after wrapping. On unmodified main, Linux conversion succeeds and emitsDT_NEEDED=libwrongx.prxfrom those unrelated bytes. The valid control emitslibkernel.prx.Check the selected load segment's complete file range with the existing subtraction-based
_rangeFitshelper before adding the address displacement. The malformed input now exits 2 withSegment offset out of bounds (offset 0xfffffffffffff000)and creates neither an executable nor a registry. Windows also rejects it in the shared parser, before its existing PE-specific validation.The ELF gABI, sections 7.1 and 7.2 defines
p_offsetas the start of a segment's file image andp_fileszas its extent. The check follows the existingElfReader::ReadSegmentcontract, which rejects a segment whose complete file range exceeds the input. This deliberately rejects truncated segments even when the requested byte itself is inside the file.Extend the already registered
elf_offsetstest with 20 conversions: valid mappings, the first file-backed byte, a segment ending exactly at EOF, wrapping/past-EOF offsets, truncated and oversized extents, an address at the segment's exclusive end, and an empty segment. Invalid cases require exit 2, the expected diagnostic, and no output or registry. Valid Linux controls inspect the emitted dynamic table and dependency name; Windows controls verify successful PE generation. Existing assertions are retained.This is the deferred file-offset translation gap recorded in #1690. It does not duplicate that PR's symbol-boundary tests or #1272's symbol guard. Open #1087 and #1956 change other
ElfReadermethods; #1446 bounds RELA tables and #1943 handles Linux layout-address overflow. The audit reviewed all 558 open PRs and current relinker/ELF issues on 9 October 2026; no equivalent implementation was found. No prerequisite is needed.Tested
macOS 26.6.2 (25G83), x86-64; AppleClang 21.0.0; CMake 4.4.4; Ninja 1.13.2; Python 3.13. Relinker-only Release build, without third-party submodules or system libraries. Base:
f145139676a48306681d3a4d5fabf83938759daf, refreshed from upstream main before final review.elf_offsetsagainst a saved, unmodified baseline binary: failed attranslation-offset-wrap, because Linux returned 0 and wrote an executable instead of rejecting the input. All three new valid controls passed in both output modes before that failure.elf_offsets: passed (1.84 s).elf_offsetstook 1.67 s.python3 tools/check_conventions.py --base origin/main --title 'fix(relinker): validate translated load segment file ranges' --body <PR-description-file>: passed.python3 tools/check_test_registration.py ../build-relinker: all five test executables registered.git diff --checkand final diff review: passed; two source/test files, three production lines, no added comments, dependencies or investigation files.Build and test commands from the repository root:
CMake and Ninja were installed only in the task's work folder. Configuration used an explicit
CMAKE_MAKE_PROGRAMpath to that Ninja executable; the registration check used its directory onPATH.Limitations: the fixtures inspect Linux ELF and Windows PE output on macOS; compatible-host execution branches in the existing tests do not run here. No native Linux/Windows build, generated-game execution, real title, full system-library build, GPU test, or sanitizer run was performed. This check covers selected segments used by address translation; general load-segment validation and virtual-address-end overflow remain outside this patch.
Checklist
main; no other open PR implements the same fix