Browse Source

* WebAssembly threads internal linker: create double relocation entries for
AT_TLS entries: one points to the AT_TLS entry (the data segment), the other
points to the WebAssembly global, holding that address. This causes the
smartlinking optimization to keep both the AT_TLS entry in the data segment,
as well as the WebAssembly global.

Nikolay Nikolov 1 year ago
parent
commit
cd8fda1c28
1 changed files with 5 additions and 1 deletions
  1. 5 1
      compiler/ogwasm.pas

+ 5 - 1
compiler/ogwasm.pas

@@ -4539,7 +4539,11 @@ implementation
                       ObjSec.ObjRelocations.Add(ObjReloc);
                       ObjSec.ObjRelocations.Add(ObjReloc);
                     end;
                     end;
                   R_WASM_GLOBAL_INDEX_LEB:
                   R_WASM_GLOBAL_INDEX_LEB:
-                    ObjSec.ObjRelocations.Add(TWasmObjRelocation.CreateSymbol(RelocOffset-BaseSectionOffset,SymbolTable[RelocIndex].ObjSym,RELOC_GLOBAL_INDEX_LEB));
+                    begin
+                      ObjSec.ObjRelocations.Add(TWasmObjRelocation.CreateSymbol(RelocOffset-BaseSectionOffset,SymbolTable[RelocIndex].ObjSym,RELOC_GLOBAL_INDEX_LEB));
+                      if Assigned(SymbolTable[RelocIndex].ObjSym.TlsGlobalSym) then
+                        ObjSec.ObjRelocations.Add(TWasmObjRelocation.CreateSymbol(RelocOffset-BaseSectionOffset,SymbolTable[RelocIndex].ObjSym.TlsGlobalSym,RELOC_GLOBAL_INDEX_LEB));
+                    end;
                   R_WASM_TAG_INDEX_LEB:
                   R_WASM_TAG_INDEX_LEB:
                     ObjSec.ObjRelocations.Add(TWasmObjRelocation.CreateSymbol(RelocOffset-BaseSectionOffset,SymbolTable[RelocIndex].ObjSym,RELOC_TAG_INDEX_LEB));
                     ObjSec.ObjRelocations.Add(TWasmObjRelocation.CreateSymbol(RelocOffset-BaseSectionOffset,SymbolTable[RelocIndex].ObjSym,RELOC_TAG_INDEX_LEB));
                   else
                   else