Repository navigation
[target/sim] Reset POSIX ELF loader state between files - #315
Open
lionelZhaowy wants to merge 5 commits into
Open
lionelZhaowy wants to merge 5 commits into
lionelZhaowy wants to merge 5 commits into
Conversation
Clear the previous image data and iterator when read_elf starts. Test real DPI open arrays with two ELF fixtures, repeated loads, an unconsumed iterator, an expected failed open, and recovery. Keep the non-POSIX implementation unchanged. AI assistance was used for code, tests, and text.
This branch has not been deployed
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.
Loading a second ELF through the POSIX loader can return bytes from the first file.
read_elfretains its section vector, address-to-bytes map, iterator and entry point.mems.insertkeeps the old payload at a reused address. An undrained iterator can expose stale sections, and a failed open leaves the old entry point.This change clears those four states at the start of each POSIX
read_elfcall. It keeps the parser, DPI API and non-POSIX implementation unchanged. The regression adds two minimal ELF fixtures and a test of the simulator's DPI open-array API.The same two ELF files reproduce 291 errors in the original loader and zero with the fix. The different check counts reflect an extra stale segment exposed by the original.
Local checks now pass with the complete checkout license rule, clang-format 14, and the official
hw-all,sw-all, andsim-alltargets. The software build uses the CI GCC 12.2.0 release.make sim-test-elfloaderchecks the real DPI loader: 823 checks, zero errors. The complete SoC JTAG HelloWorld control also finishes normally.The license job now uses Ubuntu 24.04, which supports the action's pinned Python 3.9. All four fork lint jobs pass, including the actual license checker.
Validation, reproduction and scope
Validation on official main
6c6dd5e834347f72c7be31cd6c41021ec293c5b9: same two ELF files and test, seven successful loads, six iterator drains, one expected failed open, and recovery. Original: 954 checks / 291 errors and TEST_FAILED. Fixed: 823 checks / zero errors and normal finish at 1 ns. The original runs more checks because it exposes an extra stale segment. Both VCS builds pass with the same existing simulator-linker warning. The test checks each byte, entry, address, length, buffer guards, and iterator state. Public commands and input SHA256 values are intarget/sim/tests/elfloader_state/README.md.Tools: LLVM 20.1.0, VCS W-2024.09-SP1, GCC 13.3.1, Linux. This validates the actual host loader and simulator DPI API. It does not validate a SoC, BSS, ELF32, malformed input parsing, or the non-POSIX branch. Original authors and licenses remain. AI assistance was used for code, tests, and text. An independent AI review checked the actual results.