Browse Source

* specify the def of assembler level symbols defined via
tasmdata.DefineAsmSymbol() and all routines that call it
o will be used to automatically generate AB_INDIRECT sybols when
necessary

git-svn-id: trunk@34164 -

Jonas Maebe 9 years ago
parent
commit
1cb8c0d00c
48 changed files with 322 additions and 285 deletions
  1. 2 2
      compiler/aarch64/hlcgcpu.pas
  2. 2 2
      compiler/aasmcnst.pas
  3. 58 46
      compiler/aasmdata.pas
  4. 15 15
      compiler/aasmtai.pas
  5. 2 2
      compiler/arm/aasmcpu.pas
  6. 2 2
      compiler/arm/hlcgcpu.pas
  7. 2 2
      compiler/avr/navrutil.pas
  8. 1 1
      compiler/cgobj.pas
  9. 32 32
      compiler/dbgdwarf.pas
  10. 4 4
      compiler/dbgstabs.pas
  11. 1 1
      compiler/dbgstabx.pas
  12. 4 4
      compiler/hlcgobj.pas
  13. 2 2
      compiler/i386/hlcgcpu.pas
  14. 2 2
      compiler/i8086/hlcgcpu.pas
  15. 9 8
      compiler/i8086/n8086util.pas
  16. 1 1
      compiler/llvm/aasmllvm.pas
  17. 2 2
      compiler/llvm/hlcgllvm.pas
  18. 1 1
      compiler/llvm/llvmpara.pas
  19. 3 3
      compiler/llvm/nllvmutil.pas
  20. 2 2
      compiler/m68k/hlcgcpu.pas
  21. 2 2
      compiler/mips/hlcgcpu.pas
  22. 1 1
      compiler/ncal.pas
  23. 1 1
      compiler/ncgcal.pas
  24. 1 1
      compiler/ncgld.pas
  25. 13 9
      compiler/ncgrtti.pas
  26. 2 2
      compiler/ncgutil.pas
  27. 7 7
      compiler/ncgvmt.pas
  28. 34 25
      compiler/ngenutil.pas
  29. 3 3
      compiler/ngtcon.pas
  30. 69 60
      compiler/objcgutl.pas
  31. 2 2
      compiler/pmodules.pas
  32. 4 4
      compiler/powerpc/rappcgas.pas
  33. 1 1
      compiler/powerpc64/cgcpu.pas
  34. 4 4
      compiler/powerpc64/rappcgas.pas
  35. 5 5
      compiler/ppcgen/cgppc.pas
  36. 2 2
      compiler/ppcgen/hlcgppc.pas
  37. 2 2
      compiler/psub.pas
  38. 1 1
      compiler/ptconst.pas
  39. 4 2
      compiler/raatt.pas
  40. 2 2
      compiler/rautils.pas
  41. 2 2
      compiler/sparc/hlcgcpu.pas
  42. 1 1
      compiler/systems/t_beos.pas
  43. 1 1
      compiler/systems/t_haiku.pas
  44. 1 1
      compiler/systems/t_nwl.pas
  45. 1 1
      compiler/systems/t_nwm.pas
  46. 6 6
      compiler/systems/t_win.pas
  47. 1 1
      compiler/x86/cgx86.pas
  48. 2 2
      compiler/x86_64/hlcgcpu.pas

+ 2 - 2
compiler/aarch64/hlcgcpu.pas

@@ -158,9 +158,9 @@ implementation
         make_global:=true;
         make_global:=true;
 
 
       if make_global then
       if make_global then
-        list.concat(Tai_symbol.Createname_global(labelname,AT_FUNCTION,0))
+        list.concat(Tai_symbol.Createname_global(labelname,AT_FUNCTION,0,procdef))
       else
       else
-        list.concat(Tai_symbol.Createname(labelname,AT_FUNCTION,0));
+        list.concat(Tai_symbol.Createname(labelname,AT_FUNCTION,0,procdef));
 
 
       { set param1 interface to self  }
       { set param1 interface to self  }
       procdef.init_paraloc_info(callerside);
       procdef.init_paraloc_info(callerside);

+ 2 - 2
compiler/aasmcnst.pas

@@ -993,7 +993,7 @@ implementation
          end
          end
        else if tcalo_vectorized_dead_strip_item in options then
        else if tcalo_vectorized_dead_strip_item in options then
          begin
          begin
-           sym:=current_asmdata.DefineAsmSymbol(make_mangledname(basename,st,itemname),AB_GLOBAL,AT_DATA);
+           sym:=current_asmdata.DefineAsmSymbol(make_mangledname(basename,st,itemname),AB_GLOBAL,AT_DATA,def);
            if not customsecname then
            if not customsecname then
              secname:=make_mangledname(basename,st,'2_'+itemname);
              secname:=make_mangledname(basename,st,'2_'+itemname);
            exclude(options,tcalo_vectorized_dead_strip_item);
            exclude(options,tcalo_vectorized_dead_strip_item);
@@ -1382,7 +1382,7 @@ implementation
        else
        else
          name:=make_mangledname(basename,st,'END');
          name:=make_mangledname(basename,st,'END');
        if define then
        if define then
-         result:=current_asmdata.DefineAsmSymbol(name,AB_GLOBAL,AT_DATA)
+         result:=current_asmdata.DefineAsmSymbol(name,AB_GLOBAL,AT_DATA,voidpointertype)
        else
        else
          result:=current_asmdata.RefAsmSymbol(name,AT_DATA)
          result:=current_asmdata.RefAsmSymbol(name,AT_DATA)
      end;
      end;

+ 58 - 46
compiler/aasmdata.pas

@@ -159,6 +159,8 @@ interface
         FAsmCFI        : TAsmCFI;
         FAsmCFI        : TAsmCFI;
         FConstPools    : array[TConstPoolType] of THashSet;
         FConstPools    : array[TConstPoolType] of THashSet;
         function GetConstPools(APoolType: TConstPoolType): THashSet;
         function GetConstPools(APoolType: TConstPoolType): THashSet;
+      protected
+        function  DefineAsmSymbolByClassBase(symclass: TAsmSymbolClass; const s : TSymStr;_bind:TAsmSymBind;_typ:Tasmsymtype; def: tdef; out wasdefined: boolean) : TAsmSymbol;
       public
       public
         name          : pshortstring;       { owned by tmodule }
         name          : pshortstring;       { owned by tmodule }
         NextVTEntryNr : longint;
         NextVTEntryNr : longint;
@@ -170,8 +172,8 @@ interface
         constructor create(n: pshortstring);
         constructor create(n: pshortstring);
         destructor  destroy;override;
         destructor  destroy;override;
         { asmsymbol }
         { asmsymbol }
-        function  DefineAsmSymbolByClass(symclass: TAsmSymbolClass; const s : TSymStr;_bind:TAsmSymBind;_typ:Tasmsymtype) : TAsmSymbol;
-        function  DefineAsmSymbol(const s : TSymStr;_bind:TAsmSymBind;_typ:Tasmsymtype) : TAsmSymbol;
+        function  DefineAsmSymbolByClass(symclass: TAsmSymbolClass; const s : TSymStr;_bind:TAsmSymBind;_typ:Tasmsymtype; def: tdef) : TAsmSymbol; virtual;
+        function  DefineAsmSymbol(const s : TSymStr;_bind:TAsmSymBind;_typ:Tasmsymtype; def: tdef) : TAsmSymbol;
         function  WeakRefAsmSymbol(const s : TSymStr;_typ:Tasmsymtype=AT_NONE) : TAsmSymbol;
         function  WeakRefAsmSymbol(const s : TSymStr;_typ:Tasmsymtype=AT_NONE) : TAsmSymbol;
         function  RefAsmSymbol(const s : TSymStr;_typ:Tasmsymtype=AT_NONE;indirect:boolean=false) : TAsmSymbol;
         function  RefAsmSymbol(const s : TSymStr;_typ:Tasmsymtype=AT_NONE;indirect:boolean=false) : TAsmSymbol;
         function  GetAsmSymbol(const s : TSymStr) : TAsmSymbol;
         function  GetAsmSymbol(const s : TSymStr) : TAsmSymbol;
@@ -344,6 +346,55 @@ implementation
         Result := FConstPools[APoolType];
         Result := FConstPools[APoolType];
       end;
       end;
 
 
+
+    function TAsmData.DefineAsmSymbolByClassBase(symclass: TAsmSymbolClass; const s: TSymStr; _bind: TAsmSymBind; _typ: Tasmsymtype; def: tdef; out wasdefined: boolean): TAsmSymbol;
+      var
+        hp : TAsmSymbol;
+        namestr : TSymStr;
+      begin
+        namestr:=s;
+        if _bind in asmsymbindindirect then
+          namestr:=namestr+suffix_indirect;
+        hp:=TAsmSymbol(FAsmSymbolDict.Find(namestr));
+        if assigned(hp) then
+         begin
+           { Redefine is allowed, but the types must be the same. The redefine
+             is needed for Darwin where the labels are first allocated }
+           wasdefined:=not(hp.bind in [AB_EXTERNAL,AB_WEAK_EXTERNAL]);
+           if wasdefined then
+             begin
+               if (hp.bind<>_bind) and
+                  (hp.typ<>_typ) then
+                 internalerror(200603261);
+             end;
+           hp.typ:=_typ;
+           { Changing bind from AB_GLOBAL to AB_LOCAL is wrong
+             if bind is already AB_GLOBAL or AB_EXTERNAL,
+             GOT might have been used, so change might be harmful. }
+           if (_bind<>hp.bind) and (hp.getrefs>0) then
+             begin
+{$ifdef extdebug}
+               { the changes that matter must become internalerrors, the rest
+                 should be ignored; a used cannot change anything about this,
+                 so printing a warning/hint is not useful }
+               if (_bind=AB_LOCAL) then
+                 Message3(asmw_w_changing_bind_type,namestr,asmsymbindname[hp.bind],asmsymbindname[_bind])
+               else
+                 Message3(asmw_h_changing_bind_type,namestr,asmsymbindname[hp.bind],asmsymbindname[_bind]);
+{$endif extdebug}
+             end;
+           hp.bind:=_bind;
+         end
+        else
+         begin
+           wasdefined:=false;
+           { Not found, insert it. }
+           hp:=symclass.create(AsmSymbolDict,namestr,_bind,_typ);
+         end;
+        result:=hp;
+      end;
+
+
     constructor TAsmData.create(n:pshortstring);
     constructor TAsmData.create(n:pshortstring);
       var
       var
         alt : TAsmLabelType;
         alt : TAsmLabelType;
@@ -407,56 +458,17 @@ implementation
            FConstPools[hp].Free;
            FConstPools[hp].Free;
       end;
       end;
 
 
-
-    function TAsmData.DefineAsmSymbolByClass(symclass: TAsmSymbolClass; const s : TSymStr;_bind:TAsmSymBind;_typ:Tasmsymtype) : TAsmSymbol;
+    function TAsmData.DefineAsmSymbolByClass(symclass: TAsmSymbolClass; const s: TSymStr; _bind: TAsmSymBind; _typ: Tasmsymtype; def: tdef): TAsmSymbol;
       var
       var
-        hp : TAsmSymbol;
-        namestr : TSymStr;
+        wasdefined: boolean;
       begin
       begin
-        namestr:=s;
-        if _bind in asmsymbindindirect then
-          namestr:=namestr+suffix_indirect;
-        hp:=TAsmSymbol(FAsmSymbolDict.Find(namestr));
-        if assigned(hp) then
-         begin
-           { Redefine is allowed, but the types must be the same. The redefine
-             is needed for Darwin where the labels are first allocated }
-           if not(hp.bind in [AB_EXTERNAL,AB_WEAK_EXTERNAL]) then
-             begin
-               if (hp.bind<>_bind) and
-                  (hp.typ<>_typ) then
-                 internalerror(200603261);
-             end;
-           hp.typ:=_typ;
-           { Changing bind from AB_GLOBAL to AB_LOCAL is wrong
-             if bind is already AB_GLOBAL or AB_EXTERNAL,
-             GOT might have been used, so change might be harmful. }
-           if (_bind<>hp.bind) and (hp.getrefs>0) then
-             begin
-{$ifdef extdebug}
-               { the changes that matter must become internalerrors, the rest
-                 should be ignored; a used cannot change anything about this,
-                 so printing a warning/hint is not useful }
-               if (_bind=AB_LOCAL) then
-                 Message3(asmw_w_changing_bind_type,namestr,asmsymbindname[hp.bind],asmsymbindname[_bind])
-               else
-                 Message3(asmw_h_changing_bind_type,namestr,asmsymbindname[hp.bind],asmsymbindname[_bind]);
-{$endif extdebug}
-             end;
-           hp.bind:=_bind;
-         end
-        else
-         begin
-           { Not found, insert it. }
-           hp:=symclass.create(AsmSymbolDict,namestr,_bind,_typ);
-         end;
-        result:=hp;
+        result:=DefineAsmSymbolByClassBase(symclass,s,_bind,_typ,def,wasdefined);
       end;
       end;
 
 
 
 
-    function TAsmData.DefineAsmSymbol(const s : TSymStr;_bind:TAsmSymBind;_typ:Tasmsymtype) : TAsmSymbol;
+    function TAsmData.DefineAsmSymbol(const s: TSymStr; _bind: TAsmSymBind; _typ: Tasmsymtype; def: tdef): TAsmSymbol;
       begin
       begin
-        result:=DefineAsmSymbolByClass(TAsmSymbol,s,_bind,_typ);
+        result:=DefineAsmSymbolByClass(TAsmSymbol,s,_bind,_typ,def);
       end;
       end;
 
 
 
 

+ 15 - 15
compiler/aasmtai.pas

@@ -497,9 +497,9 @@ interface
           has_value : boolean;
           has_value : boolean;
           constructor Create(_sym:tasmsymbol;siz:longint);
           constructor Create(_sym:tasmsymbol;siz:longint);
           constructor Create_Global(_sym:tasmsymbol;siz:longint);
           constructor Create_Global(_sym:tasmsymbol;siz:longint);
-          constructor Createname(const _name : string;_symtyp:Tasmsymtype;siz:longint);
-          constructor Createname_global(const _name : string;_symtyp:Tasmsymtype;siz:longint);
-          constructor Createname_global_value(const _name : string;_symtyp:Tasmsymtype;siz:longint;val:ptruint);
+          constructor Createname(const _name : string;_symtyp:Tasmsymtype;siz:longint;def:tdef);
+          constructor Createname_global(const _name : string;_symtyp:Tasmsymtype;siz:longint;def:tdef);
+          constructor Createname_global_value(const _name : string;_symtyp:Tasmsymtype;siz:longint;val:ptruint;def:tdef);
           constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
           constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
           procedure ppuwrite(ppufile:tcompilerppufile);override;
           procedure ppuwrite(ppufile:tcompilerppufile);override;
           procedure derefimpl;override;
           procedure derefimpl;override;
@@ -574,8 +574,8 @@ interface
           is_global : boolean;
           is_global : boolean;
           sym       : tasmsymbol;
           sym       : tasmsymbol;
           size      : asizeint;
           size      : asizeint;
-          constructor Create(const _name : string;_size : asizeint);
-          constructor Create_global(const _name : string;_size : asizeint);
+          constructor Create(const _name : string;_size : asizeint; def: tdef);
+          constructor Create_global(const _name : string;_size : asizeint; def: tdef);
           constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
           constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
           procedure ppuwrite(ppufile:tcompilerppufile);override;
           procedure ppuwrite(ppufile:tcompilerppufile);override;
           procedure derefimpl;override;
           procedure derefimpl;override;
@@ -1193,12 +1193,12 @@ implementation
                              TAI_DATABLOCK
                              TAI_DATABLOCK
  ****************************************************************************}
  ****************************************************************************}
 
 
-    constructor tai_datablock.Create(const _name : string;_size : asizeint);
+    constructor tai_datablock.Create(const _name : string;_size : asizeint; def: tdef);
 
 
       begin
       begin
          inherited Create;
          inherited Create;
          typ:=ait_datablock;
          typ:=ait_datablock;
-         sym:=current_asmdata.DefineAsmSymbol(_name,AB_LOCAL,AT_DATA);
+         sym:=current_asmdata.DefineAsmSymbol(_name,AB_LOCAL,AT_DATA,def);
          { keep things aligned }
          { keep things aligned }
          if _size<=0 then
          if _size<=0 then
            _size:=sizeof(aint);
            _size:=sizeof(aint);
@@ -1207,11 +1207,11 @@ implementation
       end;
       end;
 
 
 
 
-    constructor tai_datablock.Create_global(const _name : string;_size : asizeint);
+    constructor tai_datablock.Create_global(const _name : string;_size : asizeint; def: tdef);
       begin
       begin
          inherited Create;
          inherited Create;
          typ:=ait_datablock;
          typ:=ait_datablock;
-         sym:=current_asmdata.DefineAsmSymbol(_name,AB_GLOBAL,AT_DATA);
+         sym:=current_asmdata.DefineAsmSymbol(_name,AB_GLOBAL,AT_DATA,def);
          { keep things aligned }
          { keep things aligned }
          if _size<=0 then
          if _size<=0 then
            _size:=sizeof(aint);
            _size:=sizeof(aint);
@@ -1275,29 +1275,29 @@ implementation
       end;
       end;
 
 
 
 
-    constructor tai_symbol.Createname(const _name : string;_symtyp:Tasmsymtype;siz:longint);
+    constructor tai_symbol.Createname(const _name : string;_symtyp:Tasmsymtype;siz:longint;def:tdef);
       begin
       begin
          inherited Create;
          inherited Create;
          typ:=ait_symbol;
          typ:=ait_symbol;
-         sym:=current_asmdata.DefineAsmSymbol(_name,AB_LOCAL,_symtyp);
+         sym:=current_asmdata.DefineAsmSymbol(_name,AB_LOCAL,_symtyp,def);
          size:=siz;
          size:=siz;
          is_global:=false;
          is_global:=false;
       end;
       end;
 
 
 
 
-    constructor tai_symbol.Createname_global(const _name : string;_symtyp:Tasmsymtype;siz:longint);
+    constructor tai_symbol.Createname_global(const _name : string;_symtyp:Tasmsymtype;siz:longint;def:tdef);
       begin
       begin
          inherited Create;
          inherited Create;
          typ:=ait_symbol;
          typ:=ait_symbol;
-         sym:=current_asmdata.DefineAsmSymbol(_name,AB_GLOBAL,_symtyp);
+         sym:=current_asmdata.DefineAsmSymbol(_name,AB_GLOBAL,_symtyp,def);
          size:=siz;
          size:=siz;
          is_global:=true;
          is_global:=true;
       end;
       end;
 
 
 
 
-    constructor tai_symbol.createname_global_value(const _name: string;_symtyp: tasmsymtype; siz: longint; val: ptruint);
+    constructor tai_symbol.createname_global_value(const _name: string;_symtyp: tasmsymtype; siz: longint; val: ptruint;def:tdef);
       begin
       begin
-        Createname_global(_name,_symtyp,siz);
+        Createname_global(_name,_symtyp,siz,def);
         value:=val;
         value:=val;
         has_value:=true;
         has_value:=true;
       end;
       end;

+ 2 - 2
compiler/arm/aasmcpu.pas

@@ -311,7 +311,7 @@ implementation
 
 
   uses
   uses
     itcpugas,aoptcpu,
     itcpugas,aoptcpu,
-    systems;
+    systems,symdef;
 
 
 
 
     procedure taicpu.loadshifterop(opidx:longint;const so:tshifterop);
     procedure taicpu.loadshifterop(opidx:longint;const so:tshifterop);
@@ -1747,7 +1747,7 @@ implementation
         new_section(prolog,sec_code,'FPC_EH_PROLOG',sizeof(pint),secorder_begin);
         new_section(prolog,sec_code,'FPC_EH_PROLOG',sizeof(pint),secorder_begin);
         prolog.concat(Tai_const.Createname('_ARM_ExceptionHandler', 0));
         prolog.concat(Tai_const.Createname('_ARM_ExceptionHandler', 0));
         prolog.concat(Tai_const.Create_32bit(0));
         prolog.concat(Tai_const.Create_32bit(0));
-        prolog.concat(Tai_symbol.Createname_global('FPC_EH_CODE_START',AT_DATA,0));
+        prolog.concat(Tai_symbol.Createname_global('FPC_EH_CODE_START',AT_METADATA,0,voidpointertype));
         { dummy function }
         { dummy function }
         prolog.concat(taicpu.op_reg_reg(A_MOV,NR_R15,NR_R14));
         prolog.concat(taicpu.op_reg_reg(A_MOV,NR_R15,NR_R14));
         current_asmdata.asmlists[al_start].insertList(prolog);
         current_asmdata.asmlists[al_start].insertList(prolog);

+ 2 - 2
compiler/arm/hlcgcpu.pas

@@ -177,9 +177,9 @@ implementation
         make_global:=true;
         make_global:=true;
 
 
       if make_global then
       if make_global then
-        list.concat(Tai_symbol.Createname_global(labelname,AT_FUNCTION,0))
+        list.concat(Tai_symbol.Createname_global(labelname,AT_FUNCTION,0,procdef))
       else
       else
-        list.concat(Tai_symbol.Createname(labelname,AT_FUNCTION,0));
+        list.concat(Tai_symbol.Createname(labelname,AT_FUNCTION,0,procdef));
 
 
       { the wrapper might need aktlocaldata for the additional data to
       { the wrapper might need aktlocaldata for the additional data to
         load the constant }
         load the constant }

+ 2 - 2
compiler/avr/navrutil.pas

@@ -167,7 +167,7 @@ implementation
       begin
       begin
         header:=TAsmList.create;
         header:=TAsmList.create;
         new_section(header, sec_code, 'FPC_INIT_FUNC_TABLE', 1);
         new_section(header, sec_code, 'FPC_INIT_FUNC_TABLE', 1);
-        header.concat(tai_symbol.Createname_global('FPC_INIT_FUNC_TABLE',AT_FUNCTION,0));
+        header.concat(tai_symbol.Createname_global('FPC_INIT_FUNC_TABLE',AT_FUNCTION,0,voidcodepointertype));
 
 
         initList.insertList(header);
         initList.insertList(header);
         header.free;
         header.free;
@@ -178,7 +178,7 @@ implementation
       begin
       begin
         header:=TAsmList.create;
         header:=TAsmList.create;
         new_section(header, sec_code, 'FPC_FINALIZE_FUNC_TABLE', 1);
         new_section(header, sec_code, 'FPC_FINALIZE_FUNC_TABLE', 1);
-        header.concat(tai_symbol.Createname_global('FPC_FINALIZE_FUNC_TABLE',AT_FUNCTION,0));
+        header.concat(tai_symbol.Createname_global('FPC_FINALIZE_FUNC_TABLE',AT_FUNCTION,0,voidcodepointertype));
 
 
         finalList.insertList(header);
         finalList.insertList(header);
         header.free;
         header.free;

+ 1 - 1
compiler/cgobj.pas

@@ -2392,7 +2392,7 @@ implementation
               if not(assigned(l)) then
               if not(assigned(l)) then
                 begin
                 begin
                   new_section(current_asmdata.asmlists[al_picdata],sec_data_nonlazy,'',sizeof(pint));
                   new_section(current_asmdata.asmlists[al_picdata],sec_data_nonlazy,'',sizeof(pint));
-                  l:=current_asmdata.DefineAsmSymbol(nlsymname,AB_LOCAL,AT_DATA);
+                  l:=current_asmdata.DefineAsmSymbol(nlsymname,AB_LOCAL,AT_DATA,voidpointertype);
                   current_asmdata.asmlists[al_picdata].concat(tai_symbol.create(l,0));
                   current_asmdata.asmlists[al_picdata].concat(tai_symbol.create(l,0));
                   if not(is_weak in flags) then
                   if not(is_weak in flags) then
                     current_asmdata.asmlists[al_picdata].concat(tai_directive.Create(asd_indirect_symbol,current_asmdata.RefAsmSymbol(symname).Name))
                     current_asmdata.asmlists[al_picdata].concat(tai_directive.Create(asd_indirect_symbol,current_asmdata.RefAsmSymbol(symname).Name))

+ 32 - 32
compiler/dbgdwarf.pas

@@ -976,10 +976,10 @@ implementation
                        (def.owner.symtabletype=globalsymtable) and
                        (def.owner.symtabletype=globalsymtable) and
                        (def.owner.iscurrentunit) then
                        (def.owner.iscurrentunit) then
                       begin
                       begin
-                        result^.lab:=current_asmdata.DefineAsmSymbol(make_mangledname('DBG',def.owner,symname(def.typesym, true)),AB_GLOBAL,AT_METADATA);
-                        result^.ref_lab:=current_asmdata.DefineAsmSymbol(make_mangledname('DBGREF',def.owner,symname(def.typesym, true)),AB_GLOBAL,AT_METADATA);
+                        result^.lab:=current_asmdata.DefineAsmSymbol(make_mangledname('DBG',def.owner,symname(def.typesym, true)),AB_GLOBAL,AT_METADATA,voidpointertype);
+                        result^.ref_lab:=current_asmdata.DefineAsmSymbol(make_mangledname('DBGREF',def.owner,symname(def.typesym, true)),AB_GLOBAL,AT_METADATA,voidpointertype);
                         if needstructdeflab then
                         if needstructdeflab then
-                          result^.struct_lab:=current_asmdata.DefineAsmSymbol(make_mangledname('DBG2',def.owner,symname(def.typesym, true)),AB_GLOBAL,AT_METADATA);
+                          result^.struct_lab:=current_asmdata.DefineAsmSymbol(make_mangledname('DBG2',def.owner,symname(def.typesym, true)),AB_GLOBAL,AT_METADATA,voidpointertype);
                         include(def.defstates,ds_dwarf_dbg_info_written);
                         include(def.defstates,ds_dwarf_dbg_info_written);
                       end
                       end
                     else
                     else
@@ -1289,7 +1289,7 @@ implementation
         else
         else
           begin
           begin
             AddConstToAbbrev(ord(DW_FORM_ref4));
             AddConstToAbbrev(ord(DW_FORM_ref4));
-            current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_rel_sym(offsetreltype,current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'debug_info0',AB_LOCAL,AT_METADATA),sym));
+            current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_rel_sym(offsetreltype,current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'debug_info0',AB_LOCAL,AT_METADATA,voidpointertype),sym));
           end;
           end;
       end;
       end;
 
 
@@ -2999,9 +2999,9 @@ implementation
           dbgname:='L'+dbgname;
           dbgname:='L'+dbgname;
         new_section(current_asmdata.asmlists[al_start],sec_code,dbgname,0,secorder_begin);
         new_section(current_asmdata.asmlists[al_start],sec_code,dbgname,0,secorder_begin);
         if not(target_info.system in systems_darwin) then
         if not(target_info.system in systems_darwin) then
-          current_asmdata.asmlists[al_start].concat(tai_symbol.Createname_global(dbgname,AT_METADATA,0))
+          current_asmdata.asmlists[al_start].concat(tai_symbol.Createname_global(dbgname,AT_METADATA,0,voidpointertype))
         else
         else
-          current_asmdata.asmlists[al_start].concat(tai_symbol.Createname(dbgname,AT_METADATA,0));
+          current_asmdata.asmlists[al_start].concat(tai_symbol.Createname(dbgname,AT_METADATA,0,voidpointertype));
 
 
         dbgname:=make_mangledname('DEBUGEND',current_module.localsymtable,'');
         dbgname:=make_mangledname('DEBUGEND',current_module.localsymtable,'');
         { See above. }
         { See above. }
@@ -3009,27 +3009,27 @@ implementation
           dbgname:='L'+dbgname;
           dbgname:='L'+dbgname;
         new_section(current_asmdata.asmlists[al_end],sec_code,dbgname,0,secorder_end);
         new_section(current_asmdata.asmlists[al_end],sec_code,dbgname,0,secorder_end);
         if not(target_info.system in systems_darwin) then
         if not(target_info.system in systems_darwin) then
-          current_asmdata.asmlists[al_end].concat(tai_symbol.Createname_global(dbgname,AT_METADATA,0))
+          current_asmdata.asmlists[al_end].concat(tai_symbol.Createname_global(dbgname,AT_METADATA,0,voidpointertype))
         else
         else
-          current_asmdata.asmlists[al_end].concat(tai_symbol.Createname(dbgname,AT_METADATA,0));
+          current_asmdata.asmlists[al_end].concat(tai_symbol.Createname(dbgname,AT_METADATA,0,voidpointertype));
 
 
         { insert .Ldebug_abbrev0 label }
         { insert .Ldebug_abbrev0 label }
         templist:=TAsmList.create;
         templist:=TAsmList.create;
         new_section(templist,sec_debug_abbrev,'',0);
         new_section(templist,sec_debug_abbrev,'',0);
-        templist.concat(tai_symbol.createname(target_asm.labelprefix+'debug_abbrevsection0',AT_METADATA,0));
+        templist.concat(tai_symbol.createname(target_asm.labelprefix+'debug_abbrevsection0',AT_METADATA,0,voidpointertype));
         { add any extra stuff which needs to be in the abbrev section, but before    }
         { add any extra stuff which needs to be in the abbrev section, but before    }
         { the actual abbreviations, in between the symbol above and below, i.e. here }
         { the actual abbreviations, in between the symbol above and below, i.e. here }
-        templist.concat(tai_symbol.createname(target_asm.labelprefix+'debug_abbrev0',AT_METADATA,0));
+        templist.concat(tai_symbol.createname(target_asm.labelprefix+'debug_abbrev0',AT_METADATA,0,voidpointertype));
         current_asmdata.asmlists[al_start].insertlist(templist);
         current_asmdata.asmlists[al_start].insertlist(templist);
         templist.free;
         templist.free;
 
 
         { insert .Ldebug_line0 label }
         { insert .Ldebug_line0 label }
         templist:=TAsmList.create;
         templist:=TAsmList.create;
         new_section(templist,sec_debug_line,'',0);
         new_section(templist,sec_debug_line,'',0);
-        templist.concat(tai_symbol.createname(target_asm.labelprefix+'debug_linesection0',AT_METADATA,0));
+        templist.concat(tai_symbol.createname(target_asm.labelprefix+'debug_linesection0',AT_METADATA,0,voidpointertype));
         { add any extra stuff which needs to be in the line section, but before  }
         { add any extra stuff which needs to be in the line section, but before  }
         { the actual line info, in between the symbol above and below, i.e. here }
         { the actual line info, in between the symbol above and below, i.e. here }
-        templist.concat(tai_symbol.createname(target_asm.labelprefix+'debug_line0',AT_METADATA,0));
+        templist.concat(tai_symbol.createname(target_asm.labelprefix+'debug_line0',AT_METADATA,0,voidpointertype));
         current_asmdata.asmlists[al_start].insertlist(templist);
         current_asmdata.asmlists[al_start].insertlist(templist);
         templist.free;
         templist.free;
 
 
@@ -3047,7 +3047,7 @@ implementation
         if use_64bit_headers then
         if use_64bit_headers then
           linelist.concat(tai_const.create_32bit_unaligned(longint($FFFFFFFF)));
           linelist.concat(tai_const.create_32bit_unaligned(longint($FFFFFFFF)));
         linelist.concat(tai_const.create_rel_sym(offsetreltype,
         linelist.concat(tai_const.create_rel_sym(offsetreltype,
-          lbl,current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'edebug_line0',AB_LOCAL,AT_METADATA)));
+          lbl,current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'edebug_line0',AB_LOCAL,AT_METADATA,voidpointertype)));
         linelist.concat(tai_label.create(lbl));
         linelist.concat(tai_label.create(lbl));
 
 
         { version }
         { version }
@@ -3056,7 +3056,7 @@ implementation
         { header length }
         { header length }
         current_asmdata.getlabel(lbl,alt_dbgfile);
         current_asmdata.getlabel(lbl,alt_dbgfile);
         linelist.concat(tai_const.create_rel_sym(offsetreltype,
         linelist.concat(tai_const.create_rel_sym(offsetreltype,
-          lbl,current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'ehdebug_line0',AB_LOCAL,AT_METADATA)));
+          lbl,current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'ehdebug_line0',AB_LOCAL,AT_METADATA,voidpointertype)));
         linelist.concat(tai_label.create(lbl));
         linelist.concat(tai_label.create(lbl));
 
 
         { minimum_instruction_length }
         { minimum_instruction_length }
@@ -3142,14 +3142,14 @@ implementation
         linelist.concat(tai_const.create_8bit(0));
         linelist.concat(tai_const.create_8bit(0));
 
 
         { end of debug line header }
         { end of debug line header }
-        linelist.concat(tai_symbol.createname(target_asm.labelprefix+'ehdebug_line0',AT_METADATA,0));
+        linelist.concat(tai_symbol.createname(target_asm.labelprefix+'ehdebug_line0',AT_METADATA,0,voidpointertype));
         linelist.concat(tai_comment.Create(strpnew('=== header end ===')));
         linelist.concat(tai_comment.Create(strpnew('=== header end ===')));
 
 
         { add line program }
         { add line program }
         linelist.concatList(asmline);
         linelist.concatList(asmline);
 
 
         { end of debug line table }
         { end of debug line table }
-        linelist.concat(tai_symbol.createname(target_asm.labelprefix+'edebug_line0',AT_METADATA,0));
+        linelist.concat(tai_symbol.createname(target_asm.labelprefix+'edebug_line0',AT_METADATA,0,voidpointertype));
 
 
         flist.free;
         flist.free;
       end;
       end;
@@ -3195,7 +3195,7 @@ implementation
 
 
         { write start labels }
         { write start labels }
         new_section(current_asmdata.asmlists[al_dwarf_info],sec_debug_info,'',0);
         new_section(current_asmdata.asmlists[al_dwarf_info],sec_debug_info,'',0);
-        current_asmdata.asmlists[al_dwarf_info].concat(tai_symbol.createname(target_asm.labelprefix+'debug_info0',AT_METADATA,0));
+        current_asmdata.asmlists[al_dwarf_info].concat(tai_symbol.createname(target_asm.labelprefix+'debug_info0',AT_METADATA,0,voidpointertype));
 
 
         { start abbrev section }
         { start abbrev section }
         new_section(current_asmdata.asmlists[al_dwarf_abbrev],sec_debug_abbrev,'',0);
         new_section(current_asmdata.asmlists[al_dwarf_abbrev],sec_debug_abbrev,'',0);
@@ -3210,7 +3210,7 @@ implementation
             if use_64bit_headers then
             if use_64bit_headers then
               current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_32bit_unaligned(longint($FFFFFFFF)));
               current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_32bit_unaligned(longint($FFFFFFFF)));
             current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_rel_sym(offsetreltype,
             current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_rel_sym(offsetreltype,
-              arangestartlabel,current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'earanges0',AB_LOCAL,AT_METADATA)));
+              arangestartlabel,current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'earanges0',AB_LOCAL,AT_METADATA,voidpointertype)));
 
 
             current_asmdata.asmlists[al_dwarf_aranges].concat(tai_label.create(arangestartlabel));
             current_asmdata.asmlists[al_dwarf_aranges].concat(tai_label.create(arangestartlabel));
 
 
@@ -3218,11 +3218,11 @@ implementation
 
 
             if not(tf_dwarf_relative_addresses in target_info.flags) then
             if not(tf_dwarf_relative_addresses in target_info.flags) then
               current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_type_sym(offsetabstype,
               current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_type_sym(offsetabstype,
-                current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'debug_info0',AB_LOCAL,AT_METADATA)))
+                current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'debug_info0',AB_LOCAL,AT_METADATA,voidpointertype)))
             else
             else
               current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_rel_sym(offsetreltype,
               current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_rel_sym(offsetreltype,
-                current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'debug_infosection0',AB_LOCAL,AT_METADATA),
-                current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'debug_info0',AB_LOCAL,AT_METADATA)));
+                current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'debug_infosection0',AB_LOCAL,AT_METADATA,voidpointertype),
+                current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'debug_info0',AB_LOCAL,AT_METADATA,voidpointertype)));
 
 
             current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_8bit(sizeof(pint)));
             current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_8bit(sizeof(pint)));
             current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_8bit(0));
             current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_8bit(0));
@@ -3239,7 +3239,7 @@ implementation
         if use_64bit_headers then
         if use_64bit_headers then
           current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_32bit_unaligned(longint($FFFFFFFF)));
           current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_32bit_unaligned(longint($FFFFFFFF)));
         current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_rel_sym(offsetreltype,
         current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_rel_sym(offsetreltype,
-          lenstartlabel,current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'edebug_info0',AB_LOCAL,AT_METADATA)));
+          lenstartlabel,current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'edebug_info0',AB_LOCAL,AT_METADATA,voidpointertype)));
 
 
         current_asmdata.asmlists[al_dwarf_info].concat(tai_label.create(lenstartlabel));
         current_asmdata.asmlists[al_dwarf_info].concat(tai_label.create(lenstartlabel));
         { version }
         { version }
@@ -3247,11 +3247,11 @@ implementation
         { abbrev table (=relative from section start)}
         { abbrev table (=relative from section start)}
         if not(tf_dwarf_relative_addresses in target_info.flags) then
         if not(tf_dwarf_relative_addresses in target_info.flags) then
           current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_type_sym(offsetabstype,
           current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_type_sym(offsetabstype,
-            current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'debug_abbrev0',AB_LOCAL,AT_METADATA)))
+            current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'debug_abbrev0',AB_LOCAL,AT_METADATA,voidpointertype)))
         else
         else
           current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_rel_sym(offsetreltype,
           current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_rel_sym(offsetreltype,
-            current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'debug_abbrevsection0',AB_LOCAL,AT_METADATA),
-            current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'debug_abbrev0',AB_LOCAL,AT_METADATA)));
+            current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'debug_abbrevsection0',AB_LOCAL,AT_METADATA,voidpointertype),
+            current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'debug_abbrev0',AB_LOCAL,AT_METADATA,voidpointertype)));
 
 
         { address size }
         { address size }
         current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(sizeof(pint)));
         current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(sizeof(pint)));
@@ -3266,11 +3266,11 @@ implementation
 
 
         { reference to line info section }
         { reference to line info section }
         if not(tf_dwarf_relative_addresses in target_info.flags) then
         if not(tf_dwarf_relative_addresses in target_info.flags) then
-          append_labelentry_dataptr_abs(DW_AT_stmt_list,current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'debug_line0',AB_LOCAL,AT_METADATA))
+          append_labelentry_dataptr_abs(DW_AT_stmt_list,current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'debug_line0',AB_LOCAL,AT_METADATA,voidpointertype))
         else
         else
           append_labelentry_dataptr_rel(DW_AT_stmt_list,
           append_labelentry_dataptr_rel(DW_AT_stmt_list,
-            current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'debug_linesection0',AB_LOCAL,AT_METADATA),
-            current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'debug_line0',AB_LOCAL,AT_METADATA));
+            current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'debug_linesection0',AB_LOCAL,AT_METADATA,voidpointertype),
+            current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'debug_line0',AB_LOCAL,AT_METADATA,voidpointertype));
 
 
         if (m_objectivec1 in current_settings.modeswitches) then
         if (m_objectivec1 in current_settings.modeswitches) then
           append_attribute(DW_AT_APPLE_major_runtime_vers,DW_FORM_data1,[1]);
           append_attribute(DW_AT_APPLE_major_runtime_vers,DW_FORM_data1,[1]);
@@ -3283,11 +3283,11 @@ implementation
           end
           end
         else
         else
           bind:=AB_GLOBAL;
           bind:=AB_GLOBAL;
-        append_labelentry(DW_AT_low_pc,current_asmdata.DefineAsmSymbol(dbgname,bind,AT_METADATA));
+        append_labelentry(DW_AT_low_pc,current_asmdata.DefineAsmSymbol(dbgname,bind,AT_METADATA,voidpointertype));
         dbgname:=make_mangledname('DEBUGEND',current_module.localsymtable,'');
         dbgname:=make_mangledname('DEBUGEND',current_module.localsymtable,'');
         if (target_info.system in systems_darwin) then
         if (target_info.system in systems_darwin) then
           dbgname:='L'+dbgname;
           dbgname:='L'+dbgname;
-        append_labelentry(DW_AT_high_pc,current_asmdata.DefineAsmSymbol(dbgname,bind,AT_METADATA));
+        append_labelentry(DW_AT_high_pc,current_asmdata.DefineAsmSymbol(dbgname,bind,AT_METADATA,voidpointertype));
 
 
         finish_entry;
         finish_entry;
 
 
@@ -3322,7 +3322,7 @@ implementation
         finish_children;
         finish_children;
 
 
         { end of debug info table }
         { end of debug info table }
-        current_asmdata.asmlists[al_dwarf_info].concat(tai_symbol.createname(target_asm.labelprefix+'edebug_info0',AT_METADATA,0));
+        current_asmdata.asmlists[al_dwarf_info].concat(tai_symbol.createname(target_asm.labelprefix+'edebug_info0',AT_METADATA,0,voidpointertype));
 
 
         { end of abbrev table }
         { end of abbrev table }
         current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_8bit(0));
         current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_8bit(0));
@@ -3332,7 +3332,7 @@ implementation
             { end of aranges table }
             { end of aranges table }
             current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.Create_aint(0));
             current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.Create_aint(0));
             current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.Create_aint(0));
             current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.Create_aint(0));
-            current_asmdata.asmlists[al_dwarf_aranges].concat(tai_symbol.createname(target_asm.labelprefix+'earanges0',AT_METADATA,0));
+            current_asmdata.asmlists[al_dwarf_aranges].concat(tai_symbol.createname(target_asm.labelprefix+'earanges0',AT_METADATA,0,voidpointertype));
           end;
           end;
 
 
         { reset all def debug states }
         { reset all def debug states }

+ 4 - 4
compiler/dbgstabs.pas

@@ -1675,7 +1675,7 @@ implementation
         if not(target_info.system in systems_darwin) then
         if not(target_info.system in systems_darwin) then
           begin
           begin
             new_section(current_asmdata.asmlists[al_stabs],sec_data,GetSymTableName(current_module.localsymtable),sizeof(pint));
             new_section(current_asmdata.asmlists[al_stabs],sec_data,GetSymTableName(current_module.localsymtable),sizeof(pint));
-            current_asmdata.asmlists[al_stabs].concat(tai_symbol.Createname_global(make_mangledname('DEBUGINFO',current_module.localsymtable,''),AT_METADATA,0));
+            current_asmdata.asmlists[al_stabs].concat(tai_symbol.Createname_global(make_mangledname('DEBUGINFO',current_module.localsymtable,''),AT_METADATA,0,voidpointertype));
           end
           end
         else
         else
           new_section(current_asmdata.asmlists[al_stabs],sec_code,GetSymTableName(current_module.localsymtable),sizeof(pint));
           new_section(current_asmdata.asmlists[al_stabs],sec_code,GetSymTableName(current_module.localsymtable),sizeof(pint));
@@ -1813,7 +1813,7 @@ implementation
         infile:=current_module.sourcefiles.get_file(1);
         infile:=current_module.sourcefiles.get_file(1);
         new_section(current_asmdata.asmlists[al_start],sec_code,make_mangledname('DEBUGSTART',current_module.localsymtable,''),sizeof(pint),secorder_begin);
         new_section(current_asmdata.asmlists[al_start],sec_code,make_mangledname('DEBUGSTART',current_module.localsymtable,''),sizeof(pint),secorder_begin);
         if not(target_info.system in systems_darwin) then
         if not(target_info.system in systems_darwin) then
-          current_asmdata.asmlists[al_start].concat(tai_symbol.Createname_global(make_mangledname('DEBUGSTART',current_module.localsymtable,''),AT_METADATA,0));
+          current_asmdata.asmlists[al_start].concat(tai_symbol.Createname_global(make_mangledname('DEBUGSTART',current_module.localsymtable,''),AT_METADATA,0,voidpointertype));
         current_asmdata.asmlists[al_start].concat(Tai_stab.Create_str(stabsdir,'"'+BsToSlash(FixPath(getcurrentdir,false))+'",'+
         current_asmdata.asmlists[al_start].concat(Tai_stab.Create_str(stabsdir,'"'+BsToSlash(FixPath(getcurrentdir,false))+'",'+
           base_stabs_str(stabs_n_sourcefile,'0','0',hlabel.name)));
           base_stabs_str(stabs_n_sourcefile,'0','0',hlabel.name)));
         current_asmdata.asmlists[al_start].concat(Tai_stab.Create_str(stabsdir,'"'+BsToSlash(FixPath(infile.path,false))+FixFileName(infile.name)+'",'+
         current_asmdata.asmlists[al_start].concat(Tai_stab.Create_str(stabsdir,'"'+BsToSlash(FixPath(infile.path,false))+FixFileName(infile.name)+'",'+
@@ -1828,7 +1828,7 @@ implementation
         current_asmdata.getlabel(hlabel,alt_dbgfile);
         current_asmdata.getlabel(hlabel,alt_dbgfile);
         new_section(current_asmdata.asmlists[al_end],sec_code,make_mangledname('DEBUGEND',current_module.localsymtable,''),sizeof(pint),secorder_end);
         new_section(current_asmdata.asmlists[al_end],sec_code,make_mangledname('DEBUGEND',current_module.localsymtable,''),sizeof(pint),secorder_end);
         if not(target_info.system in systems_darwin) then
         if not(target_info.system in systems_darwin) then
-          current_asmdata.asmlists[al_end].concat(tai_symbol.Createname_global(make_mangledname('DEBUGEND',current_module.localsymtable,''),AT_METADATA,0));
+          current_asmdata.asmlists[al_end].concat(tai_symbol.Createname_global(make_mangledname('DEBUGEND',current_module.localsymtable,''),AT_METADATA,0,voidpointertype));
         current_asmdata.asmlists[al_end].concat(Tai_stab.Create_str(stabsdir,'"",'+base_stabs_str(stabs_n_sourcefile,'0','0',hlabel.name)));
         current_asmdata.asmlists[al_end].concat(Tai_stab.Create_str(stabsdir,'"",'+base_stabs_str(stabs_n_sourcefile,'0','0',hlabel.name)));
         current_asmdata.asmlists[al_end].concat(tai_label.create(hlabel));
         current_asmdata.asmlists[al_end].concat(tai_label.create(hlabel));
       end;
       end;
@@ -1846,7 +1846,7 @@ implementation
         { make sure the debuginfo doesn't get stripped out }
         { make sure the debuginfo doesn't get stripped out }
         if (target_info.system in systems_darwin) then
         if (target_info.system in systems_darwin) then
           begin
           begin
-            dbgtable:=tai_symbol.createname('DEBUGINFOTABLE',AT_METADATA,0);
+            dbgtable:=tai_symbol.createname('DEBUGINFOTABLE',AT_METADATA,0,voidpointertype);
             list.concat(tai_directive.create(asd_no_dead_strip,dbgtable.sym.name));
             list.concat(tai_directive.create(asd_no_dead_strip,dbgtable.sym.name));
             list.concat(dbgtable);
             list.concat(dbgtable);
           end;
           end;

+ 1 - 1
compiler/dbgstabx.pas

@@ -254,7 +254,7 @@ implementation
       result:=inherited gen_procdef_endsym_stabs(def);
       result:=inherited gen_procdef_endsym_stabs(def);
       if not assigned(def.procstarttai) then
       if not assigned(def.procstarttai) then
         exit;
         exit;
-      procendsymbol:=current_asmdata.DefineAsmSymbol('LT..'+ReplaceForbiddenAsmSymbolChars(def.mangledname),AB_LOCAL,AT_ADDR);
+      procendsymbol:=current_asmdata.DefineAsmSymbol('LT..'+ReplaceForbiddenAsmSymbolChars(def.mangledname),AB_LOCAL,AT_ADDR,voidpointertype);
       current_asmdata.asmlists[al_procedures].insertbefore(tai_symbol.create(procendsymbol,0),def.procendtai);
       current_asmdata.asmlists[al_procedures].insertbefore(tai_symbol.create(procendsymbol,0),def.procendtai);
     end;
     end;
 
 

+ 4 - 4
compiler/hlcgobj.pas

@@ -3788,12 +3788,12 @@ implementation
       new_section(list,sec_code,wrappername,target_info.alignment.procalign);
       new_section(list,sec_code,wrappername,target_info.alignment.procalign);
       if global then
       if global then
         begin
         begin
-          sym:=current_asmdata.DefineAsmSymbol(wrappername,AB_GLOBAL,AT_FUNCTION);
+          sym:=current_asmdata.DefineAsmSymbol(wrappername,AB_GLOBAL,AT_FUNCTION,procdef);
           list.concat(Tai_symbol.Create_global(sym,0));
           list.concat(Tai_symbol.Create_global(sym,0));
         end
         end
       else
       else
         begin
         begin
-          sym:=current_asmdata.DefineAsmSymbol(wrappername,AB_LOCAL,AT_FUNCTION);
+          sym:=current_asmdata.DefineAsmSymbol(wrappername,AB_LOCAL,AT_FUNCTION,procdef);
           list.concat(Tai_symbol.Create(sym,0));
           list.concat(Tai_symbol.Create(sym,0));
         end;
         end;
       a_jmp_external_name(list,externalname);
       a_jmp_external_name(list,externalname);
@@ -4464,9 +4464,9 @@ implementation
                for msdos  target with -CX option for instance }
                for msdos  target with -CX option for instance }
              (create_smartlink_library and not is_nested_pd(current_procinfo.procdef)) or
              (create_smartlink_library and not is_nested_pd(current_procinfo.procdef)) or
              (po_global in current_procinfo.procdef.procoptions) then
              (po_global in current_procinfo.procdef.procoptions) then
-            list.concat(Tai_symbol.createname_global(item.str,AT_FUNCTION,0))
+            list.concat(Tai_symbol.createname_global(item.str,AT_FUNCTION,0,current_procinfo.procdef))
           else
           else
-            list.concat(Tai_symbol.createname(item.str,AT_FUNCTION,0));
+            list.concat(Tai_symbol.createname(item.str,AT_FUNCTION,0,current_procinfo.procdef));
           if assigned(previtem) and
           if assigned(previtem) and
              (target_info.system in systems_darwin) then
              (target_info.system in systems_darwin) then
             list.concat(tai_directive.create(asd_reference,previtem.str));
             list.concat(tai_directive.create(asd_reference,previtem.str));

+ 2 - 2
compiler/i386/hlcgcpu.pas

@@ -393,9 +393,9 @@ implementation
         make_global:=true;
         make_global:=true;
 
 
       if make_global then
       if make_global then
-        List.concat(Tai_symbol.Createname_global(labelname,AT_FUNCTION,0))
+        List.concat(Tai_symbol.Createname_global(labelname,AT_FUNCTION,0,procdef))
       else
       else
-        List.concat(Tai_symbol.Createname(labelname,AT_FUNCTION,0));
+        List.concat(Tai_symbol.Createname(labelname,AT_FUNCTION,0,procdef));
 
 
       { set param1 interface to self  }
       { set param1 interface to self  }
       g_adjust_self_value(list,procdef,ioffset);
       g_adjust_self_value(list,procdef,ioffset);

+ 2 - 2
compiler/i8086/hlcgcpu.pas

@@ -598,9 +598,9 @@ implementation
         make_global:=true;
         make_global:=true;
 
 
       if make_global then
       if make_global then
-        List.concat(Tai_symbol.Createname_global(labelname,AT_FUNCTION,0))
+        List.concat(Tai_symbol.Createname_global(labelname,AT_FUNCTION,0,procdef))
       else
       else
-        List.concat(Tai_symbol.Createname(labelname,AT_FUNCTION,0));
+        List.concat(Tai_symbol.Createname(labelname,AT_FUNCTION,0,procdef));
 
 
       { set param1 interface to self  }
       { set param1 interface to self  }
       g_adjust_self_value(list,procdef,ioffset);
       g_adjust_self_value(list,procdef,ioffset);

+ 9 - 8
compiler/i8086/n8086util.pas

@@ -43,7 +43,8 @@ implementation
   uses
   uses
     sysutils,cutils,
     sysutils,cutils,
     globtype,globals,cpuinfo,
     globtype,globals,cpuinfo,
-    aasmbase,aasmdata,aasmtai;
+    aasmbase,aasmdata,aasmtai,
+    symdef;
 
 
 
 
   class procedure ti8086nodeutils.InsertMemorySizes;
   class procedure ti8086nodeutils.InsertMemorySizes;
@@ -64,7 +65,7 @@ implementation
     begin
     begin
       maybe_new_object_file(current_asmdata.asmlists[al_globals]);
       maybe_new_object_file(current_asmdata.asmlists[al_globals]);
       new_section(current_asmdata.asmlists[al_globals],sec_stack,'__stack', 16);
       new_section(current_asmdata.asmlists[al_globals],sec_stack,'__stack', 16);
-      current_asmdata.asmlists[al_globals].concat(tai_symbol.Createname_global('___stack', AT_DATA, stacksize));
+      current_asmdata.asmlists[al_globals].concat(tai_symbol.Createname_global('___stack', AT_DATA, stacksize, carraydef.getreusable(u8inttype,stacksize)));
       { HACK: since tai_datablock's size parameter is aint, which cannot be
       { HACK: since tai_datablock's size parameter is aint, which cannot be
         larger than 32767 on i8086, but we'd like to support stack size of
         larger than 32767 on i8086, but we'd like to support stack size of
         up to 64kb, we may need to use several tai_datablocks to reserve
         up to 64kb, we may need to use several tai_datablocks to reserve
@@ -74,11 +75,11 @@ implementation
       while stacksizeleft>0 do
       while stacksizeleft>0 do
         begin
         begin
           stackblock:=min(stacksizeleft,high(aint));
           stackblock:=min(stacksizeleft,high(aint));
-          current_asmdata.asmlists[al_globals].concat(tai_datablock.Create('___stackblock'+IntToStr(i),stackblock));
+          current_asmdata.asmlists[al_globals].concat(tai_datablock.Create('___stackblock'+IntToStr(i),stackblock,carraydef.getreusable(u8inttype,stackblock)));
           dec(stacksizeleft,stackblock);
           dec(stacksizeleft,stackblock);
           inc(i);
           inc(i);
         end;
         end;
-      current_asmdata.asmlists[al_globals].concat(tai_symbol.Createname_global('___stacktop',AT_DATA,0));
+      current_asmdata.asmlists[al_globals].concat(tai_symbol.Createname_global('___stacktop',AT_DATA,0,voidtype));
     end;
     end;
 
 
 
 
@@ -89,7 +90,7 @@ implementation
     begin
     begin
       maybe_new_object_file(current_asmdata.asmlists[al_globals]);
       maybe_new_object_file(current_asmdata.asmlists[al_globals]);
       new_section(current_asmdata.asmlists[al_globals],sec_heap,'__heap', 16);
       new_section(current_asmdata.asmlists[al_globals],sec_heap,'__heap', 16);
-      current_asmdata.asmlists[al_globals].concat(tai_symbol.Createname_global('___heap', AT_DATA, heapsize));
+      current_asmdata.asmlists[al_globals].concat(tai_symbol.Createname_global('___heap', AT_DATA, heapsize,carraydef.getreusable(u8inttype,heapsize)));
       { HACK: since tai_datablock's size parameter is aint, which cannot be
       { HACK: since tai_datablock's size parameter is aint, which cannot be
         larger than 32767 on i8086, but we'd like to support heap size of
         larger than 32767 on i8086, but we'd like to support heap size of
         up to 640kb, we may need to use several tai_datablocks to reserve
         up to 640kb, we may need to use several tai_datablocks to reserve
@@ -99,11 +100,11 @@ implementation
       while heapsizeleft>0 do
       while heapsizeleft>0 do
         begin
         begin
           heapblock:=min(heapsizeleft,high(aint));
           heapblock:=min(heapsizeleft,high(aint));
-          current_asmdata.asmlists[al_globals].concat(tai_datablock.Create('___heapblock'+IntToStr(i),heapblock));
+          current_asmdata.asmlists[al_globals].concat(tai_datablock.Create('___heapblock'+IntToStr(i),heapblock,carraydef.getreusable(u8inttype,heapblock)));
           dec(heapsizeleft,heapblock);
           dec(heapsizeleft,heapblock);
           inc(i);
           inc(i);
         end;
         end;
-      current_asmdata.asmlists[al_globals].concat(tai_symbol.Createname_global('___heaptop',AT_DATA,0));
+      current_asmdata.asmlists[al_globals].concat(tai_symbol.Createname_global('___heaptop',AT_DATA,0,voidtype));
     end;
     end;
 
 
 
 
@@ -117,7 +118,7 @@ implementation
 
 
       maybe_new_object_file(current_asmdata.asmlists[al_globals]);
       maybe_new_object_file(current_asmdata.asmlists[al_globals]);
       new_section(current_asmdata.asmlists[al_globals],sec_data,'__fpc_stackplusmaxheap_in_para',sizeof(pint));
       new_section(current_asmdata.asmlists[al_globals],sec_data,'__fpc_stackplusmaxheap_in_para',sizeof(pint));
-      current_asmdata.asmlists[al_globals].concat(Tai_symbol.Createname_global('__fpc_stackplusmaxheap_in_para',AT_DATA,4));
+      current_asmdata.asmlists[al_globals].concat(Tai_symbol.Createname_global('__fpc_stackplusmaxheap_in_para',AT_DATA,4,u32inttype));
       current_asmdata.asmlists[al_globals].concat(Tai_const.Create_16bit(min($1000,stacksize_para+maxheapsize_para)));
       current_asmdata.asmlists[al_globals].concat(Tai_const.Create_16bit(min($1000,stacksize_para+maxheapsize_para)));
     end;
     end;
 
 

+ 1 - 1
compiler/llvm/aasmllvm.pas

@@ -251,7 +251,7 @@ uses
         inherited Create;
         inherited Create;
         typ:=ait_llvmalias;
         typ:=ait_llvmalias;
         oldsym:=_oldsym;
         oldsym:=_oldsym;
-        newsym:=current_asmdata.DefineAsmSymbol(newname,AB_GLOBAL,AT_FUNCTION);
+        newsym:=current_asmdata.DefineAsmSymbol(newname,AB_GLOBAL,AT_FUNCTION,_def);
         newsym.declared:=true;
         newsym.declared:=true;
         def:=_def;
         def:=_def;
         bind:=_bind;
         bind:=_bind;

+ 2 - 2
compiler/llvm/hlcgllvm.pas

@@ -1241,9 +1241,9 @@ implementation
         refer to the symbol and get the binding correct }
         refer to the symbol and get the binding correct }
       if (cs_profile in current_settings.moduleswitches) or
       if (cs_profile in current_settings.moduleswitches) or
          (po_global in current_procinfo.procdef.procoptions) then
          (po_global in current_procinfo.procdef.procoptions) then
-        asmsym:=current_asmdata.DefineAsmSymbol(mangledname,AB_GLOBAL,AT_FUNCTION)
+        asmsym:=current_asmdata.DefineAsmSymbol(mangledname,AB_GLOBAL,AT_FUNCTION,current_procinfo.procdef)
       else
       else
-        asmsym:=current_asmdata.DefineAsmSymbol(mangledname,AB_LOCAL,AT_FUNCTION);
+        asmsym:=current_asmdata.DefineAsmSymbol(mangledname,AB_LOCAL,AT_FUNCTION,current_procinfo.procdef);
       while assigned(item) do
       while assigned(item) do
         begin
         begin
           if mangledname<>item.Str then
           if mangledname<>item.Str then

+ 1 - 1
compiler/llvm/llvmpara.pas

@@ -197,7 +197,7 @@ unit llvmpara;
       paralocnr:=0;
       paralocnr:=0;
       repeat
       repeat
         paraloc^.llvmloc.loc:=LOC_REFERENCE;
         paraloc^.llvmloc.loc:=LOC_REFERENCE;
-        paraloc^.llvmloc.sym:=current_asmdata.DefineAsmSymbol(llvmparaname(hp,paralocnr),AB_TEMP,AT_DATA);
+        paraloc^.llvmloc.sym:=current_asmdata.DefineAsmSymbol(llvmparaname(hp,paralocnr),AB_TEMP,AT_DATA,paraloc^.def);
         { byval: a pointer to a type that should actually be passed by
         { byval: a pointer to a type that should actually be passed by
             value (e.g. a record that should be passed on the stack) }
             value (e.g. a record that should be passed on the stack) }
         paraloc^.llvmvalueloc:=
         paraloc^.llvmvalueloc:=

+ 3 - 3
compiler/llvm/nllvmutil.pas

@@ -57,9 +57,9 @@ implementation
       tcb: ttai_typedconstbuilder;
       tcb: ttai_typedconstbuilder;
     begin
     begin
       if sym.globalasmsym then
       if sym.globalasmsym then
-        asmsym:=current_asmdata.DefineAsmSymbol(sym.mangledname,AB_GLOBAL,AT_DATA)
+        asmsym:=current_asmdata.DefineAsmSymbol(sym.mangledname,AB_GLOBAL,AT_DATA,sym.vardef)
       else
       else
-        asmsym:=current_asmdata.DefineAsmSymbol(sym.mangledname,AB_LOCAL,AT_DATA);
+        asmsym:=current_asmdata.DefineAsmSymbol(sym.mangledname,AB_LOCAL,AT_DATA,sym.vardef);
       if not(vo_is_thread_var in sym.varoptions) then
       if not(vo_is_thread_var in sym.varoptions) then
         list.concat(taillvmdecl.createdef(asmsym,sym.vardef,nil,sec_data,varalign))
         list.concat(taillvmdecl.createdef(asmsym,sym.vardef,nil,sec_data,varalign))
       else if tf_section_threadvars in target_info.flags then
       else if tf_section_threadvars in target_info.flags then
@@ -68,7 +68,7 @@ implementation
         list.concat(taillvmdecl.createdef(asmsym,
         list.concat(taillvmdecl.createdef(asmsym,
           get_threadvar_record(sym.vardef,field1,field2),
           get_threadvar_record(sym.vardef,field1,field2),
           nil,sec_data,varalign));
           nil,sec_data,varalign));
-      symind:=current_asmdata.DefineAsmSymbol(sym.mangledname,AB_INDIRECT,AT_DATA);
+      symind:=current_asmdata.DefineAsmSymbol(sym.mangledname,AB_INDIRECT,AT_DATA,cpointerdef.getreusable(sym.vardef));
       tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable,tcalo_new_section]);
       tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable,tcalo_new_section]);
       tcb.emit_tai(Tai_const.Create_sym_offset(asmsym,0),cpointerdef.getreusable(sym.vardef));
       tcb.emit_tai(Tai_const.Create_sym_offset(asmsym,0),cpointerdef.getreusable(sym.vardef));
       list.concatlist(tcb.get_final_asmlist(
       list.concatlist(tcb.get_final_asmlist(

+ 2 - 2
compiler/m68k/hlcgcpu.pas

@@ -170,9 +170,9 @@ implementation
         make_global:=true;
         make_global:=true;
 
 
       if make_global then
       if make_global then
-        List.concat(Tai_symbol.Createname_global(labelname,AT_FUNCTION,0))
+        List.concat(Tai_symbol.Createname_global(labelname,AT_FUNCTION,0,procdef))
       else
       else
-        List.concat(Tai_symbol.Createname(labelname,AT_FUNCTION,0));
+        List.concat(Tai_symbol.Createname(labelname,AT_FUNCTION,0,procdef));
 
 
       { set param1 interface to self  }
       { set param1 interface to self  }
       g_adjust_self_value(list,procdef,ioffset);
       g_adjust_self_value(list,procdef,ioffset);

+ 2 - 2
compiler/mips/hlcgcpu.pas

@@ -202,9 +202,9 @@ implementation
       make_global := True;
       make_global := True;
 
 
     if make_global then
     if make_global then
-      List.concat(Tai_symbol.Createname_global(labelname, AT_FUNCTION, 0))
+      List.concat(Tai_symbol.Createname_global(labelname, AT_FUNCTION, 0, procdef))
     else
     else
-      List.concat(Tai_symbol.Createname(labelname, AT_FUNCTION, 0));
+      List.concat(Tai_symbol.Createname(labelname, AT_FUNCTION, 0, procdef));
 
 
     IsVirtual:=(po_virtualmethod in procdef.procoptions) and
     IsVirtual:=(po_virtualmethod in procdef.procoptions) and
         not is_objectpascal_helper(procdef.struct);
         not is_objectpascal_helper(procdef.struct);

+ 1 - 1
compiler/ncal.pas

@@ -576,7 +576,7 @@ implementation
         current_module.localsymtable.insert(calldescsym);
         current_module.localsymtable.insert(calldescsym);
         current_asmdata.AsmLists[al_typedconsts].concatList(
         current_asmdata.AsmLists[al_typedconsts].concatList(
           tcb.get_final_asmlist(
           tcb.get_final_asmlist(
-            current_asmdata.DefineAsmSymbol(calldescsym.mangledname,AB_GLOBAL,AT_DATA),
+            current_asmdata.DefineAsmSymbol(calldescsym.mangledname,AB_GLOBAL,AT_DATA,calldescsym.vardef),
             calldescsym.vardef,sec_rodata_norel,
             calldescsym.vardef,sec_rodata_norel,
             lower(calldescsym.mangledname),sizeof(pint)
             lower(calldescsym.mangledname),sizeof(pint)
           )
           )

+ 1 - 1
compiler/ncgcal.pas

@@ -955,7 +955,7 @@ implementation
              if not is_interface(tprocdef(procdefinition)._class) then
              if not is_interface(tprocdef(procdefinition)._class) then
                begin
                begin
                  inc(current_asmdata.NextVTEntryNr);
                  inc(current_asmdata.NextVTEntryNr);
-                 current_asmdata.CurrAsmList.Concat(tai_symbol.CreateName('VTREF'+tostr(current_asmdata.NextVTEntryNr)+'_'+tprocdef(procdefinition).struct.vmt_mangledname+'$$'+tostr(vmtoffset div sizeof(pint)),AT_FUNCTION,0));
+                 current_asmdata.CurrAsmList.Concat(tai_symbol.CreateName('VTREF'+tostr(current_asmdata.NextVTEntryNr)+'_'+tprocdef(procdefinition).struct.vmt_mangledname+'$$'+tostr(vmtoffset div sizeof(pint)),AT_FUNCTION,0,voidpointerdef));
                end;
                end;
 {$endif vtentry}
 {$endif vtentry}
 
 

+ 1 - 1
compiler/ncgld.pas

@@ -549,7 +549,7 @@ implementation
                          if not is_interface(procdef.struct) then
                          if not is_interface(procdef.struct) then
                            begin
                            begin
                              inc(current_asmdata.NextVTEntryNr);
                              inc(current_asmdata.NextVTEntryNr);
-                             current_asmdata.CurrAsmList.Concat(tai_symbol.CreateName('VTREF'+tostr(current_asmdata.NextVTEntryNr)+'_'+procdef._class.vmt_mangledname+'$$'+tostr(vmtoffset div sizeof(pint)),AT_FUNCTION,0));
+                             current_asmdata.CurrAsmList.Concat(tai_symbol.CreateName('VTREF'+tostr(current_asmdata.NextVTEntryNr)+'_'+procdef._class.vmt_mangledname+'$$'+tostr(vmtoffset div sizeof(pint)),AT_FUNCTION,0,voidpointerdef));
                            end;
                            end;
             {$endif vtentry}
             {$endif vtentry}
                          if (left.resultdef.typ=objectdef) and
                          if (left.resultdef.typ=objectdef) and

+ 13 - 9
compiler/ncgrtti.pas

@@ -1274,6 +1274,7 @@ implementation
             r:single;             {Must be real type because of integer overflow risk.}
             r:single;             {Must be real type because of integer overflow risk.}
             tcb: ttai_typedconstbuilder;
             tcb: ttai_typedconstbuilder;
             sym_count: integer;
             sym_count: integer;
+            tabledef: tdef;
         begin
         begin
 
 
           {Decide wether a lookup array is size efficient.}
           {Decide wether a lookup array is size efficient.}
@@ -1310,7 +1311,6 @@ implementation
             end;
             end;
           { write rtti data; make sure that the alignment matches the corresponding data structure
           { write rtti data; make sure that the alignment matches the corresponding data structure
             in the code that uses it (if alignment is required). }
             in the code that uses it (if alignment is required). }
-          rttilab:=current_asmdata.DefineAsmSymbol(Tstoreddef(def).rtti_mangledname(rt)+'_o2s',AB_GLOBAL,AT_DATA);
           tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable]);
           tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable]);
           { use TConstPtrUInt packrecords to ensure good alignment }
           { use TConstPtrUInt packrecords to ensure good alignment }
           tcb.begin_anonymous_record('',defaultpacking,reqalign,
           tcb.begin_anonymous_record('',defaultpacking,reqalign,
@@ -1365,14 +1365,16 @@ implementation
             end;
             end;
             tcb.end_anonymous_record;
             tcb.end_anonymous_record;
 
 
+            tabledef:=tcb.end_anonymous_record;
+            rttilab:=current_asmdata.DefineAsmSymbol(Tstoreddef(def).rtti_mangledname(rt)+'_o2s',AB_GLOBAL,AT_DATA,tabledef);
             current_asmdata.asmlists[al_rtti].concatlist(tcb.get_final_asmlist(
             current_asmdata.asmlists[al_rtti].concatlist(tcb.get_final_asmlist(
-              rttilab,tcb.end_anonymous_record,sec_rodata,
+              rttilab,tabledef,sec_rodata,
               rttilab.name,const_align(sizeof(pint))));
               rttilab.name,const_align(sizeof(pint))));
             tcb.free;
             tcb.free;
 
 
             { write indirect symbol }
             { write indirect symbol }
             tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable]);
             tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable]);
-            rttilabind:=current_asmdata.DefineAsmSymbol(Tstoreddef(def).rtti_mangledname(rt)+'_o2s',AB_INDIRECT,AT_DATA);
+            rttilabind:=current_asmdata.DefineAsmSymbol(Tstoreddef(def).rtti_mangledname(rt)+'_o2s',AB_INDIRECT,AT_DATA,cpointerdef.getreusable(tabledef));
             tcb.emit_tai(Tai_const.Createname(rttilab.name,AT_DATA,0),voidpointertype);
             tcb.emit_tai(Tai_const.Createname(rttilab.name,AT_DATA,0),voidpointertype);
             current_asmdata.AsmLists[al_rtti].concatList(
             current_asmdata.AsmLists[al_rtti].concatList(
               tcb.get_final_asmlist(rttilabind,voidpointertype,sec_rodata,rttilabind.name,const_align(sizeof(pint))));
               tcb.get_final_asmlist(rttilabind,voidpointertype,sec_rodata,rttilabind.name,const_align(sizeof(pint))));
@@ -1390,9 +1392,9 @@ implementation
           rttilab,
           rttilab,
           rttilabind : Tasmsymbol;
           rttilabind : Tasmsymbol;
           i:longint;
           i:longint;
+          tabledef: tdef;
         begin
         begin
           { write rtti data }
           { write rtti data }
-          rttilab:=current_asmdata.DefineAsmSymbol(Tstoreddef(def).rtti_mangledname(rt)+'_s2o',AB_GLOBAL,AT_DATA);
           tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable]);
           tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable]);
           { begin of Tstring_to_ord }
           { begin of Tstring_to_ord }
           tcb.begin_anonymous_record('',defaultpacking,reqalign,
           tcb.begin_anonymous_record('',defaultpacking,reqalign,
@@ -1417,13 +1419,15 @@ implementation
               tcb.queue_emit_asmsym(mainrtti,rttidef);
               tcb.queue_emit_asmsym(mainrtti,rttidef);
             end;
             end;
           tcb.end_anonymous_record;
           tcb.end_anonymous_record;
+          tabledef:=tcb.end_anonymous_record;
+          rttilab:=current_asmdata.DefineAsmSymbol(Tstoreddef(def).rtti_mangledname(rt)+'_s2o',AB_GLOBAL,AT_DATA,tabledef);
           current_asmdata.asmlists[al_rtti].concatlist(tcb.get_final_asmlist(
           current_asmdata.asmlists[al_rtti].concatlist(tcb.get_final_asmlist(
-            rttilab,tcb.end_anonymous_record,sec_rodata,
+            rttilab,tabledef,sec_rodata,
             rttilab.name,const_align(sizeof(pint))));
             rttilab.name,const_align(sizeof(pint))));
           tcb.free;
           tcb.free;
           { write indirect symbol }
           { write indirect symbol }
           tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable]);
           tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable]);
-          rttilabind:=current_asmdata.DefineAsmSymbol(Tstoreddef(def).rtti_mangledname(rt)+'_s2o',AB_INDIRECT,AT_DATA);
+          rttilabind:=current_asmdata.DefineAsmSymbol(Tstoreddef(def).rtti_mangledname(rt)+'_s2o',AB_INDIRECT,AT_DATA,cpointerdef.getreusable(tabledef));
           tcb.emit_tai(Tai_const.Createname(rttilab.name,AT_DATA,0),voidpointertype);
           tcb.emit_tai(Tai_const.Createname(rttilab.name,AT_DATA,0),voidpointertype);
           current_asmdata.AsmLists[al_rtti].concatList(
           current_asmdata.AsmLists[al_rtti].concatList(
             tcb.get_final_asmlist(rttilabind,voidpointertype,sec_rodata,rttilabind.name,const_align(sizeof(pint))));
             tcb.get_final_asmlist(rttilabind,voidpointertype,sec_rodata,rttilabind.name,const_align(sizeof(pint))));
@@ -1559,21 +1563,21 @@ implementation
         write_child_rtti_data(def,rt);
         write_child_rtti_data(def,rt);
         { write rtti data }
         { write rtti data }
         tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable]);
         tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable]);
-        rttilab:=current_asmdata.DefineAsmSymbol(tstoreddef(def).rtti_mangledname(rt),AB_GLOBAL,AT_DATA);
         tcb.begin_anonymous_record(
         tcb.begin_anonymous_record(
-          internaltypeprefixName[itp_rttidef]+rttilab.Name,
+          internaltypeprefixName[itp_rttidef]+tstoreddef(def).rtti_mangledname(rt),
           defaultpacking,reqalign,
           defaultpacking,reqalign,
           targetinfos[target_info.system]^.alignment.recordalignmin,
           targetinfos[target_info.system]^.alignment.recordalignmin,
           targetinfos[target_info.system]^.alignment.maxCrecordalign
           targetinfos[target_info.system]^.alignment.maxCrecordalign
         );
         );
         write_rtti_data(tcb,def,rt);
         write_rtti_data(tcb,def,rt);
         rttidef:=tcb.end_anonymous_record;
         rttidef:=tcb.end_anonymous_record;
+        rttilab:=current_asmdata.DefineAsmSymbol(tstoreddef(def).rtti_mangledname(rt),AB_GLOBAL,AT_DATA,rttidef);
         current_asmdata.AsmLists[al_rtti].concatList(
         current_asmdata.AsmLists[al_rtti].concatList(
           tcb.get_final_asmlist(rttilab,rttidef,sec_rodata,rttilab.name,const_align(sizeof(pint))));
           tcb.get_final_asmlist(rttilab,rttidef,sec_rodata,rttilab.name,const_align(sizeof(pint))));
         tcb.free;
         tcb.free;
         { write indirect symbol }
         { write indirect symbol }
         tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable]);
         tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable]);
-        rttilabind:=current_asmdata.DefineAsmSymbol(tstoreddef(def).rtti_mangledname(rt),AB_INDIRECT,AT_DATA);
+        rttilabind:=current_asmdata.DefineAsmSymbol(tstoreddef(def).rtti_mangledname(rt),AB_INDIRECT,AT_DATA,cpointerdef.getreusable(rttidef));
         tcb.emit_tai(Tai_const.Createname(rttilab.name,AT_DATA,0),voidpointertype);
         tcb.emit_tai(Tai_const.Createname(rttilab.name,AT_DATA,0),voidpointertype);
         current_asmdata.AsmLists[al_rtti].concatList(
         current_asmdata.AsmLists[al_rtti].concatList(
           tcb.get_final_asmlist(rttilabind,voidpointertype,sec_rodata,rttilabind.name,const_align(sizeof(pint))));
           tcb.get_final_asmlist(rttilabind,voidpointertype,sec_rodata,rttilabind.name,const_align(sizeof(pint))));

+ 2 - 2
compiler/ncgutil.pas

@@ -1381,9 +1381,9 @@ implementation
               erroneous code (at least for targets using GOT) } 
               erroneous code (at least for targets using GOT) } 
             if (cs_profile in current_settings.moduleswitches) or
             if (cs_profile in current_settings.moduleswitches) or
                (po_global in current_procinfo.procdef.procoptions) then
                (po_global in current_procinfo.procdef.procoptions) then
-              current_asmdata.DefineAsmSymbol(item.str,AB_GLOBAL,AT_FUNCTION)
+              current_asmdata.DefineAsmSymbol(item.str,AB_GLOBAL,AT_FUNCTION,pd)
             else
             else
-              current_asmdata.DefineAsmSymbol(item.str,AB_LOCAL,AT_FUNCTION);
+              current_asmdata.DefineAsmSymbol(item.str,AB_LOCAL,AT_FUNCTION,pd);
            item := TCmdStrListItem(item.next);
            item := TCmdStrListItem(item.next);
          end;
          end;
       end;
       end;

+ 7 - 7
compiler/ncgvmt.pas

@@ -909,7 +909,7 @@ implementation
           tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable]);
           tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable]);
           tcb.emit_guid_const(_class.iidguid^);
           tcb.emit_guid_const(_class.iidguid^);
           list.concatlist(tcb.get_final_asmlist(
           list.concatlist(tcb.get_final_asmlist(
-            current_asmdata.DefineAsmSymbol(s,AB_GLOBAL,AT_DATA),
+            current_asmdata.DefineAsmSymbol(s,AB_GLOBAL,AT_DATA,rec_tguid),
             rec_tguid,
             rec_tguid,
             sec_rodata,
             sec_rodata,
             s,
             s,
@@ -920,7 +920,7 @@ implementation
       tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable]);
       tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable]);
       def:=tcb.emit_shortstring_const(_class.iidstr^);
       def:=tcb.emit_shortstring_const(_class.iidstr^);
       list.concatlist(tcb.get_final_asmlist(
       list.concatlist(tcb.get_final_asmlist(
-        current_asmdata.DefineAsmSymbol(s,AB_GLOBAL,AT_DATA),
+        current_asmdata.DefineAsmSymbol(s,AB_GLOBAL,AT_DATA,def),
         def,
         def,
         sec_rodata,
         sec_rodata,
         s,
         s,
@@ -1017,7 +1017,7 @@ implementation
            tcb.emit_tai(Tai_const.Createname(procname,AT_FUNCTION,0),cprocvardef.getreusableprocaddr(vmtpd));
            tcb.emit_tai(Tai_const.Createname(procname,AT_FUNCTION,0),cprocvardef.getreusableprocaddr(vmtpd));
 {$ifdef vtentry}
 {$ifdef vtentry}
            hs:='VTENTRY'+'_'+_class.vmt_mangledname+'$$'+tostr(_class.vmtmethodoffset(i) div sizeof(pint));
            hs:='VTENTRY'+'_'+_class.vmt_mangledname+'$$'+tostr(_class.vmtmethodoffset(i) div sizeof(pint));
-           current_asmdata.asmlists[al_globals].concat(tai_symbol.CreateName(hs,AT_DATA,0));
+           current_asmdata.asmlists[al_globals].concat(tai_symbol.CreateName(hs,AT_DATA,0,voidpointerdef));
 {$endif vtentry}
 {$endif vtentry}
          end;
          end;
       end;
       end;
@@ -1202,7 +1202,7 @@ implementation
          { concatenate the VMT to the asmlist }
          { concatenate the VMT to the asmlist }
          current_asmdata.asmlists[al_globals].concatlist(
          current_asmdata.asmlists[al_globals].concatlist(
            tcb.get_final_asmlist(
            tcb.get_final_asmlist(
-             current_asmdata.DefineAsmSymbol(_class.vmt_mangledname,AB_GLOBAL,AT_DATA),
+             current_asmdata.DefineAsmSymbol(_class.vmt_mangledname,AB_GLOBAL,AT_DATA,vmtdef),
              vmtdef,sec_rodata,_class.vmt_mangledname,const_align(sizeof(pint))
              vmtdef,sec_rodata,_class.vmt_mangledname,const_align(sizeof(pint))
            )
            )
          );
          );
@@ -1214,7 +1214,7 @@ implementation
            hs:=hs+_class.childof.vmt_mangledname
            hs:=hs+_class.childof.vmt_mangledname
          else
          else
            hs:=hs+_class.vmt_mangledname;
            hs:=hs+_class.vmt_mangledname;
-         current_asmdata.asmlists[al_globals].concat(tai_symbol.CreateName(hs,AT_DATA,0));
+         current_asmdata.asmlists[al_globals].concat(tai_symbol.CreateName(hs,AT_DATA,0,voidpointerdef));
 {$endif vtentry}
 {$endif vtentry}
         symtablestack.pop(current_module.localsymtable);
         symtablestack.pop(current_module.localsymtable);
 
 
@@ -1224,8 +1224,8 @@ implementation
         tcb.emit_tai(Tai_const.Createname(hs,AT_DATA,0),voidpointertype);
         tcb.emit_tai(Tai_const.Createname(hs,AT_DATA,0),voidpointertype);
         current_asmdata.AsmLists[al_globals].concatList(
         current_asmdata.AsmLists[al_globals].concatList(
           tcb.get_final_asmlist(
           tcb.get_final_asmlist(
-            current_asmdata.DefineAsmSymbol(hs,AB_INDIRECT,AT_DATA),
-            voidpointertype,sec_rodata,hs,const_align(sizeof(pint))));
+            current_asmdata.DefineAsmSymbol(hs,AB_INDIRECT,AT_DATA,cpointerdef.getreusable(vmtdef)),
+            cpointerdef.getreusable(vmtdef),sec_rodata,hs,const_align(sizeof(pint))));
         tcb.free;
         tcb.free;
       end;
       end;
 
 

+ 34 - 25
compiler/ngenutil.pas

@@ -730,19 +730,18 @@ implementation
              (cs_debuginfo in current_settings.moduleswitches) and
              (cs_debuginfo in current_settings.moduleswitches) and
              not assigned(current_asmdata.GetAsmSymbol(sym.name)) then
              not assigned(current_asmdata.GetAsmSymbol(sym.name)) then
             begin
             begin
-              list.concat(tai_symbol.Create(current_asmdata.DefineAsmSymbol(sym.name,AB_LOCAL,AT_DATA),0));
+              list.concat(tai_symbol.Create(current_asmdata.DefineAsmSymbol(sym.name,AB_LOCAL,AT_DATA,sym.vardef),0));
               list.concat(tai_directive.Create(asd_reference,sym.name));
               list.concat(tai_directive.Create(asd_reference,sym.name));
             end;
             end;
-          list.concat(Tai_datablock.create_global(sym.mangledname,size));
+          list.concat(Tai_datablock.create_global(sym.mangledname,size,sym.vardef));
         end
         end
       else
       else
-        list.concat(Tai_datablock.create(sym.mangledname,size));
-
+        list.concat(Tai_datablock.create(sym.mangledname,size,sym.vardef));
       if (tf_supports_packages in target_info.flags) then
       if (tf_supports_packages in target_info.flags) then
         begin
         begin
           { add the indirect symbol if needed }
           { add the indirect symbol if needed }
           new_section(list,sec_rodata,lower(sym.mangledname),const_align(sym.vardef.alignment));
           new_section(list,sec_rodata,lower(sym.mangledname),const_align(sym.vardef.alignment));
-          symind:=current_asmdata.DefineAsmSymbol(sym.mangledname,AB_INDIRECT,AT_DATA);
+          symind:=current_asmdata.DefineAsmSymbol(sym.mangledname,AB_INDIRECT,AT_DATA,cpointerdef.getreusable(sym.vardef));
           list.concat(Tai_symbol.Create_Global(symind,0));
           list.concat(Tai_symbol.Create_Global(symind,0));
           list.concat(Tai_const.Createname(sym.mangledname,AT_DATA,0));
           list.concat(Tai_const.Createname(sym.mangledname,AT_DATA,0));
           list.concat(tai_symbol_end.Create(symind));
           list.concat(tai_symbol_end.Create(symind));
@@ -855,6 +854,7 @@ implementation
       count : aint;
       count : aint;
       tablecountplaceholder: ttypedconstplaceholder;
       tablecountplaceholder: ttypedconstplaceholder;
       nameinit,namefini : TSymStr;
       nameinit,namefini : TSymStr;
+      tabledef: tdef;
 
 
       procedure write_struct_inits(u: tmodule);
       procedure write_struct_inits(u: tmodule);
         var
         var
@@ -1002,10 +1002,11 @@ implementation
       tablecountplaceholder.free;
       tablecountplaceholder.free;
       { Add to data segment }
       { Add to data segment }
 
 
+      tabledef:=unitinits.end_anonymous_record;
       current_asmdata.asmlists[al_globals].concatlist(
       current_asmdata.asmlists[al_globals].concatlist(
         unitinits.get_final_asmlist(
         unitinits.get_final_asmlist(
-          current_asmdata.DefineAsmSymbol('INITFINAL',AB_GLOBAL,AT_DATA),
-          unitinits.end_anonymous_record,
+          current_asmdata.DefineAsmSymbol('INITFINAL',AB_GLOBAL,AT_DATA,tabledef),
+          tabledef,
           sec_data,'INITFINAL',sizeof(pint)
           sec_data,'INITFINAL',sizeof(pint)
         )
         )
       );
       );
@@ -1021,6 +1022,7 @@ implementation
       count: longint;
       count: longint;
       sym: tasmsymbol;
       sym: tasmsymbol;
       placeholder: ttypedconstplaceholder;
       placeholder: ttypedconstplaceholder;
+      tabledef: tdef;
     begin
     begin
       if (tf_section_threadvars in target_info.flags) then
       if (tf_section_threadvars in target_info.flags) then
         exit;
         exit;
@@ -1058,10 +1060,11 @@ implementation
       placeholder.replace(tai_const.Create_32bit(count),u32inttype);
       placeholder.replace(tai_const.Create_32bit(count),u32inttype);
       placeholder.free;
       placeholder.free;
       { insert in data segment }
       { insert in data segment }
-      sym:=current_asmdata.DefineAsmSymbol('FPC_THREADVARTABLES',AB_GLOBAL,AT_DATA);
+      tabledef:=tcb.end_anonymous_record;
+      sym:=current_asmdata.DefineAsmSymbol('FPC_THREADVARTABLES',AB_GLOBAL,AT_DATA,tabledef);
       current_asmdata.asmlists[al_globals].concatlist(
       current_asmdata.asmlists[al_globals].concatlist(
         tcb.get_final_asmlist(
         tcb.get_final_asmlist(
-          sym,tcb.end_anonymous_record,sec_data,'FPC_THREADVARTABLES',sizeof(pint)
+          sym,tabledef,sec_data,'FPC_THREADVARTABLES',sizeof(pint)
         )
         )
       );
       );
       tcb.free;
       tcb.free;
@@ -1115,7 +1118,7 @@ implementation
        if add then
        if add then
          begin
          begin
            s:=make_mangledname('THREADVARLIST',current_module.localsymtable,'');
            s:=make_mangledname('THREADVARLIST',current_module.localsymtable,'');
-           sym:=current_asmdata.DefineAsmSymbol(s,AB_GLOBAL,AT_DATA);
+           sym:=current_asmdata.DefineAsmSymbol(s,AB_GLOBAL,AT_DATA,tabledef);
            current_asmdata.asmlists[al_globals].concatlist(
            current_asmdata.asmlists[al_globals].concatlist(
              tcb.get_final_asmlist(sym,tabledef,sec_data,s,sizeof(pint)));
              tcb.get_final_asmlist(sym,tabledef,sec_data,s,sizeof(pint)));
            current_module.flags:=current_module.flags or uf_threadvars;
            current_module.flags:=current_module.flags or uf_threadvars;
@@ -1127,10 +1130,10 @@ implementation
          begin
          begin
            { write indirect symbol }
            { write indirect symbol }
            tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable,tcalo_new_section]);
            tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable,tcalo_new_section]);
-           sym:=current_asmdata.DefineAsmSymbol(s,AB_INDIRECT,AT_DATA);
-           tcb.emit_tai(Tai_const.Create_sym(current_asmdata.RefAsmSymbol(s,AT_DATA,false)),voidpointertype);
+           tcb.emit_tai(Tai_const.Create_sym(current_asmdata.RefAsmSymbol(s,AT_DATA,false)),cpointerdef.getreusable(tabledef));
+           sym:=current_asmdata.DefineAsmSymbol(s,AB_INDIRECT,AT_DATA,voidpointertype);
            current_asmdata.AsmLists[al_globals].concatList(
            current_asmdata.AsmLists[al_globals].concatList(
-             tcb.get_final_asmlist(sym,voidpointertype,sec_rodata,sym.name,const_align(sizeof(pint))));
+             tcb.get_final_asmlist(sym,cpointerdef.getreusable(tabledef),sec_rodata,sym.name,const_align(sizeof(pint))));
            tcb.free;
            tcb.free;
          end;
          end;
     end;
     end;
@@ -1141,6 +1144,7 @@ implementation
       hp: tused_unit;
       hp: tused_unit;
       tcb: ttai_typedconstbuilder;
       tcb: ttai_typedconstbuilder;
       countplaceholder: ttypedconstplaceholder;
       countplaceholder: ttypedconstplaceholder;
+      tabledef: tdef;
       count: longint;
       count: longint;
     begin
     begin
       tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable,tcalo_new_section]);
       tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable,tcalo_new_section]);
@@ -1175,10 +1179,11 @@ implementation
       countplaceholder.replace(Tai_const.Create_pint(count),ptruinttype);
       countplaceholder.replace(Tai_const.Create_pint(count),ptruinttype);
       countplaceholder.free;
       countplaceholder.free;
       { insert in data segment }
       { insert in data segment }
+      tabledef:=tcb.end_anonymous_record;
       current_asmdata.asmlists[al_globals].concatlist(
       current_asmdata.asmlists[al_globals].concatlist(
         tcb.get_final_asmlist(
         tcb.get_final_asmlist(
-          current_asmdata.DefineAsmSymbol(tablename,AB_GLOBAL,AT_DATA),
-          tcb.end_anonymous_record,
+          current_asmdata.DefineAsmSymbol(tablename,AB_GLOBAL,AT_DATA,tabledef),
+          tabledef,
           sec_data,tablename,sizeof(pint)
           sec_data,tablename,sizeof(pint)
         )
         )
       );
       );
@@ -1197,7 +1202,9 @@ implementation
       s:=make_mangledname(prefix,current_module.localsymtable,'');
       s:=make_mangledname(prefix,current_module.localsymtable,'');
       maybe_new_object_file(current_asmdata.asmlists[al_globals]);
       maybe_new_object_file(current_asmdata.asmlists[al_globals]);
       new_section(current_asmdata.asmlists[al_globals],sec_data,s,sizeof(pint));
       new_section(current_asmdata.asmlists[al_globals],sec_data,s,sizeof(pint));
-      current_asmdata.asmlists[al_globals].concat(Tai_symbol.Createname_global(s,AT_DATA,0));
+      { TODO: def of the symbol to be fixed when this is converted to to the
+          typed constant builder }
+      current_asmdata.asmlists[al_globals].concat(Tai_symbol.Createname_global(s,AT_DATA,0,voidpointertype));
       repeat
       repeat
         { optimize away unused local/static symbols }
         { optimize away unused local/static symbols }
         if (item.sym.refs>0) or (item.sym.owner.symtabletype=globalsymtable) then
         if (item.sym.refs>0) or (item.sym.owner.symtabletype=globalsymtable) then
@@ -1246,6 +1253,7 @@ implementation
       count : longint;
       count : longint;
       tcb : ttai_typedconstbuilder;
       tcb : ttai_typedconstbuilder;
       countplaceholder : ttypedconstplaceholder;
       countplaceholder : ttypedconstplaceholder;
+      tabledef: tdef;
     begin
     begin
       tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable,tcalo_new_section]);
       tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable,tcalo_new_section]);
       count:=0;
       count:=0;
@@ -1274,10 +1282,11 @@ implementation
       countplaceholder.replace(Tai_const.Create_pint(count),ptruinttype);
       countplaceholder.replace(Tai_const.Create_pint(count),ptruinttype);
       countplaceholder.free;
       countplaceholder.free;
       { Add to data segment }
       { Add to data segment }
+      tabledef:=tcb.end_anonymous_record;
       current_asmdata.AsmLists[al_globals].concatList(
       current_asmdata.AsmLists[al_globals].concatList(
         tcb.get_final_asmlist(
         tcb.get_final_asmlist(
-          current_asmdata.DefineAsmSymbol('FPC_RESOURCESTRINGTABLES',AB_GLOBAL,AT_DATA),
-          tcb.end_anonymous_record,sec_rodata,'FPC_RESOURCESTRINGTABLES',sizeof(pint)
+          current_asmdata.DefineAsmSymbol('FPC_RESOURCESTRINGTABLES',AB_GLOBAL,AT_DATA,tabledef),
+          tabledef,sec_rodata,'FPC_RESOURCESTRINGTABLES',sizeof(pint)
         )
         )
       );
       );
       tcb.free;
       tcb.free;
@@ -1302,7 +1311,7 @@ implementation
             tcb.emit_tai(tai_const.Create_nil_dataptr,voidpointertype);
             tcb.emit_tai(tai_const.Create_nil_dataptr,voidpointertype);
           current_asmdata.asmlists[al_globals].concatList(
           current_asmdata.asmlists[al_globals].concatList(
             tcb.get_final_asmlist(
             tcb.get_final_asmlist(
-              current_asmdata.DefineAsmSymbol('FPC_RESLOCATION',AB_GLOBAL,AT_DATA),
+              current_asmdata.DefineAsmSymbol('FPC_RESLOCATION',AB_GLOBAL,AT_DATA,voidpointertype),
               voidpointertype,
               voidpointertype,
               sec_rodata,
               sec_rodata,
               'FPC_RESLOCATION',
               'FPC_RESLOCATION',
@@ -1330,7 +1339,7 @@ implementation
       tcb.maybe_begin_aggregate(def);
       tcb.maybe_begin_aggregate(def);
       tcb.emit_tai(Tai_string.Create(s),def);
       tcb.emit_tai(Tai_string.Create(s),def);
       tcb.maybe_end_aggregate(def);
       tcb.maybe_end_aggregate(def);
-      sym:=current_asmdata.DefineAsmSymbol('__fpc_ident',AB_LOCAL,AT_DATA);
+      sym:=current_asmdata.DefineAsmSymbol('__fpc_ident',AB_LOCAL,AT_DATA,def);
       current_asmdata.asmlists[al_globals].concatlist(
       current_asmdata.asmlists[al_globals].concatlist(
         tcb.get_final_asmlist(sym,def,sec_fpc,'version',const_align(32))
         tcb.get_final_asmlist(sym,def,sec_fpc,'version',const_align(32))
       );
       );
@@ -1342,7 +1351,7 @@ implementation
           { stacksize can be specified and is now simulated }
           { stacksize can be specified and is now simulated }
           tcb:=ctai_typedconstbuilder.create([tcalo_new_section,tcalo_make_dead_strippable]);
           tcb:=ctai_typedconstbuilder.create([tcalo_new_section,tcalo_make_dead_strippable]);
           tcb.emit_tai(Tai_const.Create_pint(stacksize),ptruinttype);
           tcb.emit_tai(Tai_const.Create_pint(stacksize),ptruinttype);
-          sym:=current_asmdata.DefineAsmSymbol('__stklen',AB_GLOBAL,AT_DATA);
+          sym:=current_asmdata.DefineAsmSymbol('__stklen',AB_GLOBAL,AT_DATA,ptruinttype);
           current_asmdata.asmlists[al_globals].concatlist(
           current_asmdata.asmlists[al_globals].concatlist(
             tcb.get_final_asmlist(sym,ptruinttype,sec_data,'__stklen',sizeof(pint))
             tcb.get_final_asmlist(sym,ptruinttype,sec_data,'__stklen',sizeof(pint))
           );
           );
@@ -1362,7 +1371,7 @@ implementation
          tcb.maybe_begin_aggregate(def);
          tcb.maybe_begin_aggregate(def);
          tcb.emit_tai(Tai_string.Create(s),def);
          tcb.emit_tai(Tai_string.Create(s),def);
          tcb.maybe_end_aggregate(def);
          tcb.maybe_end_aggregate(def);
-         sym:=current_asmdata.DefineAsmSymbol('__stack_cookie',AB_GLOBAL,AT_DATA);
+         sym:=current_asmdata.DefineAsmSymbol('__stack_cookie',AB_GLOBAL,AT_DATA,def);
          current_asmdata.asmlists[al_globals].concatlist(
          current_asmdata.asmlists[al_globals].concatlist(
            tcb.get_final_asmlist(sym,def,sec_data,'__stack_cookie',sizeof(pint))
            tcb.get_final_asmlist(sym,def,sec_data,'__stack_cookie',sizeof(pint))
          );
          );
@@ -1372,7 +1381,7 @@ implementation
       { Initial heapsize }
       { Initial heapsize }
       tcb:=ctai_typedconstbuilder.create([tcalo_new_section,tcalo_make_dead_strippable]);
       tcb:=ctai_typedconstbuilder.create([tcalo_new_section,tcalo_make_dead_strippable]);
       tcb.emit_tai(Tai_const.Create_pint(heapsize),ptruinttype);
       tcb.emit_tai(Tai_const.Create_pint(heapsize),ptruinttype);
-      sym:=current_asmdata.DefineAsmSymbol('__heapsize',AB_GLOBAL,AT_DATA);
+      sym:=current_asmdata.DefineAsmSymbol('__heapsize',AB_GLOBAL,AT_DATA,ptruinttype);
       current_asmdata.asmlists[al_globals].concatlist(
       current_asmdata.asmlists[al_globals].concatlist(
         tcb.get_final_asmlist(sym,ptruinttype,sec_data,'__heapsize',sizeof(pint))
         tcb.get_final_asmlist(sym,ptruinttype,sec_data,'__heapsize',sizeof(pint))
       );
       );
@@ -1386,13 +1395,13 @@ implementation
             is separate in the builder }
             is separate in the builder }
           maybe_new_object_file(current_asmdata.asmlists[al_globals]);
           maybe_new_object_file(current_asmdata.asmlists[al_globals]);
           new_section(current_asmdata.asmlists[al_globals],sec_bss,'__fpc_initialheap',current_settings.alignment.varalignmax);
           new_section(current_asmdata.asmlists[al_globals],sec_bss,'__fpc_initialheap',current_settings.alignment.varalignmax);
-          current_asmdata.asmlists[al_globals].concat(tai_datablock.Create_global('__fpc_initialheap',heapsize));
+          current_asmdata.asmlists[al_globals].concat(tai_datablock.Create_global('__fpc_initialheap',heapsize,carraydef.getreusable(u8inttype,heapsize)));
         end;
         end;
 
 
       { Valgrind usage }
       { Valgrind usage }
       tcb:=ctai_typedconstbuilder.create([tcalo_new_section,tcalo_make_dead_strippable]);
       tcb:=ctai_typedconstbuilder.create([tcalo_new_section,tcalo_make_dead_strippable]);
       tcb.emit_ord_const(byte(cs_gdb_valgrind in current_settings.globalswitches),u8inttype);
       tcb.emit_ord_const(byte(cs_gdb_valgrind in current_settings.globalswitches),u8inttype);
-      sym:=current_asmdata.DefineAsmSymbol('__fpc_valgrind',AB_GLOBAL,AT_DATA);
+      sym:=current_asmdata.DefineAsmSymbol('__fpc_valgrind',AB_GLOBAL,AT_DATA,u8inttype);
       current_asmdata.asmlists[al_globals].concatlist(
       current_asmdata.asmlists[al_globals].concatlist(
         tcb.get_final_asmlist(sym,ptruinttype,sec_data,'__fpc_valgrind',sizeof(pint))
         tcb.get_final_asmlist(sym,ptruinttype,sec_data,'__fpc_valgrind',sizeof(pint))
       );
       );

+ 3 - 3
compiler/ngtcon.pas

@@ -1089,10 +1089,10 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
                (cs_debuginfo in current_settings.moduleswitches) and
                (cs_debuginfo in current_settings.moduleswitches) and
                not assigned(current_asmdata.GetAsmSymbol(fsym.name)) then
                not assigned(current_asmdata.GetAsmSymbol(fsym.name)) then
               addstabx:=true;
               addstabx:=true;
-            asmsym:=current_asmdata.DefineAsmSymbol(fsym.mangledname,AB_GLOBAL,AT_DATA)
+            asmsym:=current_asmdata.DefineAsmSymbol(fsym.mangledname,AB_GLOBAL,AT_DATA,tcsym.vardef)
           end
           end
         else
         else
-          asmsym:=current_asmdata.DefineAsmSymbol(fsym.mangledname,AB_LOCAL,AT_DATA);
+          asmsym:=current_asmdata.DefineAsmSymbol(fsym.mangledname,AB_LOCAL,AT_DATA,tcsym.vardef);
         if vo_has_section in fsym.varoptions then
         if vo_has_section in fsym.varoptions then
           begin
           begin
             sec:=sec_user;
             sec:=sec_user;
@@ -1114,7 +1114,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
           begin
           begin
             { see same code in ncgutil.insertbssdata }
             { see same code in ncgutil.insertbssdata }
             reslist.insert(tai_directive.Create(asd_reference,fsym.name));
             reslist.insert(tai_directive.Create(asd_reference,fsym.name));
-            reslist.insert(tai_symbol.Create(current_asmdata.DefineAsmSymbol(fsym.name,AB_LOCAL,AT_DATA),0));
+            reslist.insert(tai_symbol.Create(current_asmdata.DefineAsmSymbol(fsym.name,AB_LOCAL,AT_DATA,tcsym.vardef),0));
           end;
           end;
         datalist:=fdatalist;
         datalist:=fdatalist;
       end;
       end;

+ 69 - 60
compiler/objcgutl.pas

@@ -300,6 +300,7 @@ procedure tobjcrttiwriter.gen_objc_methods(list: tasmlist; objccls: tobjectdef;
     mcnt  : integer;
     mcnt  : integer;
     mtype : tdef;
     mtype : tdef;
     tcb   : ttai_typedconstbuilder;
     tcb   : ttai_typedconstbuilder;
+    mdef  : tdef;
   begin
   begin
     methodslabel:=nil;
     methodslabel:=nil;
     mcnt:=0;
     mcnt:=0;
@@ -320,15 +321,6 @@ procedure tobjcrttiwriter.gen_objc_methods(list: tasmlist; objccls: tobjectdef;
     if mcnt=0 then
     if mcnt=0 then
       exit;
       exit;
 
 
-    if iscategory then
-      begin
-        methodslabel:=current_asmdata.DefineAsmSymbol('l_OBJC_$_CATEGORY_'+instclsName[classmethods]+'_METHODS_'+objccls.objextname^+'_$_'+objccls.childof.objextname^,AB_LOCAL,AT_DATA);
-      end
-    else
-      begin
-        methodslabel:=current_asmdata.DefineAsmSymbol('l_OBJC_$_'+instclsName[classmethods]+'_METHODS_'+objccls.objextname^,AB_LOCAL,AT_DATA);
-      end;
-
     tcb:=ctai_typedconstbuilder.create([tcalo_new_section]);
     tcb:=ctai_typedconstbuilder.create([tcalo_new_section]);
     tcb.begin_anonymous_record(internaltypeprefixName[itp_objc_method_list]+tostr(mcnt),
     tcb.begin_anonymous_record(internaltypeprefixName[itp_objc_method_list]+tostr(mcnt),
       C_alignment,1,
       C_alignment,1,
@@ -358,8 +350,18 @@ procedure tobjcrttiwriter.gen_objc_methods(list: tasmlist; objccls: tobjectdef;
         tcb.queue_init(voidcodepointertype);
         tcb.queue_init(voidcodepointertype);
         tcb.queue_emit_proc(defs[i].def);
         tcb.queue_emit_proc(defs[i].def);
       end;
       end;
+
+    mdef:=tcb.end_anonymous_record;
+    if iscategory then
+      begin
+        methodslabel:=current_asmdata.DefineAsmSymbol('l_OBJC_$_CATEGORY_'+instclsName[classmethods]+'_METHODS_'+objccls.objextname^+'_$_'+objccls.childof.objextname^,AB_LOCAL,AT_DATA,mdef);
+      end
+    else
+      begin
+        methodslabel:=current_asmdata.DefineAsmSymbol('l_OBJC_$_'+instclsName[classmethods]+'_METHODS_'+objccls.objextname^,AB_LOCAL,AT_DATA,mdef);
+      end;
     list.concatList(
     list.concatList(
-      tcb.get_final_asmlist(methodslabel,tcb.end_anonymous_record,
+      tcb.get_final_asmlist(methodslabel,mdef,
         SectType[iscategory,classmethods],
         SectType[iscategory,classmethods],
         SectName[iscategory,classmethods],sizeof(ptrint)
         SectName[iscategory,classmethods],sizeof(ptrint)
       )
       )
@@ -815,7 +817,6 @@ procedure tobjcrttiwriter_fragile.gen_objc_category_sections(list:TAsmList; objc
     gen_objc_protocol_list(list,objccat.ImplementedInterfaces,protolistsym);
     gen_objc_protocol_list(list,objccat.ImplementedInterfaces,protolistsym);
 
 
     { category declaration section }
     { category declaration section }
-    catsym:=current_asmdata.DefineAsmSymbol(objccat.rtti_mangledname(objcclassrtti),AB_LOCAL,AT_DATA);
     tcb:=ctai_typedconstbuilder.create([tcalo_new_section]);
     tcb:=ctai_typedconstbuilder.create([tcalo_new_section]);
     tcb.begin_anonymous_record(
     tcb.begin_anonymous_record(
       internaltypeprefixName[itb_objc_fr_category],
       internaltypeprefixName[itb_objc_fr_category],
@@ -835,6 +836,7 @@ procedure tobjcrttiwriter_fragile.gen_objc_category_sections(list:TAsmList; objc
     { properties, not yet supported }
     { properties, not yet supported }
     tcb.emit_ord_const(0,u32inttype);
     tcb.emit_ord_const(0,u32inttype);
     catdef:=tcb.end_anonymous_record;
     catdef:=tcb.end_anonymous_record;
+    catsym:=current_asmdata.DefineAsmSymbol(objccat.rtti_mangledname(objcclassrtti),AB_LOCAL,AT_DATA,catdef);
     list.concatList(
     list.concatList(
       tcb.get_final_asmlist(
       tcb.get_final_asmlist(
         catsym,catdef,
         catsym,catdef,
@@ -933,7 +935,6 @@ procedure tobjcrttiwriter_fragile.gen_objc_classes_sections(list:TAsmList; objcl
     { class declaration section }
     { class declaration section }
 
 
     { 1) meta-class declaration  }
     { 1) meta-class declaration  }
-    metasym:=current_asmdata.DefineAsmSymbol(objclss.rtti_mangledname(objcmetartti),AB_LOCAL,AT_DATA);
     tcb:=ctai_typedconstbuilder.create([tcalo_new_section]);
     tcb:=ctai_typedconstbuilder.create([tcalo_new_section]);
     tcb.begin_anonymous_record(internaltypeprefixName[itb_objc_fr_meta_class],
     tcb.begin_anonymous_record(internaltypeprefixName[itb_objc_fr_meta_class],
       C_alignment,1,
       C_alignment,1,
@@ -973,6 +974,7 @@ procedure tobjcrttiwriter_fragile.gen_objc_classes_sections(list:TAsmList; objcl
     { From Clang: The class extension is always unused for meta-classes. }
     { From Clang: The class extension is always unused for meta-classes. }
     tcb.emit_ord_const(0,u32inttype);
     tcb.emit_ord_const(0,u32inttype);
     metaDef:=tcb.end_anonymous_record;
     metaDef:=tcb.end_anonymous_record;
+    metasym:=current_asmdata.DefineAsmSymbol(objclss.rtti_mangledname(objcmetartti),AB_LOCAL,AT_DATA,metadef);
     list.concatList(
     list.concatList(
       tcb.get_final_asmlist(
       tcb.get_final_asmlist(
         metasym,metaDef,
         metasym,metaDef,
@@ -989,8 +991,6 @@ procedure tobjcrttiwriter_fragile.gen_objc_classes_sections(list:TAsmList; objcl
     { generate the instance variables list }
     { generate the instance variables list }
     gen_objc_ivars(list,objclss,ivarslist);
     gen_objc_ivars(list,objclss,ivarslist);
 
 
-    clssym:=current_asmdata.DefineAsmSymbol(objclss.rtti_mangledname(objcclassrtti),AB_LOCAL,AT_DATA);
-
     tcb:=ctai_typedconstbuilder.create([tcalo_new_section]);
     tcb:=ctai_typedconstbuilder.create([tcalo_new_section]);
     tcb.begin_anonymous_record(internaltypeprefixName[itb_objc_fr_class],
     tcb.begin_anonymous_record(internaltypeprefixName[itb_objc_fr_class],
       C_alignment,1,
       C_alignment,1,
@@ -1028,7 +1028,9 @@ procedure tobjcrttiwriter_fragile.gen_objc_classes_sections(list:TAsmList; objcl
     tcb.emit_tai(tai_const.Create_nil_dataptr,voidpointertype);
     tcb.emit_tai(tai_const.Create_nil_dataptr,voidpointertype);
     { TODO: From Clang: weak ivar_layout, necessary for garbage collection support }
     { TODO: From Clang: weak ivar_layout, necessary for garbage collection support }
     tcb.emit_tai(tai_const.Create_nil_dataptr,voidpointertype);
     tcb.emit_tai(tai_const.Create_nil_dataptr,voidpointertype);
+
     clsDef:=tcb.end_anonymous_record;
     clsDef:=tcb.end_anonymous_record;
+    clssym:=current_asmdata.DefineAsmSymbol(objclss.rtti_mangledname(objcclassrtti),AB_LOCAL,AT_DATA,clsDef);
     list.concatList(
     list.concatList(
       tcb.get_final_asmlist(
       tcb.get_final_asmlist(
         clssym,clsDef,
         clssym,clsDef,
@@ -1059,8 +1061,6 @@ procedure tobjcrttiwriter_fragile.gen_objc_info_sections(list: tasmlist);
        (catsyms.count<>0) then
        (catsyms.count<>0) then
       begin
       begin
         tcb:=ctai_typedconstbuilder.create([tcalo_new_section]);
         tcb:=ctai_typedconstbuilder.create([tcalo_new_section]);
-        sym := current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'_OBJC_SYMBOLS_$',AB_LOCAL,AT_DATA);
-
         tcb.begin_anonymous_record('',
         tcb.begin_anonymous_record('',
           C_alignment,1,
           C_alignment,1,
           targetinfos[target_info.system]^.alignment.recordalignmin,
           targetinfos[target_info.system]^.alignment.recordalignmin,
@@ -1080,6 +1080,7 @@ procedure tobjcrttiwriter_fragile.gen_objc_info_sections(list: tasmlist);
         for i:=0 to catsyms.count-1 do
         for i:=0 to catsyms.count-1 do
           tcb.emit_tai(Tai_const.Create_sym(tasmsymbol(catsyms[i])),tdef(catrttidefs[i]));
           tcb.emit_tai(Tai_const.Create_sym(tasmsymbol(catsyms[i])),tdef(catrttidefs[i]));
         symsdef:=tcb.end_anonymous_record;
         symsdef:=tcb.end_anonymous_record;
+        sym := current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'_OBJC_SYMBOLS_$',AB_LOCAL,AT_DATA,symsdef);
         list.concatList(tcb.get_final_asmlist(sym,
         list.concatList(tcb.get_final_asmlist(sym,
           symsdef,
           symsdef,
           sec_objc_symbols,'_OBJC_SYMBOLS',
           sec_objc_symbols,'_OBJC_SYMBOLS',
@@ -1113,6 +1114,7 @@ procedure tobjcrttiwriter_fragile.gen_objc_info_sections(list: tasmlist);
     list.concatList(tcb.get_final_asmlist(lab,
     list.concatList(tcb.get_final_asmlist(lab,
       tcb.end_anonymous_record,sec_objc_module_info,'_OBJC_MODULE_INFO',4));
       tcb.end_anonymous_record,sec_objc_module_info,'_OBJC_MODULE_INFO',4));
 
 
+
     { Add lazy references to parent classes of all classes defined in this unit }
     { Add lazy references to parent classes of all classes defined in this unit }
     superclasses:=tfpobjectlist.create(false);
     superclasses:=tfpobjectlist.create(false);
     for i:=0 to classdefs.count-1 do
     for i:=0 to classdefs.count-1 do
@@ -1140,11 +1142,11 @@ procedure tobjcrttiwriter_fragile.gen_objc_info_sections(list: tasmlist);
     superclasses.free;
     superclasses.free;
     { reference symbols for all classes and categories defined in this unit }
     { reference symbols for all classes and categories defined in this unit }
     for i:=0 to classdefs.count-1 do
     for i:=0 to classdefs.count-1 do
-      list.concat(tai_symbol.Createname_global_value('.objc_class_name_'+tobjectdef(classdefs[i]).objextname^,AT_DATA,0,0));
+      list.concat(tai_symbol.Createname_global_value('.objc_class_name_'+tobjectdef(classdefs[i]).objextname^,AT_DATA,0,0,voidpointertype));
     for i:=0 to catdefs.count-1 do
     for i:=0 to catdefs.count-1 do
       list.concat(tai_symbol.Createname_global_value('.objc_category_name_'+
       list.concat(tai_symbol.Createname_global_value('.objc_category_name_'+
         tobjectdef(catdefs[i]).childof.objextname^+'_'+
         tobjectdef(catdefs[i]).childof.objextname^+'_'+
-        tobjectdef(catdefs[i]).objextname^,AT_DATA,0,0));
+        tobjectdef(catdefs[i]).objextname^,AT_DATA,0,0,voidpointertype));
   end;
   end;
 
 
 
 
@@ -1233,7 +1235,7 @@ procedure tobjcrttiwriter_nonfragile.gen_objc_ivars(list: tasmlist; objccls: tob
                 vis:=AB_PRIVATE_EXTERN
                 vis:=AB_PRIVATE_EXTERN
               else
               else
                 vis:=AB_GLOBAL;
                 vis:=AB_GLOBAL;
-              vars[vcnt].offssym:=current_asmdata.DefineAsmSymbol(prefix+vf.RealName,vis,AT_DATA);
+              vars[vcnt].offssym:=current_asmdata.DefineAsmSymbol(prefix+vf.RealName,vis,AT_DATA,ptruinttype);
               tcb.emit_tai(tai_const.create_pint(vf.fieldoffset),ptruinttype);
               tcb.emit_tai(tai_const.create_pint(vf.fieldoffset),ptruinttype);
               list.concatList(
               list.concatList(
                 tcb.get_final_asmlist(
                 tcb.get_final_asmlist(
@@ -1336,10 +1338,10 @@ procedure tobjcrttiwriter_nonfragile.gen_objc_protocol(list: tasmlist; protocol:
         b) private_extern (should only be merged within the same module)
         b) private_extern (should only be merged within the same module)
         c) weakly defined (so multiple definitions don't cause errors)
         c) weakly defined (so multiple definitions don't cause errors)
     }
     }
-    lbl:=current_asmdata.DefineAsmSymbol(protocol.rtti_mangledname(objcclassrtti),AB_PRIVATE_EXTERN,AT_DATA);
+    prottype:=search_named_unit_globaltype('OBJC','OBJC_PROTOCOL',true).typedef;
+    lbl:=current_asmdata.DefineAsmSymbol(protocol.rtti_mangledname(objcclassrtti),AB_PRIVATE_EXTERN,AT_DATA,prottype);
     protocollabel:=lbl;
     protocollabel:=lbl;
 
 
-    prottype:=search_named_unit_globaltype('OBJC','OBJC_PROTOCOL',true).typedef;
     tcb:=ctai_typedconstbuilder.create([tcalo_new_section,tcalo_weak]);
     tcb:=ctai_typedconstbuilder.create([tcalo_new_section,tcalo_weak]);
     tcb.maybe_begin_aggregate(prottype);
     tcb.maybe_begin_aggregate(prottype);
     { protocol's isa - always nil }
     { protocol's isa - always nil }
@@ -1375,7 +1377,7 @@ procedure tobjcrttiwriter_nonfragile.gen_objc_protocol(list: tasmlist; protocol:
 
 
     { also add an entry to the __DATA, __objc_protolist section, required to
     { also add an entry to the __DATA, __objc_protolist section, required to
       register the protocol with the runtime }
       register the protocol with the runtime }
-    listsym:=current_asmdata.DefineAsmSymbol(protocol.rtti_mangledname(objcmetartti),AB_PRIVATE_EXTERN,AT_DATA);
+    listsym:=current_asmdata.DefineAsmSymbol(protocol.rtti_mangledname(objcmetartti),AB_PRIVATE_EXTERN,AT_DATA,cpointerdef.getreusable(prottype));
     tcb:=ctai_typedconstbuilder.create([tcalo_new_section,tcalo_weak]);
     tcb:=ctai_typedconstbuilder.create([tcalo_new_section,tcalo_weak]);
     tcb.emit_tai(tai_const.Create_sym(lbl),cpointerdef.getreusable(prottype));
     tcb.emit_tai(tai_const.Create_sym(lbl),cpointerdef.getreusable(prottype));
     list.concatList(
     list.concatList(
@@ -1424,7 +1426,6 @@ procedure tobjcrttiwriter_nonfragile.gen_objc_category_sections(list:TAsmList; o
     gen_objc_protocol_list(list,objccat.ImplementedInterfaces,protolistsym);
     gen_objc_protocol_list(list,objccat.ImplementedInterfaces,protolistsym);
 
 
     { category declaration section }
     { category declaration section }
-    catsym:=current_asmdata.DefineAsmSymbol(objccat.rtti_mangledname(objcclassrtti),AB_LOCAL,AT_DATA);
     tcb:=ctai_typedconstbuilder.create([tcalo_new_section]);
     tcb:=ctai_typedconstbuilder.create([tcalo_new_section]);
     tcb.begin_anonymous_record(internaltypeprefixName[itb_objc_nf_category],
     tcb.begin_anonymous_record(internaltypeprefixName[itb_objc_nf_category],
       C_alignment,1,
       C_alignment,1,
@@ -1439,6 +1440,7 @@ procedure tobjcrttiwriter_nonfragile.gen_objc_category_sections(list:TAsmList; o
     { properties, not yet supported }
     { properties, not yet supported }
     tcb.emit_tai(Tai_const.Create_nil_dataptr,voidpointertype);
     tcb.emit_tai(Tai_const.Create_nil_dataptr,voidpointertype);
     catdef:=tcb.end_anonymous_record;
     catdef:=tcb.end_anonymous_record;
+    catsym:=current_asmdata.DefineAsmSymbol(objccat.rtti_mangledname(objcclassrtti),AB_LOCAL,AT_DATA,catdef);
     list.concatList(
     list.concatList(
       tcb.get_final_asmlist(
       tcb.get_final_asmlist(
         catsym,catdef,
         catsym,catdef,
@@ -1570,6 +1572,7 @@ procedure tobjcrttiwriter_nonfragile.gen_objc_class_ro_part(list: tasmlist; objc
     classStrDef  : tdef;
     classStrDef  : tdef;
     classStrSym,
     classStrSym,
     ivarslab     : TAsmLabel;
     ivarslab     : TAsmLabel;
+    rodef,
     class_type   : tdef;
     class_type   : tdef;
     start,
     start,
     size,
     size,
@@ -1635,8 +1638,6 @@ procedure tobjcrttiwriter_nonfragile.gen_objc_class_ro_part(list: tasmlist; objc
       targetinfos[target_info.system]^.alignment.recordalignmin,
       targetinfos[target_info.system]^.alignment.recordalignmin,
       targetinfos[target_info.system]^.alignment.maxCrecordalign);
       targetinfos[target_info.system]^.alignment.maxCrecordalign);
 
 
-    rosym:=current_asmdata.DefineAsmSymbol(objclss.rtti_mangledname(rttitype),AB_LOCAL,AT_DATA);
-    classrolabel:=rosym;
     tcb.emit_ord_const(flags,u32inttype);
     tcb.emit_ord_const(flags,u32inttype);
     tcb.emit_ord_const(start,u32inttype);
     tcb.emit_ord_const(start,u32inttype);
     tcb.emit_ord_const(size,u32inttype);
     tcb.emit_ord_const(size,u32inttype);
@@ -1651,13 +1652,16 @@ procedure tobjcrttiwriter_nonfragile.gen_objc_class_ro_part(list: tasmlist; objc
     tcb.emit_tai(tai_const.Create_nil_dataptr,voidpointertype);
     tcb.emit_tai(tai_const.Create_nil_dataptr,voidpointertype);
     { TODO: properties }
     { TODO: properties }
     tcb.emit_tai(tai_const.Create_nil_dataptr,voidpointertype);
     tcb.emit_tai(tai_const.Create_nil_dataptr,voidpointertype);
+    rodef:=tcb.end_anonymous_record;
+    rosym:=current_asmdata.DefineAsmSymbol(objclss.rtti_mangledname(rttitype),AB_LOCAL,AT_DATA,rodef);
     list.concatList(
     list.concatList(
       tcb.get_final_asmlist(
       tcb.get_final_asmlist(
-        rosym,tcb.end_anonymous_record,
+        rosym,rodef,
         sec_objc_const,'_OBJC_META_CLASS',sizeof(pint)
         sec_objc_const,'_OBJC_META_CLASS',sizeof(pint)
       )
       )
     );
     );
     tcb.free;
     tcb.free;
+    classrolabel:=rosym;
   end;
   end;
 
 
 
 
@@ -1687,7 +1691,8 @@ procedure tobjcrttiwriter_nonfragile.gen_objc_classes_sections(list:TAsmList; ob
     rosym         : TAsmSymbol;
     rosym         : TAsmSymbol;
     protolistsym  : TAsmLabel;
     protolistsym  : TAsmLabel;
     vis           : TAsmsymbind;
     vis           : TAsmsymbind;
-    tcb           : ttai_typedconstbuilder;
+    isatcb,
+    metatcb       : ttai_typedconstbuilder;
     metadef,
     metadef,
     classdef      : tdef;
     classdef      : tdef;
   begin
   begin
@@ -1698,8 +1703,25 @@ procedure tobjcrttiwriter_nonfragile.gen_objc_classes_sections(list:TAsmList; ob
       vis:=AB_GLOBAL
       vis:=AB_GLOBAL
     else
     else
       vis:=AB_PRIVATE_EXTERN;
       vis:=AB_PRIVATE_EXTERN;
-    clssym:=current_asmdata.DefineAsmSymbol(objclss.rtti_mangledname(objcclassrtti),vis,AT_DATA);
-    metasym:=current_asmdata.DefineAsmSymbol(objclss.rtti_mangledname(objcmetartti),vis,AT_DATA);
+
+    { create the typed const builders so we can get the (provisional) types
+      for the class and metaclass symbols }
+    isatcb:=ctai_typedconstbuilder.create([]);
+    classdef:=isatcb.begin_anonymous_record(
+      internaltypeprefixName[itb_objc_nf_class],
+      C_alignment,1,
+      targetinfos[target_info.system]^.alignment.recordalignmin,
+      targetinfos[target_info.system]^.alignment.maxCrecordalign);
+
+    metatcb:=ctai_typedconstbuilder.create([tcalo_new_section]);
+    metadef:=metatcb.begin_anonymous_record(
+      internaltypeprefixName[itb_objc_nf_meta_class],
+      C_alignment,1,
+      targetinfos[target_info.system]^.alignment.recordalignmin,
+      targetinfos[target_info.system]^.alignment.maxCrecordalign);
+
+    clssym:=current_asmdata.DefineAsmSymbol(objclss.rtti_mangledname(objcclassrtti),vis,AT_DATA,classdef);
+    metasym:=current_asmdata.DefineAsmSymbol(objclss.rtti_mangledname(objcmetartti),vis,AT_DATA,metadef);
     { 2) the superclass and meta superclass }
     { 2) the superclass and meta superclass }
     if assigned(objclss.childof) then
     if assigned(objclss.childof) then
       begin
       begin
@@ -1730,64 +1752,51 @@ procedure tobjcrttiwriter_nonfragile.gen_objc_classes_sections(list:TAsmList; ob
     { B) Class declaration section }
     { B) Class declaration section }
     { both class and metaclass are in the objc_data section for obj-c 2 }
     { both class and metaclass are in the objc_data section for obj-c 2 }
 
 
-    tcb:=ctai_typedconstbuilder.create([tcalo_new_section]);
-    tcb.begin_anonymous_record(
-      internaltypeprefixName[itb_objc_nf_meta_class],
-      C_alignment,1,
-      targetinfos[target_info.system]^.alignment.recordalignmin,
-      targetinfos[target_info.system]^.alignment.maxCrecordalign);
     { 1) meta-class declaration }
     { 1) meta-class declaration }
 
 
     { the isa }
     { the isa }
-    tcb.emit_tai(Tai_const.Create_sym(metaisaSym),voidpointertype);
+    metatcb.emit_tai(Tai_const.Create_sym(metaisaSym),voidpointertype);
     { the superclass }
     { the superclass }
-    tcb.emit_tai(Tai_const.Create_sym(superMetaSym),voidpointertype);
+    metatcb.emit_tai(Tai_const.Create_sym(superMetaSym),voidpointertype);
     { pointer to cache }
     { pointer to cache }
     if not assigned(ObjCEmptyCacheVar) then
     if not assigned(ObjCEmptyCacheVar) then
       ObjCEmptyCacheVar:=current_asmdata.RefAsmSymbol(target_info.Cprefix+'_objc_empty_cache');
       ObjCEmptyCacheVar:=current_asmdata.RefAsmSymbol(target_info.Cprefix+'_objc_empty_cache');
-    tcb.emit_tai(Tai_const.Create_sym(ObjCEmptyCacheVar),voidpointertype);
+    metatcb.emit_tai(Tai_const.Create_sym(ObjCEmptyCacheVar),voidpointertype);
     { pointer to vtable }
     { pointer to vtable }
     if not assigned(ObjCEmptyVtableVar) and
     if not assigned(ObjCEmptyVtableVar) and
        not(target_info.system in [system_arm_darwin,system_aarch64_darwin,system_i386_iphonesim,system_x86_64_iphonesim]) then
        not(target_info.system in [system_arm_darwin,system_aarch64_darwin,system_i386_iphonesim,system_x86_64_iphonesim]) then
       ObjCEmptyVtableVar:=current_asmdata.RefAsmSymbol(target_info.Cprefix+'_objc_empty_vtable');
       ObjCEmptyVtableVar:=current_asmdata.RefAsmSymbol(target_info.Cprefix+'_objc_empty_vtable');
-    ConcatSymOrNil(tcb,ObjCEmptyVtableVar,voidpointertype);
+    ConcatSymOrNil(metatcb,ObjCEmptyVtableVar,voidpointertype);
     { the read-only part }
     { the read-only part }
-    tcb.emit_tai(Tai_const.Create_sym(metarosym),voidpointertype);
-    metadef:=tcb.end_anonymous_record;
+    metatcb.emit_tai(Tai_const.Create_sym(metarosym),voidpointertype);
+    metatcb.end_anonymous_record;
     list.concatList(
     list.concatList(
-      tcb.get_final_asmlist(
+      metatcb.get_final_asmlist(
         metasym,metadef,
         metasym,metadef,
         sec_objc_data,'_OBJC_CLASS',sizeof(pint)
         sec_objc_data,'_OBJC_CLASS',sizeof(pint)
       )
       )
     );
     );
-    tcb.free;
+    metatcb.free;
 
 
     { 2) regular class declaration }
     { 2) regular class declaration }
-    tcb:=ctai_typedconstbuilder.create([]);
-    tcb.begin_anonymous_record(
-      internaltypeprefixName[itb_objc_nf_class],
-      C_alignment,1,
-      targetinfos[target_info.system]^.alignment.recordalignmin,
-      targetinfos[target_info.system]^.alignment.maxCrecordalign);
-
     { the isa }
     { the isa }
-    tcb.emit_tai(Tai_const.Create_sym(metasym),cpointerdef.getreusable(metadef));
+    isatcb.emit_tai(Tai_const.Create_sym(metasym),cpointerdef.getreusable(metadef));
     { the superclass }
     { the superclass }
-    ConcatSymOrNil(tcb,supersym,voidpointertype);
+    ConcatSymOrNil(isatcb,supersym,voidpointertype);
     { pointer to cache }
     { pointer to cache }
-    tcb.emit_tai(Tai_const.Create_sym(ObjCEmptyCacheVar),voidpointertype);
+    isatcb.emit_tai(Tai_const.Create_sym(ObjCEmptyCacheVar),voidpointertype);
     { pointer to vtable }
     { pointer to vtable }
-    ConcatSymOrNil(tcb,ObjCEmptyVtableVar,voidpointertype);
+    ConcatSymOrNil(isatcb,ObjCEmptyVtableVar,voidpointertype);
     { the read-only part }
     { the read-only part }
-    tcb.emit_tai(Tai_const.Create_sym(rosym),voidpointertype);
-    classdef:=tcb.end_anonymous_record;
+    isatcb.emit_tai(Tai_const.Create_sym(rosym),voidpointertype);
+    isatcb.end_anonymous_record;
     list.concatList(
     list.concatList(
-      tcb.get_final_asmlist(
+      isatcb.get_final_asmlist(
         clssym,classdef,
         clssym,classdef,
         sec_objc_data,'_OBJC_CLASS',sizeof(pint)
         sec_objc_data,'_OBJC_CLASS',sizeof(pint)
       )
       )
     );
     );
-    tcb.free;
+    isatcb.free;
 
 
     classlabel:=clssym;
     classlabel:=clssym;
     classlabeldef:=classdef;;
     classlabeldef:=classdef;;
@@ -1803,9 +1812,9 @@ procedure tobjcrttiwriter_nonfragile.addclasslist(list: tasmlist; section: tasms
   begin
   begin
     if classes.count=0 then
     if classes.count=0 then
       exit;
       exit;
-    sym:=current_asmdata.DefineAsmSymbol(symname,AB_LOCAL,AT_DATA);
     tcb:=ctai_typedconstbuilder.create([tcalo_new_section]);
     tcb:=ctai_typedconstbuilder.create([tcalo_new_section]);
     arrdef:=carraydef.getreusable(voidpointertype,classes.count);
     arrdef:=carraydef.getreusable(voidpointertype,classes.count);
+    sym:=current_asmdata.DefineAsmSymbol(symname,AB_LOCAL,AT_DATA,arrdef);
     tcb.maybe_begin_aggregate(arrdef);
     tcb.maybe_begin_aggregate(arrdef);
     for i:=0 to classes.count-1 do
     for i:=0 to classes.count-1 do
       tcb.emit_tai(
       tcb.emit_tai(
@@ -1906,7 +1915,7 @@ procedure MaybeGenerateObjectiveCImageInfo(globalst, localst: tsymtable);
         tcb.emit_ord_const(0,u64inttype);
         tcb.emit_ord_const(0,u64inttype);
         current_asmdata.asmlists[al_objc_data].concatList(
         current_asmdata.asmlists[al_objc_data].concatList(
           tcb.get_final_asmlist(
           tcb.get_final_asmlist(
-            current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'_OBJC_IMAGE_INFO',AB_LOCAL,AT_DATA),
+            current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'_OBJC_IMAGE_INFO',AB_LOCAL,AT_DATA,u64inttype),
             u64inttype,sec_objc_image_info,'_OBJC_IMAGE_INFO',sizeof(pint)
             u64inttype,sec_objc_image_info,'_OBJC_IMAGE_INFO',sizeof(pint)
           )
           )
         );
         );

+ 2 - 2
compiler/pmodules.pas

@@ -1618,11 +1618,11 @@ type
          if target_info.system in systems_windows then
          if target_info.system in systems_windows then
            begin
            begin
              new_section(current_asmdata.asmlists[al_globals],sec_data,'_FPCDummy',4);
              new_section(current_asmdata.asmlists[al_globals],sec_data,'_FPCDummy',4);
-             current_asmdata.asmlists[al_globals].concat(tai_symbol.createname_global('_FPCDummy',AT_DATA,0));
+             current_asmdata.asmlists[al_globals].concat(tai_symbol.createname_global('_FPCDummy',AT_DATA,0,u32inttype));
              current_asmdata.asmlists[al_globals].concat(tai_const.create_32bit(0));
              current_asmdata.asmlists[al_globals].concat(tai_const.create_32bit(0));
 
 
              new_section(current_asmdata.asmlists[al_procedures],sec_code,'',0);
              new_section(current_asmdata.asmlists[al_procedures],sec_code,'',0);
-             current_asmdata.asmlists[al_procedures].concat(tai_symbol.createname_global('_DLLMainCRTStartup',AT_FUNCTION,0));
+             current_asmdata.asmlists[al_procedures].concat(tai_symbol.createname_global('_DLLMainCRTStartup',AT_FUNCTION,0,voidcodepointertype));
              gen_fpc_dummy(current_asmdata.asmlists[al_procedures]);
              gen_fpc_dummy(current_asmdata.asmlists[al_procedures]);
              current_asmdata.asmlists[al_procedures].concat(tai_const.createname('_FPCDummy',0));
              current_asmdata.asmlists[al_procedures].concat(tai_const.createname('_FPCDummy',0));
            end;
            end;

+ 4 - 4
compiler/powerpc/rappcgas.pas

@@ -52,7 +52,7 @@ Unit rappcgas;
       { aasm }
       { aasm }
       cpubase,aasmbase,aasmtai,aasmdata,aasmcpu,
       cpubase,aasmbase,aasmtai,aasmdata,aasmcpu,
       { symtable }
       { symtable }
-      symconst,symsym,
+      symconst,symsym,symdef,
       { parser }
       { parser }
       procinfo,
       procinfo,
       rabase,rautils,
       rabase,rautils,
@@ -350,7 +350,7 @@ Unit rappcgas;
                     if (oper.opr.val<>0) then
                     if (oper.opr.val<>0) then
                       Message(asmr_e_wrong_sym_type);
                       Message(asmr_e_wrong_sym_type);
                     oper.opr.typ:=OPR_SYMBOL;
                     oper.opr.typ:=OPR_SYMBOL;
-                    oper.opr.symbol:=current_asmdata.DefineAsmSymbol(mangledname,AB_EXTERNAL,AT_FUNCTION);
+                    oper.opr.symbol:=current_asmdata.DefineAsmSymbol(mangledname,AB_EXTERNAL,AT_FUNCTION,voidcodepointertype);
                   end
                   end
                 else
                 else
                   inc(oper.opr.val,l);
                   inc(oper.opr.val,l);
@@ -765,13 +765,13 @@ Unit rappcgas;
               Message(asmr_e_syn_operand);
               Message(asmr_e_syn_operand);
             if use_dotted_functions and
             if use_dotted_functions and
                assigned(instr.Operands[1].opr.ref.symbol) then
                assigned(instr.Operands[1].opr.ref.symbol) then
-              instr.Operands[1].opr.ref.symbol:=current_asmdata.DefineAsmSymbol('.'+instr.Operands[1].opr.ref.symbol.name,instr.Operands[1].opr.ref.symbol.bind,AT_FUNCTION);
+              instr.Operands[1].opr.ref.symbol:=current_asmdata.DefineAsmSymbol('.'+instr.Operands[1].opr.ref.symbol.name,instr.Operands[1].opr.ref.symbol.bind,AT_FUNCTION,voidcodepointertype);
           end;
           end;
         { regular name is toc entry, .-based name is actual code }
         { regular name is toc entry, .-based name is actual code }
         if use_dotted_functions and
         if use_dotted_functions and
            (instr.Operands[1].opr.typ = OPR_SYMBOL) and
            (instr.Operands[1].opr.typ = OPR_SYMBOL) and
            (instr.Operands[1].opr.symbol.typ=AT_FUNCTION) then
            (instr.Operands[1].opr.symbol.typ=AT_FUNCTION) then
-          instr.Operands[1].opr.symbol:=current_asmdata.DefineAsmSymbol('.'+instr.Operands[1].opr.symbol.name,instr.Operands[1].opr.symbol.bind,AT_FUNCTION);
+          instr.Operands[1].opr.symbol:=current_asmdata.DefineAsmSymbol('.'+instr.Operands[1].opr.symbol.name,instr.Operands[1].opr.symbol.bind,AT_FUNCTION,voidcodepointertype);
       end;
       end;
 
 
 
 

+ 1 - 1
compiler/powerpc64/cgcpu.pas

@@ -1858,7 +1858,7 @@ begin
   symname := '_$' + current_asmdata.name^ + '$toc$' + hexstr(a, sizeof(a)*2);
   symname := '_$' + current_asmdata.name^ + '$toc$' + hexstr(a, sizeof(a)*2);
   l:=current_asmdata.getasmsymbol(symname);
   l:=current_asmdata.getasmsymbol(symname);
   if not(assigned(l)) then begin
   if not(assigned(l)) then begin
-    l:=current_asmdata.DefineAsmSymbol(symname,AB_GLOBAL, AT_DATA);
+    l:=current_asmdata.DefineAsmSymbol(symname,AB_GLOBAL, AT_METADATA, voidpointertype);
     new_section(current_asmdata.asmlists[al_picdata],sec_toc, '.toc', 8);
     new_section(current_asmdata.asmlists[al_picdata],sec_toc, '.toc', 8);
     current_asmdata.asmlists[al_picdata].concat(tai_symbol.create_global(l,0));
     current_asmdata.asmlists[al_picdata].concat(tai_symbol.create_global(l,0));
     current_asmdata.asmlists[al_picdata].concat(tai_directive.create(asd_toc_entry, symname + '[TC], ' + inttostr(a)));
     current_asmdata.asmlists[al_picdata].concat(tai_directive.create(asd_toc_entry, symname + '[TC], ' + inttostr(a)));

+ 4 - 4
compiler/powerpc64/rappcgas.pas

@@ -54,7 +54,7 @@ uses
   { aasm }
   { aasm }
   cpubase, aasmbase, aasmtai,aasmdata, aasmcpu,
   cpubase, aasmbase, aasmtai,aasmdata, aasmcpu,
   { symtable }
   { symtable }
-  symconst, symsym,
+  symconst, symsym, symdef,
   { parser }
   { parser }
   procinfo,
   procinfo,
   rabase, rautils,
   rabase, rautils,
@@ -361,7 +361,7 @@ var
             if (oper.opr.val<>0) then
             if (oper.opr.val<>0) then
               Message(asmr_e_wrong_sym_type);
               Message(asmr_e_wrong_sym_type);
             oper.opr.typ:=OPR_SYMBOL;
             oper.opr.typ:=OPR_SYMBOL;
-            oper.opr.symbol:=current_asmdata.DefineAsmSymbol(mangledname,AB_EXTERNAL,AT_FUNCTION);
+            oper.opr.symbol:=current_asmdata.DefineAsmSymbol(mangledname,AB_EXTERNAL,AT_FUNCTION,voidcodepointertype);
           end
           end
         else
         else
           inc(oper.opr.val,l);
           inc(oper.opr.val,l);
@@ -767,12 +767,12 @@ begin
       Message(asmr_e_syn_operand);
       Message(asmr_e_syn_operand);
     if use_dotted_functions and
     if use_dotted_functions and
        assigned(instr.Operands[1].opr.ref.symbol) then
        assigned(instr.Operands[1].opr.ref.symbol) then
-      instr.Operands[1].opr.ref.symbol:=current_asmdata.DefineAsmSymbol('.'+instr.Operands[1].opr.ref.symbol.name,instr.Operands[1].opr.ref.symbol.bind,AT_FUNCTION);
+      instr.Operands[1].opr.ref.symbol:=current_asmdata.DefineAsmSymbol('.'+instr.Operands[1].opr.ref.symbol.name,instr.Operands[1].opr.ref.symbol.bind,AT_FUNCTION,voidcodepointertype);
   end;
   end;
   if use_dotted_functions and
   if use_dotted_functions and
      (instr.Operands[1].opr.typ = OPR_SYMBOL) and
      (instr.Operands[1].opr.typ = OPR_SYMBOL) and
      (instr.Operands[1].opr.symbol.typ=AT_FUNCTION) then
      (instr.Operands[1].opr.symbol.typ=AT_FUNCTION) then
-    instr.Operands[1].opr.symbol:=current_asmdata.DefineAsmSymbol('.'+instr.Operands[1].opr.symbol.name,instr.Operands[1].opr.symbol.bind,AT_FUNCTION);
+    instr.Operands[1].opr.symbol:=current_asmdata.DefineAsmSymbol('.'+instr.Operands[1].opr.symbol.name,instr.Operands[1].opr.symbol.bind,AT_FUNCTION,voidcodepointertype);
 end;
 end;
 
 
 function tppcattreader.is_targetdirective(const s: string): boolean;
 function tppcattreader.is_targetdirective(const s: string): boolean;

+ 5 - 5
compiler/ppcgen/cgppc.pas

@@ -342,13 +342,13 @@ unit cgppc;
         else
         else
           stubalign:=16;
           stubalign:=16;
         new_section(current_asmdata.asmlists[al_imports],sec_stub,'',stubalign);
         new_section(current_asmdata.asmlists[al_imports],sec_stub,'',stubalign);
-        result := current_asmdata.DefineAsmSymbol(stubname,AB_LOCAL,AT_FUNCTION);
+        result := current_asmdata.DefineAsmSymbol(stubname,AB_LOCAL,AT_FUNCTION,voidcodepointertype);
         current_asmdata.asmlists[al_imports].concat(Tai_symbol.Create(result,0));
         current_asmdata.asmlists[al_imports].concat(Tai_symbol.Create(result,0));
         { register as a weak symbol if necessary }
         { register as a weak symbol if necessary }
         if weak then
         if weak then
           current_asmdata.weakrefasmsymbol(s);
           current_asmdata.weakrefasmsymbol(s);
         current_asmdata.asmlists[al_imports].concat(tai_directive.create(asd_indirect_symbol,s));
         current_asmdata.asmlists[al_imports].concat(tai_directive.create(asd_indirect_symbol,s));
-        l1 := current_asmdata.DefineAsmSymbol('L'+s+'$lazy_ptr',AB_LOCAL,AT_DATA);
+        l1 := current_asmdata.DefineAsmSymbol('L'+s+'$lazy_ptr',AB_LOCAL,AT_DATA,voidpointertype);
         reference_reset_symbol(href,l1,0,sizeof(pint));
         reference_reset_symbol(href,l1,0,sizeof(pint));
         href.refaddr := addr_higha;
         href.refaddr := addr_higha;
         if (cs_create_pic in current_settings.moduleswitches) then
         if (cs_create_pic in current_settings.moduleswitches) then
@@ -816,7 +816,7 @@ unit cgppc;
             begin
             begin
               TPPCAsmData(current_asmdata).DirectTOCEntries:=TPPCAsmData(current_asmdata).DirectTOCEntries+1;
               TPPCAsmData(current_asmdata).DirectTOCEntries:=TPPCAsmData(current_asmdata).DirectTOCEntries+1;
               new_section(current_asmdata.AsmLists[al_picdata],sec_toc,'',sizeof(pint));
               new_section(current_asmdata.AsmLists[al_picdata],sec_toc,'',sizeof(pint));
-              ref.symbol:=current_asmdata.DefineAsmSymbol(nlsymname,AB_LOCAL,AT_DATA);
+              ref.symbol:=current_asmdata.DefineAsmSymbol(nlsymname,AB_LOCAL,AT_DATA,voidpointertype);
               current_asmdata.asmlists[al_picdata].concat(tai_symbol.create(ref.symbol,0));
               current_asmdata.asmlists[al_picdata].concat(tai_symbol.create(ref.symbol,0));
               { do not assign the result of these statements to ref.symbol: the
               { do not assign the result of these statements to ref.symbol: the
                 access must be done via the LC..symname symbol; these are just
                 access must be done via the LC..symname symbol; these are just
@@ -847,7 +847,7 @@ unit cgppc;
                   { base address for this batch of toc table entries that we'll
                   { base address for this batch of toc table entries that we'll
                     put in a data block instead }
                     put in a data block instead }
                   new_section(current_asmdata.AsmLists[al_indirectpicdata],sec_rodata,'',sizeof(pint));
                   new_section(current_asmdata.AsmLists[al_indirectpicdata],sec_rodata,'',sizeof(pint));
-                  sym:=current_asmdata.DefineAsmSymbol('tocsubtable'+tostr(tocnr),AB_LOCAL,AT_DATA);
+                  sym:=current_asmdata.DefineAsmSymbol('tocsubtable'+tostr(tocnr),AB_LOCAL,AT_DATA,voidpointertype);
                   current_asmdata.asmlists[al_indirectpicdata].concat(tai_symbol.create(sym,0));
                   current_asmdata.asmlists[al_indirectpicdata].concat(tai_symbol.create(sym,0));
                 end;
                 end;
               { add the reference to the actual symbol inside the tocsubtable }
               { add the reference to the actual symbol inside the tocsubtable }
@@ -857,7 +857,7 @@ unit cgppc;
                 current_asmdata.WeakRefAsmSymbol(symname)
                 current_asmdata.WeakRefAsmSymbol(symname)
               else
               else
                 current_asmdata.WeakRefAsmSymbol('.'+symname);
                 current_asmdata.WeakRefAsmSymbol('.'+symname);
-              tocsym:=TTOCAsmSymbol(current_asmdata.DefineAsmSymbolByClass(TTOCAsmSymbol,nlsymname,AB_LOCAL,AT_DATA));
+              tocsym:=TTOCAsmSymbol(current_asmdata.DefineAsmSymbolByClass(TTOCAsmSymbol,nlsymname,AB_LOCAL,AT_DATA,voidpointertype));
               ref.symbol:=tocsym;
               ref.symbol:=tocsym;
               tocsym.ftocsecnr:=tocnr;
               tocsym.ftocsecnr:=tocnr;
               current_asmdata.asmlists[al_indirectpicdata].concat(tai_symbol.create(tocsym,0));
               current_asmdata.asmlists[al_indirectpicdata].concat(tai_symbol.create(tocsym,0));

+ 2 - 2
compiler/ppcgen/hlcgppc.pas

@@ -163,9 +163,9 @@ implementation
         make_global:=true;
         make_global:=true;
 
 
       if make_global then
       if make_global then
-        List.concat(Tai_symbol.Createname_global(labelname,AT_FUNCTION,0))
+        List.concat(Tai_symbol.Createname_global(labelname,AT_FUNCTION,0,procdef))
       else
       else
-        List.concat(Tai_symbol.Createname(labelname,AT_FUNCTION,0));
+        List.concat(Tai_symbol.Createname(labelname,AT_FUNCTION,0,procdef));
 
 
       { set param1 interface to self  }
       { set param1 interface to self  }
       g_adjust_self_value(list,procdef,ioffset);
       g_adjust_self_value(list,procdef,ioffset);

+ 2 - 2
compiler/psub.pas

@@ -2225,9 +2225,9 @@ implementation
            begin
            begin
              if (po_global in pd.procoptions) or
              if (po_global in pd.procoptions) or
                 (cs_profile in current_settings.moduleswitches) then
                 (cs_profile in current_settings.moduleswitches) then
-               current_asmdata.DefineAsmSymbol(pd.mangledname,AB_GLOBAL,AT_FUNCTION)
+               current_asmdata.DefineAsmSymbol(pd.mangledname,AB_GLOBAL,AT_FUNCTION,pd)
              else
              else
-               current_asmdata.DefineAsmSymbol(pd.mangledname,AB_LOCAL,AT_FUNCTION);
+               current_asmdata.DefineAsmSymbol(pd.mangledname,AB_LOCAL,AT_FUNCTION,pd);
            end;
            end;
 
 
          current_structdef:=old_current_structdef;
          current_structdef:=old_current_structdef;

+ 1 - 1
compiler/ptconst.pas

@@ -140,7 +140,7 @@ implementation
                 { add indirect symbol }
                 { add indirect symbol }
                 { ToDo: do we also need this for the else part? }
                 { ToDo: do we also need this for the else part? }
                 new_section(list,sec_rodata,lower(sym.mangledname),const_align(sym.vardef.alignment));
                 new_section(list,sec_rodata,lower(sym.mangledname),const_align(sym.vardef.alignment));
-                symind:=current_asmdata.DefineAsmSymbol(sym.mangledname,AB_INDIRECT,AT_DATA);
+                symind:=current_asmdata.DefineAsmSymbol(sym.mangledname,AB_INDIRECT,AT_DATA,cpointerdef.getreusable(sym.vardef));
                 list.concat(Tai_symbol.Create_Global(symind,0));
                 list.concat(Tai_symbol.Create_Global(symind,0));
                 list.concat(Tai_const.Createname(sym.mangledname,AT_DATA,0));
                 list.concat(Tai_const.Createname(sym.mangledname,AT_DATA,0));
                 list.concat(tai_symbol_end.Create(symind));
                 list.concat(tai_symbol_end.Create(symind));

+ 4 - 2
compiler/raatt.pas

@@ -1225,7 +1225,8 @@ unit raatt;
                commname:=actasmpattern;
                commname:=actasmpattern;
                Consume(AS_ID);
                Consume(AS_ID);
                Consume(AS_COMMA);
                Consume(AS_COMMA);
-               curList.concat(Tai_datablock.Create(commname,BuildConstExpression(false,false)));
+               symofs:=BuildConstExpression(false,false);
+               curList.concat(Tai_datablock.Create(commname,symofs,carraydef.getreusable(u8inttype,symofs)));
                if actasmtoken<>AS_SEPARATOR then
                if actasmtoken<>AS_SEPARATOR then
                 Consume(AS_SEPARATOR);
                 Consume(AS_SEPARATOR);
              end;
              end;
@@ -1236,7 +1237,8 @@ unit raatt;
                commname:=actasmpattern;
                commname:=actasmpattern;
                Consume(AS_ID);
                Consume(AS_ID);
                Consume(AS_COMMA);
                Consume(AS_COMMA);
-               curList.concat(Tai_datablock.Create_global(commname,BuildConstExpression(false,false)));
+               symofs:=BuildConstExpression(false,false);
+               curList.concat(Tai_datablock.Create_global(commname,symofs,carraydef.getreusable(u8inttype,symofs)));
                if actasmtoken<>AS_SEPARATOR then
                if actasmtoken<>AS_SEPARATOR then
                 Consume(AS_SEPARATOR);
                 Consume(AS_SEPARATOR);
              end;
              end;

+ 2 - 2
compiler/rautils.pas

@@ -1578,7 +1578,7 @@ end;
   {  linked list of instructions.(used by AT&T styled asm)              }
   {  linked list of instructions.(used by AT&T styled asm)              }
   {*********************************************************************}
   {*********************************************************************}
    begin
    begin
-       p.concat(Tai_symbol.Createname_global(s,AT_LABEL,0));
+       p.concat(Tai_symbol.Createname_global(s,AT_LABEL,0,voidcodepointertype));
    end;
    end;
 
 
    procedure ConcatLocal(p:TAsmList;const s : string);
    procedure ConcatLocal(p:TAsmList;const s : string);
@@ -1588,7 +1588,7 @@ end;
   {  linked list of instructions.                                       }
   {  linked list of instructions.                                       }
   {*********************************************************************}
   {*********************************************************************}
    begin
    begin
-       p.concat(Tai_symbol.Createname(s,AT_LABEL,0));
+       p.concat(Tai_symbol.Createname(s,AT_LABEL,0,voidcodepointertype));
    end;
    end;
 
 
 
 

+ 2 - 2
compiler/sparc/hlcgcpu.pas

@@ -74,9 +74,9 @@ implementation
         make_global:=true;
         make_global:=true;
 
 
       if make_global then
       if make_global then
-        List.concat(Tai_symbol.Createname_global(labelname,AT_FUNCTION,0))
+        List.concat(Tai_symbol.Createname_global(labelname,AT_FUNCTION,0,procdef))
       else
       else
-        List.concat(Tai_symbol.Createname(labelname,AT_FUNCTION,0));
+        List.concat(Tai_symbol.Createname(labelname,AT_FUNCTION,0,procdef));
 
 
       { set param1 interface to self  }
       { set param1 interface to self  }
       procdef.init_paraloc_info(callerside);
       procdef.init_paraloc_info(callerside);

+ 1 - 1
compiler/systems/t_beos.pas

@@ -151,7 +151,7 @@ begin
 {$ifdef i386}
 {$ifdef i386}
            { place jump in al_procedures }
            { place jump in al_procedures }
            current_asmdata.asmlists[al_procedures].concat(Tai_align.Create_op(4,$90));
            current_asmdata.asmlists[al_procedures].concat(Tai_align.Create_op(4,$90));
-           current_asmdata.asmlists[al_procedures].concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0));
+           current_asmdata.asmlists[al_procedures].concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0,pd));
            current_asmdata.asmlists[al_procedures].concat(Taicpu.Op_sym(A_JMP,S_NO,current_asmdata.RefAsmSymbol(pd.mangledname)));
            current_asmdata.asmlists[al_procedures].concat(Taicpu.Op_sym(A_JMP,S_NO,current_asmdata.RefAsmSymbol(pd.mangledname)));
            current_asmdata.asmlists[al_procedures].concat(Tai_symbol_end.Createname(hp2.name^));
            current_asmdata.asmlists[al_procedures].concat(Tai_symbol_end.Createname(hp2.name^));
 {$endif i386}
 {$endif i386}

+ 1 - 1
compiler/systems/t_haiku.pas

@@ -152,7 +152,7 @@ begin
 {$ifdef i386}
 {$ifdef i386}
            { place jump in al_procedures }
            { place jump in al_procedures }
            current_asmdata.asmlists[al_procedures].concat(Tai_align.Create_op(4,$90));
            current_asmdata.asmlists[al_procedures].concat(Tai_align.Create_op(4,$90));
-           current_asmdata.asmlists[al_procedures].concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0));
+           current_asmdata.asmlists[al_procedures].concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0,pd));
            current_asmdata.asmlists[al_procedures].concat(Taicpu.Op_sym(A_JMP,S_NO,current_asmdata.RefAsmSymbol(pd.mangledname)));
            current_asmdata.asmlists[al_procedures].concat(Taicpu.Op_sym(A_JMP,S_NO,current_asmdata.RefAsmSymbol(pd.mangledname)));
            current_asmdata.asmlists[al_procedures].concat(Tai_symbol_end.Createname(hp2.name^));
            current_asmdata.asmlists[al_procedures].concat(Tai_symbol_end.Createname(hp2.name^));
 {$endif i386}
 {$endif i386}

+ 1 - 1
compiler/systems/t_nwl.pas

@@ -229,7 +229,7 @@ begin
 {$ifdef i386}
 {$ifdef i386}
            { place jump in al_procedures }
            { place jump in al_procedures }
            current_asmdata.asmlists[al_procedures].concat(Tai_align.Create_op(4,$90));
            current_asmdata.asmlists[al_procedures].concat(Tai_align.Create_op(4,$90));
-           current_asmdata.asmlists[al_procedures].concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0));
+           current_asmdata.asmlists[al_procedures].concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0,pd));
            current_asmdata.asmlists[al_procedures].concat(Taicpu.Op_sym(A_JMP,S_NO,current_asmdata.RefAsmSymbol(pd.mangledname)));
            current_asmdata.asmlists[al_procedures].concat(Taicpu.Op_sym(A_JMP,S_NO,current_asmdata.RefAsmSymbol(pd.mangledname)));
            current_asmdata.asmlists[al_procedures].concat(Tai_symbol_end.Createname(hp2.name^));
            current_asmdata.asmlists[al_procedures].concat(Tai_symbol_end.Createname(hp2.name^));
 {$endif i386}
 {$endif i386}

+ 1 - 1
compiler/systems/t_nwm.pas

@@ -231,7 +231,7 @@ begin
 {$ifdef i386}
 {$ifdef i386}
            { place jump in al_procedures }
            { place jump in al_procedures }
            current_asmdata.asmlists[al_procedures].concat(Tai_align.Create_op(4,$90));
            current_asmdata.asmlists[al_procedures].concat(Tai_align.Create_op(4,$90));
-           current_asmdata.asmlists[al_procedures].concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0));
+           current_asmdata.asmlists[al_procedures].concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0,pd));
            current_asmdata.asmlists[al_procedures].concat(Taicpu.Op_sym(A_JMP,S_NO,current_asmdata.RefAsmSymbol(pd.mangledname)));
            current_asmdata.asmlists[al_procedures].concat(Taicpu.Op_sym(A_JMP,S_NO,current_asmdata.RefAsmSymbol(pd.mangledname)));
            current_asmdata.asmlists[al_procedures].concat(Tai_symbol_end.Createname(hp2.name^));
            current_asmdata.asmlists[al_procedures].concat(Tai_symbol_end.Createname(hp2.name^));
 {$endif i386}
 {$endif i386}

+ 6 - 6
compiler/systems/t_win.pas

@@ -515,9 +515,9 @@ implementation
                     { place jump in al_procedures }
                     { place jump in al_procedures }
                     new_section(current_asmdata.asmlists[al_imports],sec_code,'',0);
                     new_section(current_asmdata.asmlists[al_imports],sec_code,'',0);
                     if ImportSymbol.Name <> '' then
                     if ImportSymbol.Name <> '' then
-                      current_asmdata.asmlists[al_imports].concat(Tai_symbol.Createname_global(ImportSymbol.MangledName,AT_FUNCTION,0))
+                      current_asmdata.asmlists[al_imports].concat(Tai_symbol.Createname_global(ImportSymbol.MangledName,AT_FUNCTION,0,voidcodepointertype))
                     else
                     else
-                      current_asmdata.asmlists[al_imports].concat(Tai_symbol.Createname_global(ExtractFileName(ImportLibrary.Name)+'_index_'+tostr(ImportSymbol.ordnr),AT_FUNCTION,0));
+                      current_asmdata.asmlists[al_imports].concat(Tai_symbol.Createname_global(ExtractFileName(ImportLibrary.Name)+'_index_'+tostr(ImportSymbol.ordnr),AT_FUNCTION,0,voidcodepointertype));
                     current_asmdata.asmlists[al_imports].concat(tai_function_name.create(''));
                     current_asmdata.asmlists[al_imports].concat(tai_function_name.create(''));
                   {$ifdef ARM}
                   {$ifdef ARM}
                     reference_reset_symbol(href,l5,0,sizeof(pint));
                     reference_reset_symbol(href,l5,0,sizeof(pint));
@@ -549,7 +549,7 @@ implementation
                                 inc(suffix);
                                 inc(suffix);
                                 importname:='__imp_'+ImportSymbol.MangledName+'_'+tostr(suffix);
                                 importname:='__imp_'+ImportSymbol.MangledName+'_'+tostr(suffix);
                               end;
                               end;
-                            current_asmdata.asmlists[al_imports].concat(tai_symbol.createname(importname,AT_FUNCTION,4));
+                            current_asmdata.asmlists[al_imports].concat(tai_symbol.createname(importname,AT_FUNCTION,4,voidcodepointertype));
                           end
                           end
                         else
                         else
                           begin
                           begin
@@ -560,13 +560,13 @@ implementation
                                 inc(suffix);
                                 inc(suffix);
                                 importname:='__imp_by_ordinal'+tostr(ImportSymbol.ordnr)+'_'+tostr(suffix);
                                 importname:='__imp_by_ordinal'+tostr(ImportSymbol.ordnr)+'_'+tostr(suffix);
                               end;
                               end;
-                            current_asmdata.asmlists[al_imports].concat(tai_symbol.createname(importname,AT_FUNCTION,4));
+                            current_asmdata.asmlists[al_imports].concat(tai_symbol.createname(importname,AT_FUNCTION,4,voidcodepointertype));
                           end;
                           end;
                       end;
                       end;
                      current_asmdata.asmlists[al_imports].concat(Tai_label.Create(l4));
                      current_asmdata.asmlists[al_imports].concat(Tai_label.Create(l4));
                   end
                   end
                 else
                 else
-                  current_asmdata.asmlists[al_imports].concat(Tai_symbol.Createname_global(ImportSymbol.MangledName,AT_DATA,0));
+                  current_asmdata.asmlists[al_imports].concat(Tai_symbol.Createname_global(ImportSymbol.MangledName,AT_DATA,0,voidpointertype));
                 current_asmdata.asmlists[al_imports].concat(Tai_const.Create_rva_sym(TAsmLabel(Importlabels[j])));
                 current_asmdata.asmlists[al_imports].concat(Tai_const.Create_rva_sym(TAsmLabel(Importlabels[j])));
                 if target_info.system=system_x86_64_win64 then
                 if target_info.system=system_x86_64_win64 then
                   current_asmdata.asmlists[al_imports].concat(Tai_const.Create_32bit(0));
                   current_asmdata.asmlists[al_imports].concat(Tai_const.Create_32bit(0));
@@ -788,7 +788,7 @@ implementation
          new_section(current_asmdata.asmlists[al_exports],sec_edata,'',0);
          new_section(current_asmdata.asmlists[al_exports],sec_edata,'',0);
          { create label to reference from main so smartlink will include
          { create label to reference from main so smartlink will include
            the .edata section }
            the .edata section }
-         current_asmdata.asmlists[al_exports].concat(Tai_symbol.Createname_global(make_mangledname('EDATA',current_module.localsymtable,''),AT_DATA,0));
+         current_asmdata.asmlists[al_exports].concat(Tai_symbol.Createname_global(make_mangledname('EDATA',current_module.localsymtable,''),AT_METADATA,0,voidpointertype));
          { export flags }
          { export flags }
          current_asmdata.asmlists[al_exports].concat(Tai_const.Create_32bit(0));
          current_asmdata.asmlists[al_exports].concat(Tai_const.Create_32bit(0));
          { date/time stamp }
          { date/time stamp }

+ 1 - 1
compiler/x86/cgx86.pas

@@ -819,7 +819,7 @@ unit cgx86;
           current_asmdata.asmlists[al_imports]:=TAsmList.create;
           current_asmdata.asmlists[al_imports]:=TAsmList.create;
 
 
         new_section(current_asmdata.asmlists[al_imports],sec_stub,'',0);
         new_section(current_asmdata.asmlists[al_imports],sec_stub,'',0);
-        result := current_asmdata.DefineAsmSymbol(stubname,AB_LOCAL,AT_FUNCTION);
+        result := current_asmdata.DefineAsmSymbol(stubname,AB_LOCAL,AT_FUNCTION,voidcodepointertype);
         current_asmdata.asmlists[al_imports].concat(Tai_symbol.Create(result,0));
         current_asmdata.asmlists[al_imports].concat(Tai_symbol.Create(result,0));
         { register as a weak symbol if necessary }
         { register as a weak symbol if necessary }
         if weak then
         if weak then

+ 2 - 2
compiler/x86_64/hlcgcpu.pas

@@ -72,9 +72,9 @@ implementation
         make_global:=true;
         make_global:=true;
 
 
       if make_global then
       if make_global then
-        List.concat(Tai_symbol.Createname_global(labelname,AT_FUNCTION,0))
+        List.concat(Tai_symbol.Createname_global(labelname,AT_FUNCTION,0,procdef))
       else
       else
-        List.concat(Tai_symbol.Createname(labelname,AT_FUNCTION,0));
+        List.concat(Tai_symbol.Createname(labelname,AT_FUNCTION,0,procdef));
 
 
       { set param1 interface to self  }
       { set param1 interface to self  }
       g_adjust_self_value(list,procdef,ioffset);
       g_adjust_self_value(list,procdef,ioffset);