-
Notifications
You must be signed in to change notification settings - Fork 51
Closed
Description
Hello,
It looks like binaryen.readBinary is removing the name custom section. No other custom sections in my test case are removed.
I start with a raw Wasm binary file that does have a name section, here is the result of wasm-objdump -h:
wasm-objdump -h wasm_before_raw.wasm
wasm_before_raw.wasm: file format wasm 0x1
module name: <stable_canister_template.wasm>
Sections:
Type start=0x0000000b end=0x000004c7 (size=0x000004bc) count: 147
Import start=0x000004ca end=0x00000886 (size=0x000003bc) count: 41
Function start=0x00000889 end=0x000015db (size=0x00000d52) count: 3327
Table start=0x000015dd end=0x000015e4 (size=0x00000007) count: 1
Memory start=0x000015e6 end=0x000015e9 (size=0x00000003) count: 1
Global start=0x000015eb end=0x000015f4 (size=0x00000009) count: 1
Export start=0x000015f7 end=0x00001cc3 (size=0x000006cc) count: 63
Elem start=0x00001cc6 end=0x000024fd (size=0x00000837) count: 1
Code start=0x00002502 end=0x00220dbc (size=0x0021e8ba) count: 3327
Data start=0x00220dc0 end=0x00279180 (size=0x000583c0) count: 2
Custom start=0x00279184 end=0x002ac5d1 (size=0x0003344d) "name"
Custom start=0x002ac5d4 end=0x002ac69a (size=0x000000c6) "producers"
Custom start=0x002ac69c end=0x002ac6f2 (size=0x00000056) "target_features"And then I run this TypeScript code:
export async function getModule(
wasmBinaryPath: string
): Promise<binaryen.Module> {
const originalWasm = await readFile(wasmBinaryPath);
const module = binaryen.readBinary(originalWasm);
return module;
}And I write the binary to a file just after calling getModule:
const module = await getModule(canisterTemplatePath);
await writeFile('wasm_before.wasm', module.emitBinary());When I run wasm-objdump -h on wasm_before.wasm I get this:
wasm-objdump -h wasm_before.wasm
wasm_before.wasm: file format wasm 0x1
Sections:
Type start=0x0000000b end=0x000004c7 (size=0x000004bc) count: 147
Import start=0x000004ca end=0x00000881 (size=0x000003b7) count: 41
Function start=0x00000884 end=0x00001598 (size=0x00000d14) count: 3327
Table start=0x0000159a end=0x000015a1 (size=0x00000007) count: 1
Memory start=0x000015a3 end=0x000015a6 (size=0x00000003) count: 1
Global start=0x000015a8 end=0x000015b1 (size=0x00000009) count: 1
Export start=0x000015b4 end=0x00001c80 (size=0x000006cc) count: 63
Elem start=0x00001c83 end=0x000024ba (size=0x00000837) count: 1
DataCount start=0x000024bc end=0x000024bd (size=0x00000001) count: 2
Code start=0x000024c2 end=0x00221324 (size=0x0021ee62) count: 3327
Data start=0x00221328 end=0x002796e8 (size=0x000583c0) count: 2
Custom start=0x002796eb end=0x002797b1 (size=0x000000c6) "producers"
Custom start=0x002797b3 end=0x0027981a (size=0x00000067) "target_features"I'm currently on version 116.0.0, but even updating temporarily to 123.0.0 has not solved the problem.
Metadata
Metadata
Assignees
Labels
No labels