fix(tools): normalize qualified ELF module exports #6113

Merged
ArjenS-LA merged 1 commit from upstream-pr/6113 into main 2026-10-16 23:30:13 +00:00
ArjenS-LA commented 2026-10-14 22:38:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ArjenS-LA on 2026-10-14T22:38:20Z.


What

The import audit incorrectly reports a guest import as absent when its sibling module exports the matching NID with a #library#module suffix and retains ELF section headers. The sectionless reader already resolves the same symbol. Normalize section-based export names at the first #, matching the import reader, sectionless reader, and relinker's GuestImageReader export handling.

The regression fixture audits consumer.prx importing NID#import#module against provider.prx exporting NID#export#module. It covers section headers, sectionless SysV hash and sectionless GNU hash, verifies the JSON provider and importing module, and checks that a different NID remains absent.

Branch: fix/import-audit-export-suffix
Baseline: eea428ca855fb59a3edd394bab9abf99165590f1
Tested commit: fcd477faf8fd0b4959f927db1f36590b317fa2b7.

Tested

Windows 11 build 26200, AMD64, CPython 3.13.7. Python tooling only; no C++ compiler, GPU, title or homebrew execution was required or performed.

  • Same new regression against a separate untouched baseline source copy: fails for the section-header case (audit exit 1 instead of 0), with both sectionless controls passing.
  • Fixed regression: passes, including the unrelated-export negative control.
  • tools/tests/test_import_audit.py: 80 tests, 76 passed and 4 skipped, 2.830 seconds. Two POSIX permission checks are unavailable on Windows, symlink creation lacks privilege, and the existing source-stamp fixture was explicitly excluded because it creates a temporary Git commit. An external runner applied this skip without changing tracked tests.
  • git diff --check: passed.
  • python tools/check_conventions.py --base origin/main: passed on the committed change.

Reproducer: python -m unittest tools.tests.test_import_audit.ImportAuditTests.test_module_export_suffix_is_stripped_with_and_without_sections -v.

Open PR comparison

Checked main eea428ca855fb59a3edd394bab9abf99165590f1 and the complete 466-PR inventory with paginated changed-file lists. Each overlapping head was normalized onto that main with Git tree-only merges, then compared with main as the explicit merge base. No temporary commits were created. This branch merges cleanly with main. The four proposed changes also merge cleanly with one another.

#5713 changes Git stamping; #5571 changes out-of-file section-table fallback. Neither normalizes section-based export names. #5473 has no remaining common-base diff in the shared files.

  • #5713 fd3c6796042ff61c599fa100a4e979a7be200658: clean pair preview. Shared files: tools/import_audit.py, tools/tests/test_import_audit.py.
  • #5571 7ff22e76dc54f096f724381aef1a0c936b86cf9b: clean pair preview. Shared files: tools/import_audit.py, tools/tests/test_import_audit.py.
  • #5473 4a7a38c43d8d2545584f72c10ac1614f8f74c311: clean pair preview. Shared files: tools/import_audit.py, tools/tests/test_import_audit.py.

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
  • GPUs tested: n/a
  • AI-assisted: yes, OpenAI Codex
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4865531694 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6113). Originally posted by [ArjenS-LA](https://github.com/ArjenS-LA) on 2026-10-14T22:38:20Z. --- ### What The import audit incorrectly reports a guest import as absent when its sibling module exports the matching NID with a `#library#module` suffix and retains ELF section headers. The sectionless reader already resolves the same symbol. Normalize section-based export names at the first `#`, matching the import reader, sectionless reader, and relinker's `GuestImageReader` export handling. The regression fixture audits `consumer.prx` importing `NID#import#module` against `provider.prx` exporting `NID#export#module`. It covers section headers, sectionless SysV hash and sectionless GNU hash, verifies the JSON provider and importing module, and checks that a different NID remains absent. Branch: `fix/import-audit-export-suffix` Baseline: `eea428ca855fb59a3edd394bab9abf99165590f1` Tested commit: `fcd477faf8fd0b4959f927db1f36590b317fa2b7`. ### Tested Windows 11 build 26200, AMD64, CPython 3.13.7. Python tooling only; no C++ compiler, GPU, title or homebrew execution was required or performed. - Same new regression against a separate untouched baseline source copy: fails for the section-header case (audit exit 1 instead of 0), with both sectionless controls passing. - Fixed regression: passes, including the unrelated-export negative control. - `tools/tests/test_import_audit.py`: 80 tests, 76 passed and 4 skipped, 2.830 seconds. Two POSIX permission checks are unavailable on Windows, symlink creation lacks privilege, and the existing source-stamp fixture was explicitly excluded because it creates a temporary Git commit. An external runner applied this skip without changing tracked tests. - `git diff --check`: passed. - `python tools/check_conventions.py --base origin/main`: passed on the committed change. Reproducer: `python -m unittest tools.tests.test_import_audit.ImportAuditTests.test_module_export_suffix_is_stripped_with_and_without_sections -v`. ### Open PR comparison Checked main `eea428ca855fb59a3edd394bab9abf99165590f1` and the complete 466-PR inventory with paginated changed-file lists. Each overlapping head was normalized onto that main with Git tree-only merges, then compared with main as the explicit merge base. No temporary commits were created. This branch merges cleanly with main. The four proposed changes also merge cleanly with one another. #5713 changes Git stamping; #5571 changes out-of-file section-table fallback. Neither normalizes section-based export names. #5473 has no remaining common-base diff in the shared files. - #5713 `fd3c6796042ff61c599fa100a4e979a7be200658`: clean pair preview. Shared files: `tools/import_audit.py`, `tools/tests/test_import_audit.py`. - #5571 `7ff22e76dc54f096f724381aef1a0c936b86cf9b`: clean pair preview. Shared files: `tools/import_audit.py`, `tools/tests/test_import_audit.py`. - #5473 `4a7a38c43d8d2545584f72c10ac1614f8f74c311`: clean pair preview. Shared files: `tools/import_audit.py`, `tools/tests/test_import_audit.py`. ### 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] GPUs tested: n/a - [x] AI-assisted: yes, OpenAI Codex
Dextroid17 commented 2026-10-15 15:04:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-15T15:04:45Z.


I ran the test this PR adds, on Linux.

Setup: head fcd477faf merged into main at ff23657f3 (no conflicts), Linux, Python 3.14.8, clean environment (env -i, only HOME and PATH set). python3 -m unittest -v test_import_audit from tools/tests, 3 runs each.

  • with this PR: 3 of 3 runs pass (85 tests, 1 Windows-only test skipped).
  • with tools/import_audit.py put back to main's version (the PR's test changes kept): 3 of 3 runs fail, each time only at the layout='sections' subtest of test_module_export_suffix_is_stripped_with_and_without_sections.

The export path for ELFs with section headers now strips the # suffix, as main already did for section-less dynamic symbols and in elf_imports.
I did not check Windows or macOS.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6195272934 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6113#issuecomment-6195272934). Originally posted by [Dextroid17](https://github.com/Dextroid17) on 2026-10-15T15:04:45Z. --- I ran the test this PR adds, on Linux. Setup: head fcd477faf merged into main at ff23657f3 (no conflicts), Linux, Python 3.14.8, clean environment (`env -i`, only HOME and PATH set). `python3 -m unittest -v test_import_audit` from tools/tests, 3 runs each. - with this PR: 3 of 3 runs pass (85 tests, 1 Windows-only test skipped). - with tools/import_audit.py put back to main's version (the PR's test changes kept): 3 of 3 runs fail, each time only at the `layout='sections'` subtest of `test_module_export_suffix_is_stripped_with_and_without_sections`. The export path for ELFs with section headers now strips the `#` suffix, as main already did for section-less dynamic symbols and in `elf_imports`. I did not check Windows or macOS. AI-assisted: yes
adriadam10 commented 2026-10-16 23:30:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T23:30:01Z.


Checked the one-line change in elf_exports against the other two readers (lines 145 and 208, same # split) and the new test: import_audit passes on the merged tree and fails with tools/import_audit.py reverted. The test covers section headers, sectionless SysV/GNU hash and a different-NID negative control. Also confirmed on Linux by @Dextroid17. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6226620763 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6113#issuecomment-6226620763). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-16T23:30:01Z. --- Checked the one-line change in `elf_exports` against the other two readers (lines 145 and 208, same `#` split) and the new test: `import_audit` passes on the merged tree and fails with `tools/import_audit.py` reverted. The test covers section headers, sectionless SysV/GNU hash and a different-NID negative control. Also confirmed on Linux by @Dextroid17. Merging.
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!6113
No description provided.