diff --git a/compiler/cgobj.pas b/compiler/cgobj.pas index c51bcc1b56..f01d96bfeb 100644 --- a/compiler/cgobj.pas +++ b/compiler/cgobj.pas @@ -192,7 +192,8 @@ unit cgobj; registers used for the parameters (PFV) } procedure a_call_name(list : taasmoutput;const s : string);virtual; abstract; - procedure a_call_reg(list : taasmoutput;reg : tregister);virtual;abstract; + procedure a_call_reg(list : taasmoutput;reg : tregister);virtual; abstract; + procedure a_call_ref(list : taasmoutput;ref : treference);virtual; abstract; { move instructions } procedure a_load_const_reg(list : taasmoutput;size : tcgsize;a : aint;register : tregister);virtual; abstract; diff --git a/compiler/ncgcal.pas b/compiler/ncgcal.pas index 30cc7db5b2..b6e324fcaf 100644 --- a/compiler/ncgcal.pas +++ b/compiler/ncgcal.pas @@ -794,14 +794,15 @@ implementation procedure tcgcallnode.pass_2; var - regs_to_save_int, - regs_to_save_fpu, - regs_to_save_mm : Tcpuregisterset; - href : treference; - pop_size : longint; - pvreg, - vmtreg : tregister; - oldaktcallnode : tcallnode; + regs_to_save_int, + regs_to_save_fpu, + regs_to_save_mm : Tcpuregisterset; + href : treference; + pop_size : longint; + pvreg, + vmtreg : tregister; + oldaktcallnode : tcallnode; + sym : tasmsymbol; begin if not assigned(procdefinition) or not procdefinition.has_paraloc_info then @@ -933,7 +934,19 @@ implementation if (po_interrupt in procdefinition.procoptions) then extra_interrupt_code; extra_call_code; - cg.a_call_name(exprasmlist,tprocdef(procdefinition).mangledname); + + { lazy binding on linux? } + if (target_info.system in system_linux) and + assigned(tprocdef(procdefinition).import_dll) and + (tprocdef(procdefinition).import_dll^='') then + begin + sym:=objectlibrary.newasmsymbol(tprocdef(procdefinition).mangledname,AB_EXTERNAL,AT_FUNCTION); + reference_reset_symbol(href,sym,0); + href.refaddr:=addr_pic; + cg.a_call_ref(exprasmlist,href); + end + else + cg.a_call_name(exprasmlist,tprocdef(procdefinition).mangledname); extra_post_call_code; end; end; diff --git a/compiler/x86/cgx86.pas b/compiler/x86/cgx86.pas index 49bef197a2..c2efe32e79 100644 --- a/compiler/x86/cgx86.pas +++ b/compiler/x86/cgx86.pas @@ -54,6 +54,7 @@ unit cgx86; procedure a_call_name(list : taasmoutput;const s : string);override; procedure a_call_reg(list : taasmoutput;reg : tregister);override; + procedure a_call_ref(list : taasmoutput;ref : treference);override; procedure a_op_const_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; a: aint; reg: TRegister); override; procedure a_op_const_ref(list : taasmoutput; Op: TOpCG; size: TCGSize; a: aint; const ref: TReference); override; @@ -556,6 +557,12 @@ unit cgx86; end; + procedure tcgx86.a_call_ref(list : taasmoutput;ref : treference); + begin + list.concat(taicpu.op_ref(A_CALL,S_NO,ref)); + end; + + {********************** load instructions ********************} procedure tcgx86.a_load_const_reg(list : taasmoutput; tosize: TCGSize; a : aint; reg : TRegister); @@ -824,7 +831,7 @@ unit cgx86; A_MOVSS, A_MOVSD, A_MOVQ: - add_move_instruction(instr); + add_move_instruction(instr); end; list.concat(instr); end;