From: yury Date: Wed, 16 Sep 2015 21:30:20 +0000 (+0000) Subject: * ARM: Fixed GOT init when optimization is off. X-Git-Tag: archive/raspbian/3.0.0+dfsg-11+rpi1^2~13 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=5b7e7cd01c51771b8f1b2cc9fd62d5f6bc5746cf;p=fpc.git * ARM: Fixed GOT init when optimization is off. 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 --- diff --git a/fpcsrc/compiler/arm/cgcpu.pas b/fpcsrc/compiler/arm/cgcpu.pas index d174743a..2e275155 100644 --- a/fpcsrc/compiler/arm/cgcpu.pas +++ b/fpcsrc/compiler/arm/cgcpu.pas @@ -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;