fix(tools): validate empty ELF dynamic symbol table bounds #4825

Merged
StefanBuc merged 1 commit from upstream-pr/4825 into main 2026-10-14 02:37:26 +00:00
StefanBuc commented 2026-10-12 23:02:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by StefanBuc on 2026-10-12T23:02:23Z.


What

An empty ELF dynamic symbol table beyond EOF currently becomes an empty export set, so the import audit can report an absent import and write a misleading report instead of rejecting the malformed library. Validate the complete declared table range before iterating. Keep valid empty ranges at EOF accepted.

Regression tests cover invalid and extreme offsets, truncated tables, valid EOF boundaries, and CLI exit 2 with a file/table diagnostic; the audit does not write a JSON report on this error. Related #4559 has merged into main, but the existing sectioned built-library export-parser gap remains reproducible. This branch retains upstream's import-reader test and all three bounds regression tests. The change only validates the existing sectioned export path; it does not change the new import parser or sectionless path.

Tested

Based on upstream main dacd78525e537a779682032c0ace7f7af120af05, adopting blawesom's independently reviewed rebase handoff 89a8ec58b14c661a52641728fa6f083081ae5578. Author metadata is preserved. Validation below was performed on October 13, 2026.

  • Exact handoff commit: Linux Ubuntu 24.04 / Python 3.12.3 focused import-audit suite 49/49; native Windows Python 3.12.3 focused suite 49/49. Conventions against its upstream base and exact committed-diff whitespace checks pass.
  • Previous published revision 1dca84000, based on upstream 18c438b10: full Linux tools suite 282/282; documented relinker-only configuration and registered import_audit CTest 1/1 (0.53 s), using GCC 13.3.0, CMake 3.28.3 and Ninja 1.11.1. These broader checks were not rerun for the handoff.
  • On that previous upstream base, the three added regression methods produce three expected failed assertions; an independently constructed range fixture improves from 6/8 on upstream to 8/8 with the fix, including valid boundary controls.
  • The handoff's production parser and test file are byte-for-byte identical to the previous published revision. Final diff against its new upstream base remains two files and the same 37 added lines; upstream's added tests are retained. No unrelated changes were introduced by the handoff.
  • No native relinker compilation, full runtime/library build, supported Windows GCC build, macOS run, or game execution. No game compatibility improvement claimed.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • AI-assisted: yes; prepared and independently validated with Codex assistance. The submitting author is responsible for every line.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4836007393 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4825). Originally posted by [StefanBuc](https://github.com/StefanBuc) on 2026-10-12T23:02:23Z. --- ### What An empty ELF dynamic symbol table beyond EOF currently becomes an empty export set, so the import audit can report an absent import and write a misleading report instead of rejecting the malformed library. Validate the complete declared table range before iterating. Keep valid empty ranges at EOF accepted. Regression tests cover invalid and extreme offsets, truncated tables, valid EOF boundaries, and CLI exit 2 with a file/table diagnostic; the audit does not write a JSON report on this error. Related #4559 has merged into main, but the existing sectioned built-library export-parser gap remains reproducible. This branch retains upstream's import-reader test and all three bounds regression tests. The change only validates the existing sectioned export path; it does not change the new import parser or sectionless path. ### Tested Based on upstream main `dacd78525e537a779682032c0ace7f7af120af05`, adopting blawesom's independently reviewed rebase handoff `89a8ec58b14c661a52641728fa6f083081ae5578`. Author metadata is preserved. Validation below was performed on October 13, 2026. - Exact handoff commit: Linux Ubuntu 24.04 / Python 3.12.3 focused import-audit suite 49/49; native Windows Python 3.12.3 focused suite 49/49. Conventions against its upstream base and exact committed-diff whitespace checks pass. - Previous published revision `1dca84000`, based on upstream `18c438b10`: full Linux tools suite 282/282; documented relinker-only configuration and registered `import_audit` CTest 1/1 (0.53 s), using GCC 13.3.0, CMake 3.28.3 and Ninja 1.11.1. These broader checks were not rerun for the handoff. - On that previous upstream base, the three added regression methods produce three expected failed assertions; an independently constructed range fixture improves from 6/8 on upstream to 8/8 with the fix, including valid boundary controls. - The handoff's production parser and test file are byte-for-byte identical to the previous published revision. Final diff against its new upstream base remains two files and the same 37 added lines; upstream's added tests are retained. No unrelated changes were introduced by the handoff. - No native relinker compilation, full runtime/library build, supported Windows GCC build, macOS run, or game execution. No game compatibility improvement claimed. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] AI-assisted: yes; prepared and independently validated with Codex assistance. The submitting author is responsible for every line.
xXPBSXx commented 2026-10-13 11:51:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T11:51:54Z.


Windows test: head 2f238ebd6 merged onto current main 5d50886ee, together with 9 other open pull requests in one build (the merges were conflict-free); a failure would have been bisected per PR. Windows 10, MinGW GCC (WinLibs), Ninja Release, -j2: full build 0 errors; ctest for the tests this change adds or touches: import_audit passed; python tools/check_conventions.py --base upstream/main passed for the combined tree. I did not run the new tests against main without the change.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6144914955 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4825#issuecomment-6144914955). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-13T11:51:54Z. --- Windows test: head `2f238ebd6` merged onto current `main` `5d50886ee`, together with 9 other open pull requests in one build (the merges were conflict-free); a failure would have been bisected per PR. Windows 10, MinGW GCC (WinLibs), Ninja Release, `-j2`: full build 0 errors; ctest for the tests this change adds or touches: import_audit passed; `python tools/check_conventions.py --base upstream/main` passed for the combined tree. I did not run the new tests against `main` without the change. AI-assisted (Claude Code).
blawesom commented 2026-10-13 19:09:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-13T19:09:10Z.


Rebase handoff — rebased onto current main (staleness only, applied cleanly), authorship unchanged.

Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, AMD RX 9070 XT / RADV):

  • builds; tools/check_conventions.py --base origin/main passes
  • full suite passes except the known main regression (agc_driver_tessellation segfault, #4727) — not caused by this PR

To pick it up:

git fetch https://github.com/blawesom/AnyPS5 rebase/4825
git checkout <your branch>
git merge --ff-only FETCH_HEAD

Head is 89a8ec58b.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6153117576 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4825#issuecomment-6153117576). Originally posted by [blawesom](https://github.com/blawesom) on 2026-10-13T19:09:10Z. --- **Rebase handoff** — rebased onto current `main` (staleness only, applied cleanly), authorship unchanged. Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, `BUILD_TESTING=ON`, AMD RX 9070 XT / RADV): - builds; `tools/check_conventions.py --base origin/main` passes - **full suite passes except the known `main` regression** (`agc_driver_tessellation` segfault, #4727) — not caused by this PR **To pick it up:** ``` git fetch https://github.com/blawesom/AnyPS5 rebase/4825 git checkout <your branch> git merge --ff-only FETCH_HEAD ``` Head is `89a8ec58b`.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!4825
No description provided.