Scripts: map PE export RVAs only into file-backed bytes #2662

Open
github-bot wants to merge 1 commit from github-bot/gh-2662 into main AGit
Owner

@⁠luckyteagirl on GitHub · 2026-11-26 05:29 UTC · original
luckyteagirl:codex/pe-export-file-backed-rvas → main · +35 −2 · 2 files · 1 commits · open

The PE export inspector maps an RVA into disk bytes using the larger of a section's virtual and raw sizes. When VirtualSize is larger, the extra bytes are zero-filled by the loader and have no corresponding file data. An export name RVA in that tail can therefore read unrelated bytes from the next file section and print a false name. Limit disk mapping to SizeOfRawData, as the PE section format defines.

What is in it

  • Use the raw section size for RVA-to-file-offset lookup.
  • Add a synthetic two-section PE32+ fixture with an export name RVA exactly at the first section's raw end and an unrelated sentinel at the old mistaken file offset.

Tested

  • On current main b49be183, the fixture exited successfully and printed the unrelated name. On this branch it rejects the unmapped RVA; the focused export tests passed 2/2 and full Python script discovery passed 26/26 on Windows.
  • Existing PE32 and PE32+ alias/forwarder cases still pass when raw size exceeds virtual size. git diff --check and independent source review passed.
  • PRs #1494, #1685, and #1814 touch nearby code but leave this mapping behavior unchanged; #1814 may need a mechanical rebase.

Regression run

  • Not applicable. Only the Python inspector and synthetic fixture changed.

Not tested

  • A retail PE export table, full bounds checking of export strings/arrays, Rust workspace tests, GPU tests, or retail title smoke.

AI use

  • Codex (GPT-6.2 Sol) implemented and tested the change; another Codex Sol agent independently reviewed it against the PE format.
**@⁠luckyteagirl** on GitHub · 2026-11-26 05:29 UTC · [original](https://github.com/xcl-dev/xcl/pull/2662) `luckyteagirl:codex/pe-export-file-backed-rvas` → `main` · +35 −2 · 2 files · 1 commits · open The PE export inspector maps an RVA into disk bytes using the larger of a section's virtual and raw sizes. When `VirtualSize` is larger, the extra bytes are zero-filled by the loader and have no corresponding file data. An export name RVA in that tail can therefore read unrelated bytes from the next file section and print a false name. Limit disk mapping to `SizeOfRawData`, as the [PE section format](https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#section-table-section-headers) defines. **What is in it** - Use the raw section size for RVA-to-file-offset lookup. - Add a synthetic two-section PE32+ fixture with an export name RVA exactly at the first section's raw end and an unrelated sentinel at the old mistaken file offset. **Tested** - On current main `b49be183`, the fixture exited successfully and printed the unrelated name. On this branch it rejects the unmapped RVA; the focused export tests passed 2/2 and full Python script discovery passed 26/26 on Windows. - Existing PE32 and PE32+ alias/forwarder cases still pass when raw size exceeds virtual size. `git diff --check` and independent source review passed. - PRs #1494, #1685, and #1814 touch nearby code but leave this mapping behavior unchanged; #1814 may need a mechanical rebase. **Regression run** - Not applicable. Only the Python inspector and synthetic fixture changed. **Not tested** - A retail PE export table, full bounds checking of export strings/arrays, Rust workspace tests, GPU tests, or retail title smoke. **AI use** - Codex (GPT-6.2 Sol) implemented and tested the change; another Codex Sol agent independently reviewed it against the PE format.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:14:55 +00:00
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2662/head:github-bot/gh-2662'
git switch 'github-bot/gh-2662'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2662'
git switch 'github-bot/gh-2662'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2662'
git switch 'github-bot/gh-2662'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2662'
git switch 'main'
git merge --squash 'github-bot/gh-2662'
git switch 'main'
git merge --ff-only 'github-bot/gh-2662'
git switch 'main'
git merge 'github-bot/gh-2662'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.