fix(tools): audit sectionless guest modules #4559

Merged
MarcZX10 merged 2 commits from upstream-pr/4559 into main 2026-10-13 14:43:54 +00:00
MarcZX10 commented 2026-10-12 15:38:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-12T15:38:24Z.


What

Fixes #4202. Carries Leandro Soares's --modules import audit and extends it to sectionless ELF modules, which are common in shipped PRX files.

The audit reads sectionless dynamic symbols and DT_NEEDED entries through PT_DYNAMIC, maps virtual addresses through file-backed load segments, and determines symbol-table bounds from SysV or GNU hash data. It audits both undefined imports and sibling module exports. Unsupported or malformed dynamic layouts fail with a file-specific diagnostic instead of being silently skipped. The usage guide describes the supported layouts.

The first commit preserves Leandro's original commit authorship. The follow-up is authored by MarcZX100.

Tested

Linux:

  • python3 -m unittest tools.tests.test_import_audit: passed (44 tests).
  • python3 -m unittest discover -s tools/tests -p 'test_*.py': passed (205 tests).
  • python3 tools/check_conventions.py --base upstream/main: passed.
  • git diff --check upstream/main...HEAD and git diff --check: passed.

Tests cover sectioned and sectionless modules, SysV and GNU hash tables, module imports and exports, DT_NEEDED, missing symbols, malformed files, and suffix handling. No native build or game run was needed for this tooling change.

Checklist

  • Based on current main; no other open pull request implements the remaining sectionless-module behavior
  • One topic per PR; follow-up work goes in a new PR
  • No comments in code except technical debt
  • No notes, investigation files or images added to the repository
  • Generic behavior, not title-specific
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4831647988 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4559). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-12T15:38:24Z. --- ### What Fixes #4202. Carries Leandro Soares's `--modules` import audit and extends it to sectionless ELF modules, which are common in shipped PRX files. The audit reads sectionless dynamic symbols and `DT_NEEDED` entries through `PT_DYNAMIC`, maps virtual addresses through file-backed load segments, and determines symbol-table bounds from SysV or GNU hash data. It audits both undefined imports and sibling module exports. Unsupported or malformed dynamic layouts fail with a file-specific diagnostic instead of being silently skipped. The usage guide describes the supported layouts. The first commit preserves Leandro's original commit authorship. The follow-up is authored by MarcZX100. ### Tested Linux: - `python3 -m unittest tools.tests.test_import_audit`: passed (44 tests). - `python3 -m unittest discover -s tools/tests -p 'test_*.py'`: passed (205 tests). - `python3 tools/check_conventions.py --base upstream/main`: passed. - `git diff --check upstream/main...HEAD` and `git diff --check`: passed. Tests cover sectioned and sectionless modules, SysV and GNU hash tables, module imports and exports, `DT_NEEDED`, missing symbols, malformed files, and suffix handling. No native build or game run was needed for this tooling change. ### Checklist - [x] Based on current `main`; no other open pull request implements the remaining sectionless-module behavior - [x] One topic per PR; follow-up work goes in a new PR - [x] No comments in code except technical debt - [x] No notes, investigation files or images added to the repository - [x] Generic behavior, not title-specific - [x] Depends on: none - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-12 16:03:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T16:03:49Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#4606 tools/import_audit.py L368
#4825 tools/tests/test_import_audit.py L264
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6127941233 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4559#issuecomment-6127941233). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-12T16:03:49Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #4606 | `tools/import_audit.py` [L368](https://github.com/boykopovar/AnyPS5/blob/69b4ca5d9b265049562bf74ea11647bec88139d5/tools/import_audit.py#L368) | | | | #4825 | `tools/tests/test_import_audit.py` [L264](https://github.com/boykopovar/AnyPS5/blob/69b4ca5d9b265049562bf74ea11647bec88139d5/tools/tests/test_import_audit.py#L264) | | |
xXPBSXx commented 2026-10-13 13:17:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T13:17:12Z.


Windows test: head acd821f7c merged onto current main 0f2683cb7, together with 5 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:6146432768 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4559#issuecomment-6146432768). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-13T13:17:12Z. --- Windows test: head `acd821f7c` merged onto current `main` `0f2683cb7`, together with 5 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).
adriadam10 commented 2026-10-13 14:26:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T14:26:36Z.


Checked the sectioned and sectionless readers (SysV and GNU hash), the new module-import records and the docs. Tests pass (44 in test_import_audit), the new tests fail on main without the change (5 failures, 2 errors), and truncated sectionless images only raise AuditError. Windows run by @xXPBSXx also green; merging once the full Build is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6147825310 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4559#issuecomment-6147825310). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-13T14:26:36Z. --- Checked the sectioned and sectionless readers (SysV and GNU hash), the new module-import records and the docs. Tests pass (44 in `test_import_audit`), the new tests fail on `main` without the change (5 failures, 2 errors), and truncated sectionless images only raise `AuditError`. Windows run by @xXPBSXx also green; merging once the full Build is green.
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!4559
No description provided.