Browse Source

* WebAssembly threads internal linker: declare the symbol __wasm_init_tls in the
.text section (function will be generated later by the linker)

Nikolay Nikolov 1 year ago
parent
commit
0642f14552
1 changed files with 13 additions and 4 deletions
  1. 13 4
      compiler/systems/t_wasi.pas

+ 13 - 4
compiler/systems/t_wasi.pas

@@ -345,11 +345,20 @@ begin
     is important to keep the sections grouped, and keep the first section in
     is important to keep the sections grouped, and keep the first section in
     each group intact (otherwise, TWasmExeOutput.MemPos_ExeSection in ogwasm.pas
     each group intact (otherwise, TWasmExeOutput.MemPos_ExeSection in ogwasm.pas
     needs to be updated) }
     needs to be updated) }
+  { tags (used by WebAssembly native exceptions) }
+  ScriptAddGenericSections('.wasm_tags');
+  { code }
+  if ts_wasm_threads in current_settings.targetswitches then
+    begin
+      linkscript.Concat('EXESECTION .text');
+      linkscript.Concat('  OBJSECTION .text*');
+      { functions, generated by the linker: }
+      linkscript.Concat('  SYMBOL __wasm_init_tls');
+      linkscript.Concat('ENDEXESECTION');
+    end
+  else
+    ScriptAddGenericSections('.text');
   ScriptAddGenericSections(
   ScriptAddGenericSections(
-    { tags (used by WebAssembly native exceptions) }
-    '.wasm_tags,'+
-    { code }
-    '.text,'+
     { data (initialized data first, uninitialized data later) }
     { data (initialized data first, uninitialized data later) }
     '.rodata,.data,fpc.resources,fpc.reshandles,.bss,'+
     '.rodata,.data,fpc.resources,fpc.reshandles,.bss,'+
     { debug info }
     { debug info }