elf: mode-based IRELATIVE handling with strict default + coverage#73
Open
jlinenkohl wants to merge 1 commit into
Open
elf: mode-based IRELATIVE handling with strict default + coverage#73jlinenkohl wants to merge 1 commit into
jlinenkohl wants to merge 1 commit into
Conversation
Contributor
Author
|
Request for feedback (see reviewer ask section). PR 74 is standalone. |
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.
PR A Draft: Relocation IRELATIVE Modes + Coverage
Summary
This PR adds explicit and testable handling for
R_X86_64_IRELATIVErelocations with a fail-fast default.What Changed
StrictFail(default)BestEffort(opt-in)ExecuteResolver(opt-in)Scope
Files in this PR:
lib/tinykvm/common.hpplib/tinykvm/machine.cpplib/tinykvm/machine.hpplib/tinykvm/machine_elf.cpptests/unit/elf.cppNon-goals
.rela.pltenablement.Why
Recompiling binaries with different linker/build options can reduce relocation surface in some cases, but that is not a complete operational strategy:
The objective here is to make that runtime behavior explicit and safe: fail fast by default when correctness is uncertain, while preserving explicit opt-in modes for compatibility and experimentation.
How Silent Mis-relocation Could Happen (Before)
Before this policy was explicit and default-strict, unsupported or unresolved dynamic relocation paths could continue far enough to look like a successful load in permissive scenarios.
In practice, that can mean:
This is the "silent" part: failure appears late and indirect (for example, runtime crash/segfault) instead of at deterministic load-time validation.
This PR changes that by making the default behavior explicit
StrictFail, adding clear opt-in alternatives, and extending fail-hard coverage for malformed/unsafe relocation inputs.IFUNC/IRELATIVE Boundary
R_X86_64_IRELATIVEonly..rela.pltin this change set.Validation
cd tests && bash ./run_unit_tests.sh -R test_basiccd tests && bash ./run_unit_tests.sh -R test_elfReviewer Ask
StrictFailthe right default policy for IRELATIVE in current scope?Optional Context (if helpful)
docs/elf_loader_contract_baseline.mddocs/elf_relocation_test_matrix.md