@@ -604,21 +604,23 @@ export let createStartSection = (wasmBinary, dependencyChain, wasmData) => {
604
604
...wasmBinary.localNames
605
605
]
606
606
// TODO: Support WASI
607
- wasmBinary.startSection = listToBuffer(
608
- Encoder.encodeUIntLeb128(wasmData.funcCount)
609
- )
610
- // // Push The Start Export to be Wasi Compatible
611
- // let startExport = Buffer.make(0)
612
- // // Export Name
613
- // appendBufferByteList(Encoder.encodeString("_start"), startExport)
614
- // // Export Type
615
- // appendBufferByteList(
616
- // [
617
- // 0x00, // Function Export Kind
618
- // ...Encoder.encodeUIntLeb128(wasmData.funcCount)
619
- // ],
620
- // startExport
607
+ // wasmBinary.startSection = listToBuffer(
608
+ // Encoder.encodeUIntLeb128(wasmData.funcCount)
621
609
// )
610
+ // Push The Start Export to be Wasi Compatible
611
+ let startExport = Buffer.make(0)
612
+ // Export Name
613
+ appendBufferByteList(Encoder.encodeString("_start"), startExport)
614
+ // Export Type
615
+ appendBufferByteList(
616
+ [
617
+ 0x00, // Function Export Kind
618
+ ...Encoder.encodeUIntLeb128(wasmData.funcCount)
619
+ ],
620
+ startExport
621
+ )
622
+ // Export Start
623
+ wasmBinary.exportSection = [startExport, ...wasmBinary.exportSection]
622
624
}
623
625
export let createElementSection = (wasmBinary, dependencyChain, wasmData) => {
624
626
let mut elementOffset = 0
@@ -850,7 +852,9 @@ export let buildBinary = wasmBinaryContent => {
850
852
Buffer.addBuffer(memorySection, wasmBinary)
851
853
Buffer.addBuffer(globalSection, wasmBinary)
852
854
Buffer.addBuffer(exportSection, wasmBinary)
853
- Buffer.addBuffer(startSection, wasmBinary)
855
+ if (Buffer.length(wasmBinaryContent.startSection) != 0) {
856
+ Buffer.addBuffer(startSection, wasmBinary)
857
+ }
854
858
Buffer.addBuffer(elementSection, wasmBinary)
855
859
Buffer.addBuffer(codeSection, wasmBinary)
856
860
// let wasmBinary = createDataSection(wasmBinary, dependencyChain, wasmData)
0 commit comments