fix(native): retain spaced symbols in dyld inventory (#669)

Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com>
This commit is contained in:
Rudy Mizrahi Celekli
2026-10-06 03:18:09 -05:00
committed by GitHub
parent ddea06360a
commit fa02df9ad3
2 changed files with 54 additions and 3 deletions
+3 -3
View File
@@ -17,7 +17,7 @@ export const parseDyldSymbols = (
const line = rawLine.trim();
if (mode === "imports") {
const imported =
/^(?:0x[\da-f]+\s+)?(\S+)(?:\s+\[([^\]]+)\])?\s+\(from (.+)\)$/iu.exec(
/^(?:0x[\da-f]+\s+)?(.+?)(?:\s+\[([^\]]+)\])?\s+\(from (.+)\)$/iu.exec(
line,
);
if (imported?.[1] !== undefined)
@@ -32,7 +32,7 @@ export const parseDyldSymbols = (
];
return [];
}
const reexport = /^\[re-export\]\s+(\S+)(?:\s+\(from (.+)\))?$/u.exec(line);
const reexport = /^\[re-export\]\s+(.+?)(?:\s+\(from (.+)\))?$/u.exec(line);
if (reexport?.[1] !== undefined)
return [
{
@@ -43,7 +43,7 @@ export const parseDyldSymbols = (
source: reexport[2] ?? null,
},
];
const exported = /^(0x[\da-f]+)\s+(\S+)(?:\s+\[([^\]]+)\])?$/iu.exec(line);
const exported = /^(0x[\da-f]+)\s+(.+?)(?:\s+\[([^\]]+)\])?$/iu.exec(line);
if (exported?.[1] === undefined || exported[2] === undefined) return [];
const absolute = /\babsolute\b/u.test(exported[3] ?? "");
const address =
@@ -115,3 +115,54 @@ it("retains native inventory facts from captured Apple tool output", async () =>
source: null,
});
});
it("retains symbol names containing spaces in dyld inventory rows", () => {
expect(
parseDyldSymbols(" 0x0000 _entry with space (from fixture)", "imports"),
).toEqual([
{
name: "_entry with space",
address: null,
weak: null,
reexport: null,
source: "fixture",
},
]);
expect(
parseDyldSymbols(
" offset symbol\n 0x00000348 _entry with space",
"exports",
"0x0",
),
).toEqual([
{
name: "_entry with space",
address: "0x348",
weak: null,
reexport: false,
source: null,
},
]);
expect(
parseDyldSymbols("[re-export] _entry with space (from fixture)", "exports"),
).toEqual([
{
name: "_entry with space",
address: null,
weak: null,
reexport: true,
source: "fixture",
},
]);
expect(
parseDyldSymbols("0x123 _weak with space [weak-def]", "exports"),
).toEqual([
{
name: "_weak with space",
address: "0x123",
weak: true,
reexport: false,
source: null,
},
]);
});