Browse Source

* create a TWasmGlobalAsmSymbol instead of TAsmSymbol when generating debug info
for thread vars. This fixes a memory corruption error, when later the compiler
tries to access the extra fields in TWasmGlobalAsmSymbol for the '__tls_base'
symbol.

Nikolay Nikolov 10 months ago
parent
commit
1ddf014980
2 changed files with 12 additions and 1 deletions
  1. 8 0
      compiler/aasmtai.pas
  2. 4 1
      compiler/dbgdwarf.pas

+ 8 - 0
compiler/aasmtai.pas

@@ -767,6 +767,7 @@ interface
           constructor Createname(const name:string;_symtyp:Tasmsymtype;ofs:asizeint);
           constructor Create_type_name(_typ:taiconst_type;const name:string;ofs:asizeint);
           constructor Create_type_name(_typ:taiconst_type;const name:string;_symtyp:Tasmsymtype;ofs:asizeint);
+          constructor Create_type_name(_typ:taiconst_type;const name:string;symclass: TAsmSymbolClass;_symtyp:Tasmsymtype;ofs:asizeint);
           constructor Create_nil_codeptr;
           constructor Create_nil_codeptr_unaligned;
           constructor Create_nil_dataptr;
@@ -1996,6 +1997,13 @@ implementation
       end;
 
 
+    constructor tai_const.Create_type_name(_typ:taiconst_type;const name:string;symclass: TAsmSymbolClass;_symtyp:Tasmsymtype;ofs:asizeint);
+      begin
+        self.create_sym_offset(current_asmdata.RefAsmSymbolByClass(symclass,name,_symtyp),ofs);
+        consttype:=_typ;
+      end;
+
+
     constructor tai_const.Create_nil_codeptr;
       begin
         self.Create_int_codeptr(0);

+ 4 - 1
compiler/dbgdwarf.pas

@@ -273,6 +273,9 @@ implementation
       cpubase,cpuinfo,paramgr,
       fmodule,
       defutil,symtable,symcpu,ppu
+{$ifdef wasm}
+      ,aasmcpu
+{$endif wasm}
 {$ifdef OMFOBJSUPPORT}
       ,dbgcodeview
 {$endif OMFOBJSUPPORT}
@@ -2387,7 +2390,7 @@ implementation
 {$ifdef wasm}
                         templist.concat(tai_const.create_8bit(ord(DW_OP_WASM_location)));
                         templist.concat(tai_const.create_8bit(3)); { wasm global }
-                        templist.concat(tai_const.Create_type_name(aitconst_ptr_unaligned,TLS_BASE_SYM,AT_WASM_GLOBAL,0));
+                        templist.concat(tai_const.Create_type_name(aitconst_ptr_unaligned,TLS_BASE_SYM,TWasmGlobalAsmSymbol,AT_WASM_GLOBAL,0));
                         templist.concat(tai_const.create_8bit(ord(DW_OP_addr)));
                         templist.concat(tai_const.Create_type_name(aitconst_ptr_unaligned,sym.mangledname,0));
                         templist.concat(tai_const.create_8bit(ord(DW_OP_plus)));