浏览代码

* patch by Jeppe Johansen to fix thumb2 epilog generation, resolves #18392

git-svn-id: trunk@17252 -
florian 14 年之前
父节点
当前提交
8bff2a0de4
共有 2 个文件被更改,包括 10 次插入2 次删除
  1. 2 0
      compiler/arm/cgcpu.pas
  2. 8 2
      rtl/arm/thumb2.inc

+ 2 - 0
compiler/arm/cgcpu.pas

@@ -3479,6 +3479,8 @@ unit cgcpu;
               begin
                 { restore int registers and return }
                 list.concat(taicpu.op_reg_reg(A_MOV, NR_STACK_POINTER_REG, NR_FRAME_POINTER_REG));
+                { Add 4 to SP to make it point to an "imaginary PC" which the paramanager assumes is there(for normal ARM) }
+                list.concat(taicpu.op_reg_const(A_ADD, NR_STACK_POINTER_REG, 4));
 
                 reference_reset(ref,4);
                 ref.index:=NR_STACK_POINTER_REG;

+ 8 - 2
rtl/arm/thumb2.inc

@@ -77,12 +77,18 @@ asm
 end;
 {$ENDIF not INTERNAL_BACKTRACE}
 
+{
+ Stack frame on Thumb2:
+  LR    <- FP
+  Old FP
+}
+
 {$define FPC_SYSTEM_HAS_GET_CALLER_ADDR}
 function get_caller_addr(framebp:pointer):pointer;assembler;
 asm
   movs r0,r0
   beq .Lg_a_null
-  ldr r0,[r0,#-4]
+  ldr r0,[r0]
 .Lg_a_null:
 end;
 
@@ -92,7 +98,7 @@ function get_caller_frame(framebp:pointer):pointer;assembler;
 asm
   movs r0,r0
   beq .Lgnf_null
-  ldr r0,[r0,#-12]
+  ldr r0,[r0,#-4]
 .Lgnf_null:
 end;