fix(wasm): preserve debug module names in WABT output (#1967)
* fix(wasm): preserve debug module names in WABT output * fix(native): accept otool dylib-use options Preserve modern dylib options while requiring one encoding metadata row and retaining duplicate and multiline-output checks. Share field parsing between preservation and validation. Verify delayed dylibs through real macOS CLI/MCP workflows and refresh the high-address golden with the provider's -h -l capture. Validated 85 focused native tests, npm run check, and verify:macos-bundle on macOS arm64. --------- Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
@@ -32,6 +32,69 @@ it("retains lazily loaded library dependencies", () => {
|
||||
});
|
||||
});
|
||||
|
||||
// Captured from the real Apple bundle CI fixture's `otool -h -l` output.
|
||||
const delayedDylib = withOtoolMachHeader(`Load command 0
|
||||
cmd LC_LOAD_DYLIB
|
||||
cmdsize 56
|
||||
name @rpath/libdelay.dylib (offset 28)
|
||||
options delay-init
|
||||
current version 0.0.0
|
||||
compatibility version 1.0.0
|
||||
`);
|
||||
|
||||
it("preserves dylib-use options through native Mach-O inspection", async () => {
|
||||
const runner = new NativeFixtureRunner({ "otool:-h": delayedDylib });
|
||||
const client = new NativeMacOSProvider({}, runner, "darwin").createClient(
|
||||
nativeMachoTarget("/owned/fixture"),
|
||||
);
|
||||
const result = await client.execute("inspect_macho", {});
|
||||
if (!result.ok) throw result.error;
|
||||
expect(result.value.result).toMatchObject({
|
||||
load_commands: {
|
||||
items: [{ kind: "LC_LOAD_DYLIB", fields: { options: "delay-init" } }],
|
||||
},
|
||||
dependencies: {
|
||||
items: [
|
||||
{
|
||||
path: "@rpath/libdelay.dylib",
|
||||
kind: "LC_LOAD_DYLIB",
|
||||
current_version: "0.0.0",
|
||||
compatibility_version: "1.0.0",
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("retains empty dylib-use options and rejects missing or ambiguous encoding fields", () => {
|
||||
expect(
|
||||
parseOtoolLoadCommands(delayedDylib.replace("delay-init", "")).commands[0]
|
||||
?.fields.options,
|
||||
).toBe("");
|
||||
const malformed: Array<readonly [string, RegExp]> = [
|
||||
["", /timestamp or options/u],
|
||||
[
|
||||
" options delay-init\n options weak\n",
|
||||
/options is missing or repeated/u,
|
||||
],
|
||||
[
|
||||
" options delay-init\n time stamp 2 Thu Jan 1 00:00:02 1970\n",
|
||||
/timestamp or options/u,
|
||||
],
|
||||
[
|
||||
" options delay-init\n injected text\n",
|
||||
/ambiguous multiline text/u,
|
||||
],
|
||||
];
|
||||
for (const [replacement, reason] of malformed) {
|
||||
expect(() =>
|
||||
parseOtoolLoadCommands(
|
||||
delayedDylib.replace(" options delay-init\n", replacement),
|
||||
),
|
||||
).toThrow(reason);
|
||||
}
|
||||
});
|
||||
|
||||
it("preserves dependency install names that begin with the word stamp", () => {
|
||||
const load = parseOtoolLoadCommands(
|
||||
withOtoolMachHeader(
|
||||
|
||||
+1
-1
@@ -23,5 +23,5 @@ section = struct.pack(
|
||||
)
|
||||
Path('/tmp/rea-high-address.macho').write_bytes(header + segment + section + b'\xc0')
|
||||
PY
|
||||
xcrun otool -l /tmp/rea-high-address.macho
|
||||
xcrun otool -h -l /tmp/rea-high-address.macho
|
||||
```
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
fixture:
|
||||
Mach header
|
||||
magic cputype cpusubtype caps filetype ncmds sizeofcmds flags
|
||||
0xfeedfacf 16777228 0 0x00 5 1 152 0x00000000
|
||||
Load command 0
|
||||
cmd LC_SEGMENT_64
|
||||
cmdsize 152
|
||||
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
(module
|
||||
(@custom "name" "\00\01\00")
|
||||
(@custom "name" "\00\ad\01\ab\01unicode-\c3\a9 >\0a\0aSections:\0a\0aa-long-package-path/a-long-package-path/a-long-package-path/a-long-package-path/a-long-package-path/a-long-package-path/a-long-package-path/inside")
|
||||
(@custom "name" "\00\0f\0evisible\00hidden"))
|
||||
Reference in New Issue
Block a user