summaryrefslogtreecommitdiff
path: root/compiler/mips/hlcgcpu.pas
diff options
context:
space:
mode:
authorpierre <pierre@3ad0048d-3df7-0310-abae-a5850022a9f2>2013-02-01 21:16:58 +0000
committerpierre <pierre@3ad0048d-3df7-0310-abae-a5850022a9f2>2013-02-01 21:16:58 +0000
commit7bc2101f6bd3e8fc7216933fdc80c326e54dd85c (patch)
tree2995a96ab943833f58443bb54f2dd8ce22ed15e0 /compiler/mips/hlcgcpu.pas
parent55d034b5028a0df4f3a25c0bdd79c8e0d822edfb (diff)
downloadfpc-7bc2101f6bd3e8fc7216933fdc80c326e54dd85c.tar.gz
Avoid wrong code generation for a_call_name if we create pic code
git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@23560 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'compiler/mips/hlcgcpu.pas')
-rw-r--r--compiler/mips/hlcgcpu.pas30
1 files changed, 20 insertions, 10 deletions
diff --git a/compiler/mips/hlcgcpu.pas b/compiler/mips/hlcgcpu.pas
index cc50cd6452..b98a15379e 100644
--- a/compiler/mips/hlcgcpu.pas
+++ b/compiler/mips/hlcgcpu.pas
@@ -49,6 +49,7 @@ implementation
uses
aasmtai,
cutils,
+ globals,
cgobj,
cpubase,
cgcpu;
@@ -59,16 +60,25 @@ implementation
begin
if pd.proccalloption=pocall_cdecl then
begin
- { Use $gp/$t9 registers as the code might be in a shared library }
- reference_reset(ref,sizeof(aint));
- ref.symbol:=current_asmdata.RefAsmSymbol('_gp');
- list.concat(tai_comment.create(strpnew('Using PIC code for a_call_name')));
- cg.a_loadaddr_ref_reg(list,ref,NR_GP);
- reference_reset(ref,sizeof(aint));
- ref.symbol:=current_asmdata.RefAsmSymbol(s);
- ref.base:=NR_GP;
- ref.refaddr:=addr_pic_call16;
- cg.a_loadaddr_ref_reg(list,ref,NR_PIC_FUNC);
+ if (cs_create_pic in current_settings.moduleswitches) then
+ begin
+ reference_reset(ref,sizeof(aint));
+ ref.symbol:=current_asmdata.RefAsmSymbol(s);
+ cg.a_loadaddr_ref_reg(list,ref,NR_PIC_FUNC);
+ end
+ else
+ begin
+ { Use $gp/$t9 registers as the code might be in a shared library }
+ reference_reset(ref,sizeof(aint));
+ ref.symbol:=current_asmdata.RefAsmSymbol('_gp');
+ list.concat(tai_comment.create(strpnew('Using PIC code for a_call_name')));
+ cg.a_loadaddr_ref_reg(list,ref,NR_GP);
+ reference_reset(ref,sizeof(aint));
+ ref.symbol:=current_asmdata.RefAsmSymbol(s);
+ ref.base:=NR_GP;
+ ref.refaddr:=addr_pic_call16;
+ cg.a_loadaddr_ref_reg(list,ref,NR_PIC_FUNC);
+ end;
cg.a_call_reg(list,NR_PIC_FUNC);
end
else