diff --git a/compiler/aasmdata.pas b/compiler/aasmdata.pas index 2a3460e14d..78bb8a4a96 100644 --- a/compiler/aasmdata.pas +++ b/compiler/aasmdata.pas @@ -207,7 +207,8 @@ interface sym: tsym; offset: aint; datalabel: TAsmSymbol; - constructor Create(asym: tsym; aoffset: aint; alabel: TAsmSymbol); + datadef: TDef; + constructor Create(asym: tsym; aoffset: aint; alabel: TAsmSymbol; alabeldef: tdef); end; var @@ -287,12 +288,13 @@ implementation *****************************************************************************} - constructor TTCInitItem.Create(asym: tsym; aoffset: aint; alabel: TAsmSymbol); + constructor TTCInitItem.Create(asym: tsym; aoffset: aint; alabel: TAsmSymbol; alabeldef: tdef); begin inherited Create; sym:=asym; offset:=aoffset; datalabel:=alabel; + datadef:=alabeldef; end; {***************************************************************************** diff --git a/compiler/ngenutil.pas b/compiler/ngenutil.pas index e457760ec9..dfc3214468 100644 --- a/compiler/ngenutil.pas +++ b/compiler/ngenutil.pas @@ -1212,30 +1212,40 @@ implementation var s: string; item: TTCInitItem; + tcb: ttai_typedconstbuilder; + rawdatadef: tdef; begin item:=TTCInitItem(list.First); if item=nil then exit; s:=make_mangledname(prefix,current_module.localsymtable,''); - maybe_new_object_file(current_asmdata.asmlists[al_globals]); - new_section(current_asmdata.asmlists[al_globals],sec_data,s,sizeof(pint)); - { 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)); + tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable,tcalo_new_section]); + tcb.begin_anonymous_record('',default_settings.packrecords,sizeof(pint), + targetinfos[target_info.system]^.alignment.recordalignmin, + targetinfos[target_info.system]^.alignment.maxCrecordalign ); repeat { optimize away unused local/static symbols } if (item.sym.refs>0) or (item.sym.owner.symtabletype=globalsymtable) then begin { address to initialize } - current_asmdata.asmlists[al_globals].concat(Tai_const.createname(item.sym.mangledname, item.offset)); + tcb.queue_init(voidpointertype); + rawdatadef:=carraydef.getreusable(cansichartype,tstaticvarsym(item.sym).vardef.size); + tcb.queue_vecn(rawdatadef,item.offset); + tcb.queue_typeconvn(cpointerdef.getreusable(tstaticvarsym(item.sym).vardef),cpointerdef.getreusable(rawdatadef)); + tcb.queue_emit_staticvar(tstaticvarsym(item.sym)); { value with which to initialize } - current_asmdata.asmlists[al_globals].concat(Tai_const.Create_sym(item.datalabel)); + tcb.emit_tai(Tai_const.Create_sym(item.datalabel),item.datadef) end; item:=TTCInitItem(item.Next); until item=nil; { end-of-list marker } - current_asmdata.asmlists[al_globals].concat(Tai_const.Create_sym(nil)); - current_asmdata.asmlists[al_globals].concat(Tai_symbol_end.Createname(s)); + tcb.emit_tai(Tai_const.Create_nil_dataptr,voidpointertype); + rawdatadef:=tcb.end_anonymous_record; + current_asmdata.asmlists[al_globals].concatList( + tcb.get_final_asmlist( + current_asmdata.DefineAsmSymbol(s,AB_GLOBAL,AT_DATA,rawdatadef), + rawdatadef,sec_data,s,sizeof(pint))); + tcb.free; current_module.flags:=current_module.flags or unitflag; end; diff --git a/compiler/ngtcon.pas b/compiler/ngtcon.pas index 3751e19bb8..b0c964e698 100644 --- a/compiler/ngtcon.pas +++ b/compiler/ngtcon.pas @@ -511,7 +511,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis begin current_asmdata.ResStrInits.Concat( TTCInitItem.Create(tcsym,curoffset, - current_asmdata.RefAsmSymbol(make_mangledname('RESSTR',hsym.owner,hsym.name),AT_DATA)) + current_asmdata.RefAsmSymbol(make_mangledname('RESSTR',hsym.owner,hsym.name),AT_DATA),charpointertype) ); Include(tcsym.varoptions,vo_force_finalize); end; @@ -583,7 +583,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis if ll.ofs<>0 then internalerror(2012051704); current_asmdata.WideInits.Concat( - TTCInitItem.Create(tcsym,curoffset,ll.lab) + TTCInitItem.Create(tcsym,curoffset,ll.lab,widecharpointertype) ); ll.lab:=nil; ll.ofs:=0;