+ new relocations for arm tls

git-svn-id: trunk@43123 -
This commit is contained in:
florian 2019-10-05 20:48:21 +00:00
parent 03f7ef4c63
commit 03dfc615dc
7 changed files with 70 additions and 10 deletions

View File

@ -153,8 +153,8 @@ interface
aitconst_gotoff_symbol,
{ ARM TLS code }
aitconst_gottpoff,
aitconst_tpoff
aitconst_tpoff,
aitconst_tlsgd
);
tairealconsttype = (
@ -2099,6 +2099,12 @@ implementation
result:=sizeof(pint);
aitconst_gotoff_symbol:
result:=4;
aitconst_gottpoff:
result:=4;
aitconst_tlsgd:
result:=4;
aitconst_tpoff:
result:=4;
else
internalerror(200603253);
end;

View File

@ -992,6 +992,18 @@ implementation
writer.AsmWrite(#9'.word'#9+tai_const(hp).sym.name+'(gottpoff)+(.-'+tai_const(hp).endsym.name+tostr_with_plus(tai_const(hp).symofs)+')');
writer.Asmln;
end;
aitconst_tlsgd:
begin
writer.AsmWrite(#9'.word'#9+tai_const(hp).sym.name+'(tlsgd)+(.-'+tai_const(hp).endsym.name+tostr_with_plus(tai_const(hp).symofs)+')');
writer.Asmln;
end;
aitconst_tpoff:
begin
if assigned(tai_const(hp).endsym) or (tai_const(hp).symofs<>0) then
Internalerror(2019092805);
writer.AsmWrite(#9'.word'#9+tai_const(hp).sym.name+'(tpoff)');
writer.Asmln;
end;
{$endif cpu64bitaddr}
aitconst_got:
begin

View File

@ -1160,8 +1160,8 @@ implementation
begin
if (hp2.typ=ait_const) and (tai_const(hp2).sym=tai_const(hp).sym)
and (tai_const(hp2).value=tai_const(hp).value) and (tai(hp2.previous).typ=ait_label) and
{ gottpoff symbols are PC relative, so we cannot reuse them }
(tai_const(hp2).consttype<>aitconst_gottpoff) then
{ gottpoff and tlsgd symbols are PC relative, so we cannot reuse them }
(not(tai_const(hp2).consttype in [aitconst_gottpoff,aitconst_tlsgd])) then
begin
with taicpu(curtai).oper[curop]^.ref^ do
begin

View File

@ -2493,6 +2493,15 @@ unit cgcpu;
end
else if ref.refaddr=addr_gottpoff then
current_procinfo.aktlocaldata.concat(tai_const.Create_rel_sym_offset(aitconst_gottpoff,ref.symbol,ref.relsymbol,ref.offset))
else if ref.refaddr=addr_tlsgd then
current_procinfo.aktlocaldata.concat(tai_const.Create_rel_sym_offset(aitconst_tlsgd,ref.symbol,ref.relsymbol,ref.offset))
else if ref.refaddr=addr_tpoff then
begin
if assigned(ref.relsymbol) or (ref.offset<>0) then
Internalerror(2019092804);
current_procinfo.aktlocaldata.concat(tai_const.Create_type_sym(aitconst_tpoff,ref.symbol));
end
else if (cs_create_pic in current_settings.moduleswitches) then
if (tf_pic_uses_got in target_info.flags) then
current_procinfo.aktlocaldata.concat(tai_const.Create_type_sym(aitconst_got,ref.symbol))
@ -3339,10 +3348,13 @@ unit cgcpu;
procedure tbasecgarm.g_maybe_tls_init(list : TAsmList);
begin
list.concat(tai_regalloc.alloc(NR_R0,nil));
a_call_name(list,'fpc_read_tp',false);
a_load_reg_reg(list,OS_ADDR,OS_ADDR,NR_R0,current_procinfo.tlsoffset);
list.concat(tai_regalloc.dealloc(NR_R0,nil));
if pi_needs_tls in current_procinfo.flags then
begin
list.concat(tai_regalloc.alloc(NR_R0,nil));
a_call_name(list,'fpc_read_tp',false);
a_load_reg_reg(list,OS_ADDR,OS_ADDR,NR_R0,current_procinfo.tlsoffset);
list.concat(tai_regalloc.dealloc(NR_R0,nil));
end;
end;
@ -5126,6 +5138,15 @@ unit cgcpu;
if ref.refaddr=addr_gottpoff then
current_procinfo.aktlocaldata.concat(tai_const.Create_rel_sym_offset(aitconst_gottpoff,ref.symbol,ref.relsymbol,ref.offset))
else if ref.refaddr=addr_tlsgd then
current_procinfo.aktlocaldata.concat(tai_const.Create_rel_sym_offset(aitconst_tlsgd,ref.symbol,ref.relsymbol,ref.offset))
else if ref.refaddr=addr_tpoff then
begin
if assigned(ref.relsymbol) or (ref.offset<>0) then
Internalerror(2019092805);
current_procinfo.aktlocaldata.concat(tai_const.Create_type_sym(aitconst_tpoff,ref.symbol));
end
else
current_procinfo.aktlocaldata.concat(tai_const.create_sym_offset(ref.symbol,ref.offset));

View File

@ -1764,7 +1764,13 @@ Implementation
begin
objsym:=Objdata.SymbolRef(tai_const(hp).sym);
objsymend:=Objdata.SymbolRef(tai_const(hp).endsym);
if objsymend.objsection<>objsym.objsection then
if Tai_const(hp).consttype in [aitconst_gottpoff,aitconst_tlsgd] then
begin
if objsymend.objsection<>ObjData.CurrObjSec then
Internalerror(2019092801);
Tai_const(hp).value:=objsymend.address-ObjData.CurrObjSec.Size+Tai_const(hp).symofs;
end
else if objsymend.objsection<>objsym.objsection then
begin
if (Tai_const(hp).consttype in [aitconst_uleb128bit,aitconst_sleb128bit]) or
(objsym.objsection<>ObjData.CurrObjSec) then
@ -1985,7 +1991,13 @@ Implementation
objsym:=Objdata.SymbolRef(tai_const(hp).sym);
objsymend:=Objdata.SymbolRef(tai_const(hp).endsym);
relative_reloc:=(objsym.objsection<>objsymend.objsection);
if objsymend.objsection<>objsym.objsection then
if Tai_const(hp).consttype in [aitconst_gottpoff,aitconst_tlsgd] then
begin
if objsymend.objsection<>ObjData.CurrObjSec then
Internalerror(2019092802);
Tai_const(hp).value:=objsymend.address-ObjData.CurrObjSec.Size+Tai_const(hp).symofs;
end
else if objsymend.objsection<>objsym.objsection then
begin
if (Tai_const(hp).consttype in [aitconst_uleb128bit,aitconst_sleb128bit]) or
(objsym.objsection<>ObjData.CurrObjSec) then
@ -2048,6 +2060,12 @@ Implementation
{$ifdef arm}
aitconst_got:
ObjData.writereloc(Tai_const(hp).symofs,sizeof(longint),Objdata.SymbolRef(tai_const(hp).sym),RELOC_GOT32);
{ aitconst_gottpoff:
ObjData.writereloc(Tai_const(hp).symofs,sizeof(longint),Objdata.SymbolRef(tai_const(hp).sym),RELOC_TPOFF); }
aitconst_tpoff:
ObjData.writereloc(Tai_const(hp).symofs,sizeof(longint),Objdata.SymbolRef(tai_const(hp).sym),RELOC_TPOFF);
aitconst_tlsgd:
ObjData.writereloc(Tai_const(hp).symofs,sizeof(longint),Objdata.SymbolRef(tai_const(hp).sym),RELOC_TLSGD);
{$endif arm}
aitconst_gotoff_symbol:
ObjData.writereloc(Tai_const(hp).symofs,sizeof(longint),Objdata.SymbolRef(tai_const(hp).sym),RELOC_GOTOFF);

View File

@ -125,6 +125,7 @@ interface
{$IFDEF ARM}
,addr_gottpoff
,addr_tpoff
,addr_tlsgd
{$ENDIF}
{$IFDEF i386}
,addr_ntpoff

View File

@ -91,6 +91,8 @@ interface
RELOC_RELATIVE_24_THUMB,
RELOC_RELATIVE_CALL_THUMB,
RELOC_GOT32,
RELOC_TPOFF,
RELOC_TLSGD,
{$endif arm}
{ Relative relocation }
RELOC_RELATIVE,