|
@@ -41,7 +41,7 @@ implementation
|
|
|
uses
|
|
|
globals,verbose,
|
|
|
cgbase,cgobj,cgutils,
|
|
|
- aasmdata,
|
|
|
+ aasmdata,aasmcpu,
|
|
|
systems,
|
|
|
symcpu,symdef,
|
|
|
nld,
|
|
@@ -70,6 +70,7 @@ implementation
|
|
|
case current_settings.tlsmodel of
|
|
|
tlsm_general_dynamic:
|
|
|
begin
|
|
|
+{$ifdef use_tls_dialect_gnu}
|
|
|
current_asmdata.getjumplabel(l);
|
|
|
reference_reset_symbol(href,current_asmdata.RefAsmSymbol(gvs.mangledname,AT_TLS),-8,sizeof(AInt),[]);
|
|
|
href.refaddr:=addr_tlsgd;
|
|
@@ -79,12 +80,49 @@ implementation
|
|
|
cg.a_label(current_asmdata.CurrAsmList,l);
|
|
|
cg.getcpuregister(current_asmdata.CurrAsmList,NR_R0);
|
|
|
cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList,OP_ADD,OS_ADDR,hregister,NR_PC,NR_R0);
|
|
|
- cg.g_call(current_asmdata.CurrAsmList,'___tls_get_addr');
|
|
|
+ cg.g_call(current_asmdata.CurrAsmList,'__tls_get_addr');
|
|
|
cg.ungetcpuregister(current_asmdata.CurrAsmList,NR_R0);
|
|
|
hregister:=cg.getaddressregister(current_asmdata.CurrAsmList);
|
|
|
cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,NR_R0,hregister);
|
|
|
reference_reset(location.reference,location.reference.alignment,location.reference.volatility);
|
|
|
location.reference.base:=hregister;
|
|
|
+{$else use_tls_dialect_gnu}
|
|
|
+ { On arm, we use the gnu2 tls dialect. It has the advantage that it can be relaxed (optimized) by the linker,
|
|
|
+ this is not possible with the gnu tls dialect.
|
|
|
+
|
|
|
+ gnu2 is proposed and documented in
|
|
|
+ Glauber de Oliveira Costa, Alexandre Oliva: Speeding Up Thread-Local Storage Access in DynamicLibraries in the ARM platform, 2006.
|
|
|
+ Link: https://www.fsfla.org/~lxoliva/writeups/TLS/paper-lk2006.pdf
|
|
|
+ }
|
|
|
+ current_asmdata.getjumplabel(l);
|
|
|
+ reference_reset_symbol(href,current_asmdata.RefAsmSymbol(gvs.mangledname,AT_TLS),0,sizeof(AInt),[]);
|
|
|
+ href.refaddr:=addr_tlsdesc;
|
|
|
+ href.relsymbol:=l;
|
|
|
+ hregister:=cg.getaddressregister(current_asmdata.CurrAsmList);
|
|
|
+ cg.getcpuregister(current_asmdata.CurrAsmList,NR_R0);
|
|
|
+ cg.a_loadaddr_ref_reg(current_asmdata.CurrAsmList,href,NR_R0);
|
|
|
+ cg.a_label(current_asmdata.CurrAsmList,l);
|
|
|
+
|
|
|
+ { we have to go the ugly way so we can set addr_tlscall }
|
|
|
+ cg.allocallcpuregisters(current_asmdata.CurrAsmList);
|
|
|
+ cg.a_call_name(current_asmdata.CurrAsmList,gvs.mangledname,false);
|
|
|
+ with taicpu(current_asmdata.CurrAsmList.Last) do
|
|
|
+ begin
|
|
|
+ if opcode<>A_BL then
|
|
|
+ Internalerror(2019092902);
|
|
|
+ oper[0]^.ref^.refaddr:=addr_tlscall;
|
|
|
+ end;
|
|
|
+ cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
|
|
|
+
|
|
|
+ cg.getcpuregister(current_asmdata.CurrAsmList,NR_R0);
|
|
|
+ cg.ungetcpuregister(current_asmdata.CurrAsmList,NR_R0);
|
|
|
+ hregister:=cg.getaddressregister(current_asmdata.CurrAsmList);
|
|
|
+ cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,NR_R0,hregister);
|
|
|
+ reference_reset(location.reference,location.reference.alignment,location.reference.volatility);
|
|
|
+ location.reference.base:=current_procinfo.tlsoffset;
|
|
|
+ include(current_procinfo.flags,pi_needs_tls);
|
|
|
+ location.reference.index:=hregister;
|
|
|
+{$endif use_tls_dialect_gnu}
|
|
|
handled:=true;
|
|
|
end;
|
|
|
tlsm_initial_exec:
|