line up iggy signatures across every platform build
This commit is contained in:
@@ -249,6 +249,13 @@ python3 "$ROOT/match-iggy-functions.py" \
|
||||
-postScript ExportDecompiled.java "$OUTPUT_DIR/raw/windows" \
|
||||
-deleteProject > "$WORK_DIR/iggy-windows-named.log" 2>&1
|
||||
|
||||
python3 "$ROOT/merge-iggy-signatures.py" \
|
||||
"$OUTPUT_DIR/symbols/cross-platform-signatures.tsv" \
|
||||
"durango=$OUTPUT_DIR/symbols/signatures/durango" \
|
||||
"orbis=$OUTPUT_DIR/symbols/signatures/orbis" \
|
||||
"ps3=$OUTPUT_DIR/symbols/signatures/ps3" \
|
||||
"vita=$OUTPUT_DIR/symbols/signatures/vita"
|
||||
|
||||
python3 "$ROOT/summarize-iggy-decomp.py" \
|
||||
"$OUTPUT_DIR/raw/durango" "$OUTPUT_DIR/symbols/iggy_durango.members.txt" \
|
||||
"$OUTPUT_DIR/symbols/iggy_durango.modules.tsv"
|
||||
|
||||
@@ -33,6 +33,8 @@ renderer, shader, and public-header source files that were shipped unobfuscated.
|
||||
`include` contains the canonical public ABI headers used for type reconciliation.
|
||||
The per-module and linked-view prototypes are exported under
|
||||
`symbols/signatures` as machine-readable TSV files after ABI typing.
|
||||
`symbols/cross-platform-signatures.tsv` aligns same-named function occurrences
|
||||
by original module across Durango, Orbis, PS3, and Vita for type reconciliation.
|
||||
|
||||
The shipped ABI headers are parsed and applied automatically to matching public
|
||||
functions before export. Internal structures, locals, and non-public signatures
|
||||
|
||||
@@ -55,6 +55,12 @@ signatures. PS3 descriptor symbols are normalized from `.Iggy*` before lookup,
|
||||
so its public API now receives the same header-derived parameter types as the
|
||||
other three archive builds.
|
||||
|
||||
The core signature tables are also joined by original module and normalized
|
||||
symbol name in `symbols/cross-platform-signatures.tsv`. Duplicate static names
|
||||
are retained as ordered occurrences instead of being silently collapsed. The
|
||||
joined index has 5,756 occurrences: 2,416 are independently present in all four
|
||||
builds and another 1,100 are present in three.
|
||||
|
||||
Whole-archive linking recovered all analyzed function names in the cross-module
|
||||
views. The core view combines PDB public symbols with 746 linker-map-only static
|
||||
function names and 636 static data names. Perfmon adds 63 static function names
|
||||
|
||||
5757
iggy-decompiled/symbols/cross-platform-signatures.tsv
Normal file
5757
iggy-decompiled/symbols/cross-platform-signatures.tsv
Normal file
File diff suppressed because it is too large
Load Diff
107
merge-iggy-signatures.py
Normal file
107
merge-iggy-signatures.py
Normal file
@@ -0,0 +1,107 @@
|
||||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
from collections import defaultdict
|
||||
import csv
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
SIGNATURE_FIELDS = (
|
||||
"address",
|
||||
"calling_convention",
|
||||
"return_type",
|
||||
"parameter_count",
|
||||
"variadic",
|
||||
"prototype",
|
||||
)
|
||||
|
||||
|
||||
def normalize_name(name: str) -> str:
|
||||
return name.lstrip("._")
|
||||
|
||||
|
||||
def address_key(row: dict[str, str]) -> tuple[int, str]:
|
||||
address = row["address"]
|
||||
try:
|
||||
return int(address, 16), address
|
||||
except ValueError:
|
||||
return 0, address
|
||||
|
||||
|
||||
def parse_platform(value: str) -> tuple[str, Path]:
|
||||
if "=" not in value:
|
||||
raise argparse.ArgumentTypeError("platform inputs must use NAME=DIRECTORY")
|
||||
name, directory = value.split("=", 1)
|
||||
if not name or not directory:
|
||||
raise argparse.ArgumentTypeError("platform inputs must use NAME=DIRECTORY")
|
||||
path = Path(directory)
|
||||
if not path.is_dir():
|
||||
raise argparse.ArgumentTypeError(f"signature directory does not exist: {path}")
|
||||
return name, path
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("output", type=Path)
|
||||
parser.add_argument("platform", nargs="+", type=parse_platform)
|
||||
args = parser.parse_args()
|
||||
|
||||
platforms = [name for name, _ in args.platform]
|
||||
if len(platforms) != len(set(platforms)):
|
||||
parser.error("platform names must be unique")
|
||||
|
||||
signatures = defaultdict(lambda: defaultdict(list))
|
||||
for platform, directory in args.platform:
|
||||
for path in sorted(directory.glob("*.tsv")):
|
||||
with path.open(newline="", encoding="utf-8") as handle:
|
||||
reader = csv.DictReader(handle, delimiter="\t")
|
||||
for row in reader:
|
||||
key = path.stem, normalize_name(row["name"])
|
||||
signatures[key][platform].append(row)
|
||||
|
||||
fieldnames = ["module", "name", "occurrence", "platform_count"]
|
||||
fieldnames.extend(
|
||||
f"{platform}_{field}"
|
||||
for platform in platforms
|
||||
for field in SIGNATURE_FIELDS
|
||||
)
|
||||
|
||||
args.output.parent.mkdir(parents=True, exist_ok=True)
|
||||
output_rows = 0
|
||||
with args.output.open("w", newline="", encoding="utf-8") as handle:
|
||||
writer = csv.DictWriter(
|
||||
handle,
|
||||
fieldnames=fieldnames,
|
||||
delimiter="\t",
|
||||
lineterminator="\n",
|
||||
)
|
||||
writer.writeheader()
|
||||
for (module, name), by_platform in sorted(signatures.items()):
|
||||
for rows in by_platform.values():
|
||||
rows.sort(key=address_key)
|
||||
occurrences = max(len(rows) for rows in by_platform.values())
|
||||
for occurrence in range(occurrences):
|
||||
output = {
|
||||
"module": module,
|
||||
"name": name,
|
||||
"occurrence": occurrence + 1,
|
||||
"platform_count": sum(
|
||||
occurrence < len(by_platform.get(platform, ()))
|
||||
for platform in platforms
|
||||
),
|
||||
}
|
||||
for platform in platforms:
|
||||
rows = by_platform.get(platform, ())
|
||||
if occurrence >= len(rows):
|
||||
continue
|
||||
row = rows[occurrence]
|
||||
for field in SIGNATURE_FIELDS:
|
||||
output[f"{platform}_{field}"] = row[field]
|
||||
writer.writerow(output)
|
||||
output_rows += 1
|
||||
|
||||
print(f"merged {output_rows} function occurrences across {len(platforms)} platforms")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
82
tests/test_merge_iggy_signatures.py
Normal file
82
tests/test_merge_iggy_signatures.py
Normal file
@@ -0,0 +1,82 @@
|
||||
import csv
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
SCRIPT = ROOT / "merge-iggy-signatures.py"
|
||||
HEADER = [
|
||||
"address",
|
||||
"name",
|
||||
"calling_convention",
|
||||
"return_type",
|
||||
"parameter_count",
|
||||
"variadic",
|
||||
"prototype",
|
||||
]
|
||||
|
||||
|
||||
class MergeIggySignaturesTests(unittest.TestCase):
|
||||
def test_merges_platform_names_and_preserves_duplicate_occurrences(self):
|
||||
with tempfile.TemporaryDirectory() as temporary_directory:
|
||||
root = Path(temporary_directory)
|
||||
platform_directories = {}
|
||||
for platform in ("durango", "orbis", "ps3", "vita"):
|
||||
directory = root / platform
|
||||
directory.mkdir()
|
||||
platform_directories[platform] = directory
|
||||
|
||||
self.write_signatures(
|
||||
platform_directories["durango"] / "iggy_main.tsv",
|
||||
[
|
||||
["1000", "IggyFoo", "__stdcall", "void", "1", "0", "void IggyFoo(Iggy * f)"],
|
||||
["1010", "helper", "unknown", "int", "1", "0", "int helper(int value)"],
|
||||
["1020", "helper", "unknown", "int", "2", "0", "int helper(int a, int b)"],
|
||||
],
|
||||
)
|
||||
self.write_signatures(
|
||||
platform_directories["orbis"] / "iggy_main.tsv",
|
||||
[["2000", "IggyFoo", "unknown", "void", "1", "0", "void IggyFoo(Iggy * f)"]],
|
||||
)
|
||||
self.write_signatures(
|
||||
platform_directories["ps3"] / "iggy_main.tsv",
|
||||
[["3000", ".IggyFoo", "unknown", "void", "1", "0", "void .IggyFoo(Iggy * f)"]],
|
||||
)
|
||||
self.write_signatures(
|
||||
platform_directories["vita"] / "iggy_main.tsv",
|
||||
[["4000", "_IggyFoo", "unknown", "void", "1", "0", "void _IggyFoo(Iggy * f)"]],
|
||||
)
|
||||
|
||||
output = root / "cross-platform.tsv"
|
||||
command = ["python3", str(SCRIPT), str(output)]
|
||||
command.extend(
|
||||
f"{platform}={directory}"
|
||||
for platform, directory in platform_directories.items()
|
||||
)
|
||||
result = subprocess.run(command, capture_output=True, text=True)
|
||||
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
|
||||
|
||||
with output.open(newline="", encoding="utf-8") as handle:
|
||||
rows = list(csv.DictReader(handle, delimiter="\t"))
|
||||
|
||||
self.assertEqual(len(rows), 3)
|
||||
foo = next(row for row in rows if row["name"] == "IggyFoo")
|
||||
self.assertEqual(foo["platform_count"], "4")
|
||||
self.assertEqual(foo["ps3_address"], "3000")
|
||||
self.assertEqual(foo["vita_address"], "4000")
|
||||
helpers = [row for row in rows if row["name"] == "helper"]
|
||||
self.assertEqual([row["occurrence"] for row in helpers], ["1", "2"])
|
||||
self.assertEqual(helpers[1]["durango_parameter_count"], "2")
|
||||
self.assertEqual(helpers[1]["platform_count"], "1")
|
||||
|
||||
def write_signatures(self, path, rows):
|
||||
with path.open("w", newline="", encoding="utf-8") as handle:
|
||||
writer = csv.writer(handle, delimiter="\t", lineterminator="\n")
|
||||
writer.writerow(HEADER)
|
||||
writer.writerows(rows)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user