Skip to content

[target/sim] Reset POSIX ELF loader state between files - #315

Open
lionelZhaowy wants to merge 5 commits into
pulp-platform:mainfrom
lionelZhaowy:fix-elfloader-state
Open

lionelZhaowy wants to merge 5 commits into
pulp-platform:mainfrom
lionelZhaowy:fix-elfloader-state

Conversation

@lionelZhaowy

@lionelZhaowy lionelZhaowy commented Nov 7, 2026 •

Copy link
Copy Markdown

Loading a second ELF through the POSIX loader can return bytes from the first file. read_elf retains its section vector, address-to-bytes map, iterator and entry point. mems.insert keeps 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_elf call. 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, and sim-all targets. The software build uses the CI GCC 12.2.0 release. make sim-test-elfloader checks 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 in target/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.

lionelZhaowy and others added 5 commits November 7, 2026 12:09
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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant