Skip to content

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

Open
lionelZhaowy wants to merge 1 commit into
pulp-platform:mainfrom
lionelZhaowy:fix-elfloader-state
Open

lionelZhaowy wants to merge 1 commit into
pulp-platform:mainfrom
lionelZhaowy:fix-elfloader-state

Conversation

@lionelZhaowy

Copy link
Copy Markdown

Reloading an ELF with the POSIX implementation can return data from the previous file. read_elf retains the section vector, address-to-bytes map, iterator, and entry point. A second ELF at the same address keeps the first payload because mems.insert does not replace it. An unconsumed iterator can expose stale sections; a failed open keeps the old entry point.

Clear the four per-file states when a new POSIX read_elf call starts. The non-POSIX implementation is unchanged. Keep the parser and DPI API unchanged. Add two minimal ELF fixtures and a real DPI open-array test.

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.

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