浏览代码

Avoid wrong code generation for a_call_name if we create pic code

git-svn-id: trunk@23560 -
pierre 12 年之前
父节点
当前提交
899951577a
共有 1 个文件被更改,包括 20 次插入10 次删除
  1. 20 10
      compiler/mips/hlcgcpu.pas

+ 20 - 10
compiler/mips/hlcgcpu.pas

@@ -49,6 +49,7 @@ implementation
   uses
   uses
     aasmtai,
     aasmtai,
     cutils,
     cutils,
+    globals,
     cgobj,
     cgobj,
     cpubase,
     cpubase,
     cgcpu;
     cgcpu;
@@ -59,16 +60,25 @@ implementation
     begin
     begin
       if pd.proccalloption=pocall_cdecl then
       if pd.proccalloption=pocall_cdecl then
         begin
         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);
           cg.a_call_reg(list,NR_PIC_FUNC);
         end
         end
       else
       else