Browse Source

+ introduced trefaddr.addr_got_tls, to be used for generating WebAssembly threadvar access, when WASM multithreading is turned on

Nikolay Nikolov 3 years ago
parent
commit
557e823734
2 changed files with 17 additions and 1 deletions
  1. 3 0
      compiler/cgbase.pas
  2. 14 1
      compiler/wasm32/agllvmmc.pas

+ 3 - 0
compiler/cgbase.pas

@@ -143,6 +143,9 @@ interface
           ,addr_tpoff
           ,addr_tpoff
           ,addr_tlsgd
           ,addr_tlsgd
 {$endif x86_64}
 {$endif x86_64}
+{$ifdef wasm32}
+          ,addr_got_tls
+{$endif wasm32}
          );
          );
 
 
 
 

+ 14 - 1
compiler/wasm32/agllvmmc.pas

@@ -89,6 +89,7 @@ implementation
 
 
   uses
   uses
     cutils,
     cutils,
+    cgbase,
     fmodule,finput,
     fmodule,finput,
     itcpugas,
     itcpugas,
     cpubase,
     cpubase,
@@ -166,7 +167,19 @@ implementation
 
 
     function getreferencestring(var ref : treference) : ansistring;
     function getreferencestring(var ref : treference) : ansistring;
       begin
       begin
-        if assigned(ref.symbol) then
+        if ref.refaddr=addr_got_tls then
+          begin
+            if not assigned(ref.symbol) then
+              internalerror(2022071401);
+            if ref.base<>NR_NO then
+              internalerror(2022071402);
+            if ref.index<>NR_NO then
+              internalerror(2022071403);
+            if ref.offset<>0 then
+              internalerror(2022071404);
+            result:=ref.symbol.name+'@GOT@TLS';
+          end
+        else if assigned(ref.symbol) then
           begin
           begin
             // global symbol or field -> full type and name
             // global symbol or field -> full type and name
             // ref.base can be <> NR_NO in case an instance field is loaded.
             // ref.base can be <> NR_NO in case an instance field is loaded.