From f69b365b77b15cd22e3de80e962c3037b92aab5f Mon Sep 17 00:00:00 2001 From: svenbarth Date: Fri, 22 Jul 2016 13:34:38 +0000 Subject: [PATCH] * declare various symbols as external assembler symbols: RTTI references, parent VMT, FPC_EMPTYMETHOD (all three only if it's used from a different unit), threadvar lists and symbols declared as "external" git-svn-id: trunk@34176 - --- compiler/ncgrtti.pas | 2 ++ compiler/ncgvmt.pas | 11 +++++++++-- compiler/ngenutil.pas | 1 + compiler/psub.pas | 7 ++++++- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/compiler/ncgrtti.pas b/compiler/ncgrtti.pas index 0ce3de9ab7..f510e696ab 100644 --- a/compiler/ncgrtti.pas +++ b/compiler/ncgrtti.pas @@ -1527,6 +1527,8 @@ implementation if (cs_create_pic in current_settings.moduleswitches) and assigned(current_procinfo) then include(current_procinfo.flags,pi_needs_got); + if def.owner.moduleid<>current_module.moduleid then + current_module.add_extern_asmsym(result); end; diff --git a/compiler/ncgvmt.pas b/compiler/ncgvmt.pas index d9f9e441c2..ac432e493c 100644 --- a/compiler/ncgvmt.pas +++ b/compiler/ncgvmt.pas @@ -1011,7 +1011,11 @@ implementation generate_abstract_stub(current_asmdata.AsmLists[al_procedures],vmtpd); end else if (cs_opt_remove_emtpy_proc in current_settings.optimizerswitches) and RedirectToEmpty(vmtpd) then - procname:='FPC_EMPTYMETHOD' + begin + procname:='FPC_EMPTYMETHOD'; + if current_module.globalsymtable<>systemunit then + current_module.add_extern_asmsym(procname,AB_GLOBAL,AT_FUNCTION); + end else if not wpoinfomanager.optimized_name_for_vmt(_class,vmtpd,procname) then procname:=vmtpd.mangledname; tcb.emit_tai(Tai_const.Createname(procname,AT_FUNCTION,0),cprocvardef.getreusableprocaddr(vmtpd)); @@ -1129,9 +1133,12 @@ implementation (oo_has_vmt in _class.childof.objectoptions) then begin tcb.queue_init(parentvmtdef); + sym:=current_asmdata.RefAsmSymbol(_class.childof.vmt_mangledname,AT_DATA,true); tcb.queue_emit_asmsym( - current_asmdata.RefAsmSymbol(_class.childof.vmt_mangledname,AT_DATA,true), + sym, tfieldvarsym(_class.childof.vmt_field).vardef); + if _class.childof.owner.moduleid<>current_module.moduleid then + current_module.add_extern_asmsym(sym); end else tcb.emit_tai(Tai_const.Create_nil_dataptr,parentvmtdef); diff --git a/compiler/ngenutil.pas b/compiler/ngenutil.pas index f82678a2c3..172630dc53 100644 --- a/compiler/ngenutil.pas +++ b/compiler/ngenutil.pas @@ -1034,6 +1034,7 @@ implementation tcb.emit_tai( tai_const.Create_sym(sym), voidpointertype); + current_module.add_extern_asmsym(sym); inc(count); end; hp:=tused_unit(hp.next); diff --git a/compiler/psub.pas b/compiler/psub.pas index 37085030bf..dc6637af26 100644 --- a/compiler/psub.pas +++ b/compiler/psub.pas @@ -2238,6 +2238,8 @@ implementation procedure import_external_proc(pd:tprocdef); + var + name : string; begin if not (po_external in pd.procoptions) then internalerror(2015121101); @@ -2256,9 +2258,12 @@ implementation end else begin + name:=proc_get_importname(pd); { add import name to external list for DLL scanning } if tf_has_dllscanner in target_info.flags then - current_module.dllscannerinputlist.Add(proc_get_importname(pd),pd); + current_module.dllscannerinputlist.Add(name,pd); + { needed for units that use functions in packages this way } + current_module.add_extern_asmsym(name,AB_EXTERNAL,AT_FUNCTION); end; end;