fix(tools): audit ELF modules with out-of-file section tables #5571
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5571"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by Dripl1x on 2026-10-14T00:09:12Z.
What
tools/import_audit.py --modules, the auditdocs/user/USAGE.mddescribes for a title's own modules, stops with exit code 2 before it reports anything when it reads thelibc.prxthat homebrew titles ship. An fSELF container carries the module's original ELF header but not its section table. Unwrapping copies each segment to its program-header offset and keeps that header, soe_shoff(0x194f18, 38 sections) points past the end of the 1335962-byte file. The relinker reads program headers and converts the same file without complaint.In
elf_exportsandelf_imports, use the program-header reader added by #4559 whene_shoffis zero or at or beyond the end of the file. This also avoids reading section 0 for an extended count (e_shnum == 0) outside the file. A section table that starts inside the file but runs past its end still raisesAuditError.What stops on this
No guest path is involved: this stops the documented audit of a title. On
main90d0cb481, RetroArch (PPSA99169):Exit code 2. With this change on the same
main, the audit exits 0:libc.prxis the only module shipped by each of the 63 executable titles in ps5-homebrew-catalog. Four builds of it occur, and 58 titles share one of them. Every copy carries the samee_shoffand section count. Each title was unwrapped as described above and audited with the command above, using the tool frommainand then from this change. With the tool frommain, the audit stops for all 63 with the line above (one title's copy is 1336250 bytes). With this change it completes for all 63: 58 exit with 0, and 5 exit with 1 because the title itself has absent imports.<libs>are libraries from an earlier build ofmain; they decide the classification, not whether the module can be read.Tested
Windows 11, Python 3.14. Head
7ff22e76d, onmain90d0cb481.python tools/tests/test_import_audit.py: 64 tests pass. Three are skipped on Windows: two POSIX permission tests, and one symbolic-link test that needs a privilege this account lacks.tools/import_audit.pyfrommainand the new tests, 4 tests fail and 8 raise errors, all in the out-of-file section-table cases.git diff --checkpass.Not tested: Linux and macOS (the change is pure Python with no platform branch), and any title run; the audit result describes imports, not whether a title runs.
Checklist
main; no other open PR implements the same fallback.mdfiles or images added to the repository--modulesaudits of the catalog titles🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by Dripl1x on 2026-10-14T05:23:51Z.
Re-checked on current
main90d0cb481, because #4887, #4966 and similar PRs were closed with "no title is known to reach this".This is a tool fix, so what stops on it is the audit of a title, not the title itself. Here is the title ID and the log line:
docs/user/USAGE.mddescribestools/import_audit.py ... --modules <title>/sce_moduleas the way to audit a title together with its own modules. The modules have to be unwrapped from fSELF first, as the usage guide says.e_shoff(0x194f18, 38 sections) points past the end of the file. The relinker reads program headers and converts the same file.import_audit.pyreads the section table first and exits.main90d0cb481: The exit code is 2 and nothing else is reported.90d0cb481, head7ff22e76d): the audit exits 0 and reports 682 references, 658 unique imports, 0 absent, and no current stop.libc.prxis the only module of each of the 63 executable titles in ps5-homebrew-catalog, and every copy has this header. Withmain's tool the audit stops on all 63 with the line above. With this PR it completes on all 63: 58 exit 0, and 5 exit 1 because the title itself has absent imports.tools/tests/test_import_audit.pypasses 64 tests (3 skipped on Windows: POSIX permissions and a symbolic-link privilege). Withmain'simport_audit.py, the new cases give 4 failures and 8 errors.The description is updated with the same evidence.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by ideabsassistenza on 2026-10-14T08:15:27Z.
Independent Windows validation of head
7ff22e76dc54f096f724381aef1a0c936b86cf9b, using CPython 3.12.14 on Windows 11 Pro (i7-8700).test_import_audit.py: 64 discovered cases, 62 passed and two POSIX-permission skips, in 5.318 s. The Windows symlink case ran successfully on this account.31bfc4e8693d86318824d83c47cfa418703a7cc8in the same fixture environment, produce four failed subcases and eight errors. With the PR reader, all three methods pass, including rejection of a section table that starts inside the file but is truncated.e_shoff=0x194f18ande_shnum=38, matching the header fields reported for the homebrew module. The baseline audit entry point exits 2; the PR completes with exit 0 and resolves the fixture's imported symbol and dependency through program headers.This probe uses a small synthetic ELF, not the real RetroArch/module files. I did not independently reproduce the catalog runs or test any title, native build or GPU path. These are pinned Python branch-head checks, not a composition with current main. No source changes made.
AI-assisted: yes (Codex); results checked against the saved logs.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T00:40:19Z.
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.
main)tools/import_audit.pyL191-192Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-15T11:18:30Z.
Checked the two-line change in
elf_exports/elf_importsand the new tests:import_auditpasses on the merged tree and fails withtools/import_audit.pyreverted, and a section table that starts inside the file but is truncated is still rejected. Windows run by @ideabsassistenza also green; merging once the Windows build is green.Note: #6171 touches the same lines (191-192), so whichever lands second needs a rebase.