fix(wasm): accept unpadded WABT section rows (#1963)

* fix(wasm): accept unpadded WABT section rows

WABT 1.0.42 right-aligns section names in a nine-column field. DataCount
fills that field, so its objdump row has no leading whitespace. Accept
that legal row. Header recognition, the required field shape, and section
range checks still reject malformed output.

Fixes #1956

* fix(ci): refresh MIPS expectations and Windows test paths

Assert admitted soft-float ABI metadata and its committed storage policy through the public target resolver, retain FP64 rejection, and point the curated Windows lane at the moved filesystem reconstruction tests.

Validation: reproduced all four prior failures; 97 focused tests and check:ci pass. Native Windows and real Ghidra execution were not performed locally.

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
Nithilan Kumaran
2026-10-12 05:29:04 +08:00
committed by GitHub
co-authored by morluto
parent beb80a07ba
commit 9eee709f0c
6 changed files with 147 additions and 12 deletions
+104
View File
@@ -33,6 +33,110 @@ it("retains real WABT section ranges, custom section identity and original heade
["test"],
),
).toThrow(/Unrecognized/u);
expect(() =>
parseWabtOutput(
text.replace(
"\nSection Details:\n",
"\nDataCount start=0x00000040 end=0x0000004c (size=0x0000000c)\nSection Details:\n",
),
76,
["test"],
),
).toThrow(/Unrecognized/u);
});
const dataCountModuleBytes = 0x3d;
const unpaddedDataCountRow =
"DataCount start=0x00000023 end=0x00000024 (size=0x00000001) count: 1";
const dataCountDump = [
"",
"module.wasm:\tfile format wasm 0x1",
"",
"Sections:",
"",
" Type start=0x0000000a end=0x0000000e (size=0x00000004) count: 1",
" Function start=0x00000010 end=0x00000012 (size=0x00000002) count: 1",
" Memory start=0x00000014 end=0x00000017 (size=0x00000003) count: 1",
" Export start=0x00000019 end=0x00000021 (size=0x00000008) count: 1",
unpaddedDataCountRow,
" Code start=0x00000026 end=0x00000037 (size=0x00000011) count: 1",
" Data start=0x00000039 end=0x0000003d (size=0x00000004) count: 1",
"",
"Section Details:",
"",
].join("\n");
it("accepts an unpadded DataCount row and still rejects malformed output and bad ranges", () => {
const parsed = parseWabtOutput(dataCountDump, dataCountModuleBytes, []);
expect(parsed.sections.map(({ kind }) => kind)).toEqual([
"Type",
"Function",
"Memory",
"Export",
"DataCount",
"Code",
"Data",
]);
expect(parsed.sections.find(({ kind }) => kind === "DataCount")).toEqual({
kind: "DataCount",
start: 0x23,
end: 0x24,
bytes: 1,
description: "count: 1",
});
expect(parsed.headers).toContain(`\n${unpaddedDataCountRow}\n`);
expect(() =>
parseWabtOutput(
dataCountDump.replace(unpaddedDataCountRow, "DataCount count: 1"),
dataCountModuleBytes,
[],
),
).toThrow(/Unrecognized/u);
expect(() =>
parseWabtOutput(
dataCountDump.replace(unpaddedDataCountRow, "Sections:"),
dataCountModuleBytes,
[],
),
).toThrow(/Unrecognized/u);
expect(() =>
parseWabtOutput(
dataCountDump.replace(
unpaddedDataCountRow,
"DataCount start=0x00000023 end=0x00000024 (size=0x00000001)count: 1",
),
dataCountModuleBytes,
[],
),
).toThrow(/Unrecognized/u);
expect(() =>
parseWabtOutput(
dataCountDump.replace("(size=0x00000001)", "(size=0x00000002)"),
dataCountModuleBytes,
[],
),
).toThrow(/ranges/u);
expect(() =>
parseWabtOutput(
dataCountDump.replace(
"DataCount start=0x00000023 end=0x00000024 (size=0x00000001)",
"DataCount start=0x00000020 end=0x00000021 (size=0x00000001)",
),
dataCountModuleBytes,
[],
),
).toThrow(/ranges/u);
expect(() =>
parseWabtOutput(dataCountDump, dataCountModuleBytes - 1, []),
).toThrow(/ranges/u);
expect(() =>
parseWabtOutput(
dataCountDump.replace(
"\nmodule.wasm:\tfile format wasm 0x1\n\nSections:\n\n",
"",
),
dataCountModuleBytes,
[],
),
).toThrow(/header/u);
});
it("extracts escaped WAT import/export forms while retaining multiline producer text", async () => {
const text = await readFile(
+1 -1
View File
@@ -13,7 +13,7 @@ export const parseWabtOutput = (
const sections = [];
while (!text.startsWith("\nSection Details:\n", offset)) {
const match =
/^[ \t]+(\w+) start=0x([\da-f]+) end=0x([\da-f]+) \(size=0x([\da-f]+)\) /u.exec(
/^[ \t]*(\w+) start=0x([\da-f]+) end=0x([\da-f]+) \(size=0x([\da-f]+)\) /u.exec(
text.slice(offset),
);
if (match === null) throw new Error("Unrecognized WABT section row.");