* ARM: Fixed GOT init when optimization is off.
authoryury <yury@3ad0048d-3df7-0310-abae-a5850022a9f2>
Wed, 16 Sep 2015 21:30:20 +0000 (21:30 +0000)
committerGraham Inggs <ginggs@debian.org>
Wed, 8 Feb 2017 09:53:35 +0000 (09:53 +0000)
git-svn-id: http://svn.freepascal.org/svn/ fpc/trunk@31728 3ad0048d-3df7-0310-abae-a5850022a9f2

Gbp-Pq: Name ARM-Fixed-GOT-init-when-optimization-is-off.patch

fpcsrc/compiler/arm/cgcpu.pas

index d174743a43565abba95238a15e48c7ce80682fde..2e275155e62a66eb0aa03896c720e5ef2d49cf78 100644 (file)
@@ -2284,19 +2284,14 @@ unit cgcpu;
             current_asmdata.getaddrlabel(l);
             current_procinfo.aktlocaldata.concat(tai_const.Create_rel_sym_offset(aitconst_32bit,l,current_asmdata.RefAsmSymbol('_GLOBAL_OFFSET_TABLE_'),-8));
             cg.a_label(list,l);
-            if cs_opt_regvar in current_settings.optimizerswitches then
-              begin
-                {
-                  When regvars are used, it is needed to perform GOT calculations using the scratch register R12
-                  and then MOV the result to the GOT register. Otherwise the register allocator will use
-                  register R0 as temp to perform calculations in case if a procedure uses all available registers.
-                  It leads to corruption of R0 which is normally holds a value of the first procedure parameter.
-                }
-                list.concat(Taicpu.op_reg_reg_reg(A_ADD,NR_R12,NR_PC,NR_R12));
-                list.concat(Taicpu.op_reg_reg(A_MOV,current_procinfo.got,NR_R12));
-              end
-            else
-              list.concat(Taicpu.op_reg_reg_reg(A_ADD,current_procinfo.got,NR_PC,NR_R12));
+            {
+              It is needed to perform GOT calculations using the scratch register R12
+              and then MOV the result to the GOT register. Otherwise the register allocator will use
+              register R0 as temp to perform calculations in case if a procedure uses all available registers.
+              It leads to corruption of R0 which is normally holds a value of the first procedure parameter.
+            }
+            list.concat(Taicpu.op_reg_reg_reg(A_ADD,NR_R12,NR_PC,NR_R12));
+            list.concat(Taicpu.op_reg_reg(A_MOV,current_procinfo.got,NR_R12));
             a_reg_dealloc(list,NR_R12);
           end;
       end;