Browse Source

* WebAssembly threads internal linker: generate passive data segments, when multithreading is on

Nikolay Nikolov 1 year ago
parent
commit
4d48e7e4d3
1 changed files with 9 additions and 4 deletions
  1. 9 4
      compiler/ogwasm.pas

+ 9 - 4
compiler/ogwasm.pas

@@ -4669,11 +4669,16 @@ implementation
             exesecdatapos: LongWord;
             exesecdatapos: LongWord;
             dpos, pad: QWord;
             dpos, pad: QWord;
           begin
           begin
-            WriteByte(FWasmSections[wsiData],0);
+            if ts_wasm_threads in current_settings.targetswitches then
+              WriteByte(FWasmSections[wsiData],1)  { mode passive }
+            else
+              begin
+                WriteByte(FWasmSections[wsiData],0);  { mode active, memory 0, offset e }
 
 
-            WriteByte(FWasmSections[wsiData],$41);  { i32.const }
-            WriteSleb(FWasmSections[wsiData],longint(exesec.MemPos));
-            WriteByte(FWasmSections[wsiData],$0B);  { end }
+                WriteByte(FWasmSections[wsiData],$41);  { i32.const }
+                WriteSleb(FWasmSections[wsiData],longint(exesec.MemPos));
+                WriteByte(FWasmSections[wsiData],$0B);  { end }
+              end;
 
 
             WriteUleb(FWasmSections[wsiData],exesec.Size);
             WriteUleb(FWasmSections[wsiData],exesec.Size);
             exesecdatapos:=FWasmSections[wsiData].size;
             exesecdatapos:=FWasmSections[wsiData].size;