summaryrefslogtreecommitdiff
path: root/compiler/ncgld.pas
diff options
context:
space:
mode:
authorsvenbarth <svenbarth@3ad0048d-3df7-0310-abae-a5850022a9f2>2016-08-19 13:07:56 +0000
committersvenbarth <svenbarth@3ad0048d-3df7-0310-abae-a5850022a9f2>2016-08-19 13:07:56 +0000
commita40792d273b0c8ac19021b3a3ff0ccf4462441f4 (patch)
tree5b728cbb3a3c9f58f41e4568e09c271d5611a4d3 /compiler/ncgld.pas
parentd74229c8330a9fc77f33c581ebd5047a73818cb7 (diff)
downloadfpc-a40792d273b0c8ac19021b3a3ff0ccf4462441f4.tar.gz
* use indirect reference for FPC_THREADVAR_RELOCATE if necessary
* reference FPC_THREADVAR_RELOCATE assembler symbol if necessary git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@34339 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'compiler/ncgld.pas')
-rw-r--r--compiler/ncgld.pas19
1 files changed, 18 insertions, 1 deletions
diff --git a/compiler/ncgld.pas b/compiler/ncgld.pas
index 516c6462cd..7d6ee27df5 100644
--- a/compiler/ncgld.pas
+++ b/compiler/ncgld.pas
@@ -269,6 +269,8 @@ implementation
tv_index_field,
tv_non_mt_data_field: tsym;
tmpresloc: tlocation;
+ issystemunit,
+ indirect : boolean;
begin
if (tf_section_threadvars in target_info.flags) then
begin
@@ -298,10 +300,25 @@ implementation
internalerror(2012120901);
{ FPC_THREADVAR_RELOCATE is nil? }
+ issystemunit:=not current_module.is_unit or
+ (
+ assigned(current_module.globalsymtable) and
+ (current_module.globalsymtable=systemunit)
+ ) or
+ (
+ not assigned(current_module.globalsymtable) and
+ (current_module.localsymtable=systemunit)
+ );
+ indirect:=(tf_supports_packages in target_info.flags) and
+ (target_info.system in systems_indirect_var_imports) and
+ (cs_imported_data in current_settings.localswitches) and
+ not issystemunit;
paraloc1.init;
paramanager.getintparaloc(current_asmdata.CurrAsmList,tprocvardef(pvd),1,paraloc1);
hregister:=hlcg.getaddressregister(current_asmdata.CurrAsmList,pvd);
- reference_reset_symbol(href,current_asmdata.RefAsmSymbol('FPC_THREADVAR_RELOCATE',AT_DATA),0,pvd.size);
+ reference_reset_symbol(href,current_asmdata.RefAsmSymbol('FPC_THREADVAR_RELOCATE',AT_DATA,indirect),0,pvd.size);
+ if not issystemunit then
+ current_module.add_extern_asmsym('FPC_THREADVAR_RELOCATE',AB_EXTERNAL,AT_DATA);
hlcg.a_load_ref_reg(current_asmdata.CurrAsmList,pvd,pvd,href,hregister);
hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,pvd,OC_EQ,0,hregister,norelocatelab);
{ no, call it with the index of the threadvar as parameter }