Browse Source

* WebAssembly threads internal linker: set MemPos for data sections correctly
when threads are enabled (take into account that the first data section with
threads enabled is .tbss, instead of .rodata)

Nikolay Nikolov 1 year ago
parent
commit
7e938ffafc
1 changed files with 6 additions and 1 deletions
  1. 6 1
      compiler/ogwasm.pas

+ 6 - 1
compiler/ogwasm.pas

@@ -5099,12 +5099,17 @@ implementation
         ExeSec: TExeSection;
         ExeSec: TExeSection;
         i: Integer;
         i: Integer;
         objsec: TObjSection;
         objsec: TObjSection;
+        firstdatasec: string;
       begin
       begin
         { WebAssembly is a Harvard architecture.
         { WebAssembly is a Harvard architecture.
           Data lives in a separate address space, so start addressing back from 0
           Data lives in a separate address space, so start addressing back from 0
           (the LLVM leaves the first 1024 bytes in the data segment empty, so we
           (the LLVM leaves the first 1024 bytes in the data segment empty, so we
           start at 1024). }
           start at 1024). }
-        if aname='.rodata' then
+        if ts_wasm_threads in current_settings.targetswitches then
+          firstdatasec:='.tbss'
+        else
+          firstdatasec:='.rodata';
+        if aname=firstdatasec then
           begin
           begin
             CurrMemPos:=1024;
             CurrMemPos:=1024;
             inherited;
             inherited;