Repository navigation
fix(tools): audit ELF modules with out-of-file section tables - #5571
adriadam10 merged 1 commit into
Conversation
Use program headers when the section table starts at or beyond EOF. Keep rejecting tables that start inside the file but are truncated. Cover imports, exports, full module audits, and extended section counts.
c0ad701 to
7ff22e7
Compare
|
Re-checked on current 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:
The description is updated with the same evidence. AI-assisted (Claude Code). |
|
Independent Windows validation of head
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. |
|
Checked the two-line change in Note: #6171 touches the same lines (191-192), so whichever lands second needs a rebase. |
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