From fcd477faf8fd0b4959f927db1f36590b317fa2b7 Mon Sep 17 00:00:00 2001 From: ArjenS-LA Date: Wed, 14 Oct 2026 15:35:59 -0700 Subject: [PATCH] fix(tools): normalize qualified ELF module exports --- tools/import_audit.py | 2 +- tools/tests/test_import_audit.py | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/tools/import_audit.py b/tools/import_audit.py index bc819fc9bf2b..993ba42611ee 100644 --- a/tools/import_audit.py +++ b/tools/import_audit.py @@ -182,7 +182,7 @@ def elf_exports(path, data): binding, visibility = info >> 4, other & 3 if name == 0 or index == 0 or binding not in (1, 2, 10) or visibility not in (0, 3): continue - names.add(cstring(data, strings_offset + name, strings_offset + strings_size, path, "export name")) + names.add(cstring(data, strings_offset + name, strings_offset + strings_size, path, "export name").split(MODULE_SUFFIX, 1)[0]) return names diff --git a/tools/tests/test_import_audit.py b/tools/tests/test_import_audit.py index 2b6bf042f62c..ec05e0e37169 100644 --- a/tools/tests/test_import_audit.py +++ b/tools/tests/test_import_audit.py @@ -635,6 +635,33 @@ def test_module_symbol_suffix_is_stripped(self): self.assertEqual(data["unique_by_class"], {"implemented": 1, "stub": 0, "absent": 0, "module": 0}) self.assertEqual(data["references"], 1) + def test_module_export_suffix_is_stripped_with_and_without_sections(self): + work = self.work + nid = nid_names.compute_nid("sceModuleCall") + (work.libs / "libSceA.prx").write_bytes(exporting()) + (work.modules / "consumer.prx").write_bytes(build_elf([ + (nid + "#import#module", 0, GLOBAL_FUNCTION)])) + provider = work.modules / "provider.prx" + registry, result = work.root / "game.json", work.root / "audit.json" + write_registry(registry, []) + symbols = [(nid + "#export#module", 1, GLOBAL_FUNCTION)] + for layout, image in (("sections", build_elf(symbols)), + ("sysv", build_sectionless_elf(symbols)), + ("gnu", build_sectionless_elf(symbols, gnu_hash=True))): + with self.subTest(layout=layout): + provider.write_bytes(image) + code, out, err = work.run(registry, "--json", str(result)) + self.assertEqual((code, err), (0, "")) + record, = json.loads(result.read_text())["imports"] + self.assertEqual((record["nid"], record["class"], record["providers"]), + (nid, "implemented", ["provider.prx"])) + self.assertEqual(record["module"], "consumer.prx") + provider.write_bytes(exporting(nid + "other#export#module")) + code, out, err = work.run(registry, "--json", str(result)) + self.assertEqual((code, err), (1, "")) + record, = json.loads(result.read_text())["imports"] + self.assertEqual((record["nid"], record["class"], record["providers"]), (nid, "absent", [])) + def test_clean_audit_exits_zero_and_empty_registry_is_empty(self): work = self.work (work.libs / "libSceA.prx").write_bytes(exporting("AAAAAAAAAAA"))