Documentation
¶
Overview ¶
Command patchdata writes the start address of .data, and the ranges of the globals that hold no heap pointers, into a TinyGo core built with the runtime fork in budget/tinygo.
patchdata <module.wasm> <linker.map>
The fork's findGlobals scans the globals from the address stored after the 8-byte marker "PiGDDATA" (runtime pigDataStart) instead of from __global_base, so the GC does not take .rodata words for heap pointers. wasm-ld defines no symbol for the start of .data, so build-wasm.sh links with --Map and this command takes the address of the .data output section from the map. It fails when the map has no .data section, when a memory section other than .rodata starts below .data, when the module holds the marker other than exactly once, or when the word is already set: a build cannot fall back to scanning .rodata, or skip a writable section, without failing.
The words after the address are [start, end) pairs the scan leaves out: the .data and .bss symbols in pointerFreeGlobals, merged where adjacent. It fails when they need more pairs than the runtime holds, or when the pairs are not unset.