* extend tai_typedconstbuilder with the ability to add an indirect symbol to the same section as the one that's generated for the constant data (at least if it's also rodata)

git-svn-id: trunk@35365 -
This commit is contained in:
svenbarth 2017-01-29 17:39:52 +00:00
parent b813fc641f
commit 822d96776b

View File

@ -488,6 +488,7 @@ type
implementation
uses
cutils,
verbose,globals,systems,widestr,
fmodule,
symtable,defutil;
@ -912,6 +913,10 @@ implementation
procedure ttai_typedconstbuilder.finalize_asmlist(sym: tasmsymbol; def: tdef; section: TAsmSectiontype; const secname: TSymStr; alignment: shortint; const options: ttcasmlistoptions);
var
prelist: tasmlist;
ptrdef : tdef;
symind : tasmsymbol;
indtcb : ttai_typedconstbuilder;
indsecname : tsymstr;
begin
if tcalo_apply_constalign in options then
alignment:=const_align(alignment);
@ -982,6 +987,31 @@ implementation
fasmlist.concat(tai_symbol_end.Createname(sym.name));
{ free the temporary list }
prelist.free;
if (tcalo_data_force_indirect in options) and
not fvectorized_finalize_called and
(sym.bind in [AB_GLOBAL,AB_COMMON]) and
(sym.typ=AT_DATA) then
begin
ptrdef:=cpointerdef.getreusable(def);
symind:=current_asmdata.DefineAsmSymbol(sym.name,AB_INDIRECT,AT_DATA,ptrdef);
{ reuse the section if possible }
if section=sec_rodata then
indsecname:=secname
else
indsecname:=lower(symind.name);
indtcb:=ctai_typedconstbuilder.create([tcalo_new_section]);
indtcb.emit_tai(tai_const.create_sym_offset(sym,0),ptrdef);
current_asmdata.asmlists[al_indirectglobals].concatlist(indtcb.get_final_asmlist(
symind,
ptrdef,
sec_rodata,
indsecname,
ptrdef.alignment));
indtcb.free;
if not (target_info.system in systems_indirect_var_imports) then
current_module.add_public_asmsym(symind.name,AB_INDIRECT,AT_DATA);
end;
end;