Files
rea/tests/boundary/providers/native/nativeLoadText.golden.test.ts
T
Kaoru0822 30ba5e99f9 fix(native): keep a dylib's own install name out of its dependencies (#4050)
inspect-macho listed the LC_ID_DYLIB command of a dylib as a dependency,
so every dylib reported a self-dependency and an inflated exhaustive
count, while trace-dylib-resolution correctly treats that name as the
image identity. The dependency collector now skips LC_ID_DYLIB; the
command, with its install name, remains in the raw load commands.

Fixes #3872

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 03:42:03 -07:00

38 lines
1.2 KiB
TypeScript

import { expect, it } from "vitest";
import { parseOtoolLoadCommands } from "../../../../src/native/parsers/otool.js";
import {
nativeFixture,
withOtoolMachHeader,
} from "../../../fixtures/nativeCommands.js";
it.each([
["decimal-space", "123 library.dylib"],
["hex-space", "0x123 library.dylib"],
["decimal", "123"],
["hex", "0x123"],
["ordinary", "ordinary.dylib"],
])("preserves native install-name text from %s capture", async (slug, name) => {
const load = parseOtoolLoadCommands(
withOtoolMachHeader(
await nativeFixture(`load-command-text-values/${slug}.txt`),
),
);
// The image's own install name is identity, not a dependency.
expect(load.dependencies.map(({ kind }) => kind)).not.toContain(
"LC_ID_DYLIB",
);
expect(
load.commands.find((command) => command.kind === "LC_ID_DYLIB")?.fields
.name,
).toBe(`${name} (offset 24)`);
const text = load.segments.find((segment) => segment.name === "__TEXT");
expect(text).toMatchObject({
file_offset: 0,
file_size: 16384,
initial_permissions: { read: true, write: false, execute: true },
});
expect(
load.commands.find((command) => command.kind === "LC_SEGMENT_64")?.fields
.cmdsize,
).toBe(232);
});