fix(ghidra): bound Swift literal reads and compare decoded strings

Large immortal literals are measured against the remaining heap before
allocation, and a failed fit stays visible as a limitation. The canonical
empty string is kept. Small and large literals now require matching
address nullability, and function comparison treats decoded literals as
string evidence without equating a missing record to an empty one.
This commit is contained in:
Cursor Agent
2026-10-12 05:04:18 +00:00
parent 2f89a1b5c0
commit 702dc9f932
6 changed files with 212 additions and 43 deletions
@@ -139,6 +139,18 @@ const compareStringsAndNames = (
right: FunctionSnapshot,
context: ComparisonContext,
): FunctionDimension => {
const leftRecorded = left.dossier.swift_string_literals !== undefined;
const rightRecorded = right.dossier.swift_string_literals !== undefined;
if (leftRecorded !== rightRecorded)
return unresolvedDimension({
dimension: "strings_names",
links: context.links,
leftCount: recordedStringFactCount(left),
rightCount: recordedStringFactCount(right),
limitations: [
"Swift String literal coverage differs; one dossier did not record decoded literals.",
],
});
const leftValues = stringAndNameProjection(left);
const rightValues = stringAndNameProjection(right);
if (leftValues === null || rightValues === null)
@@ -154,6 +166,13 @@ const compareStringsAndNames = (
return compareValues("strings_names", leftValues, rightValues, context);
};
const recordedStringFactCount = (snapshot: FunctionSnapshot): number | null =>
snapshot.dossier.swift_string_literals === undefined
? null
: snapshot.dossier.referenced_strings.length +
snapshot.dossier.referenced_names.length +
snapshot.dossier.swift_string_literals.length;
const compareReferences = (
left: FunctionSnapshot,
right: FunctionSnapshot,