]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
ARM64: Restore fp before sp in C stack unwinders.
authorMike Pall <mike>
Sun, 8 Oct 2023 19:17:43 +0000 (21:17 +0200)
committerMike Pall <mike>
Sun, 8 Oct 2023 19:17:43 +0000 (21:17 +0200)
Thanks to Peter Cawley. #1096

src/host/buildvm_peobj.c
src/vm_arm64.dasc

index 7ce3b05acf5f2d596ab46a485b667f233833599b..8f04c496dfae9cb41ff2bc41c360098f378e4871 100644 (file)
@@ -373,11 +373,12 @@ void emit_peobj(BuildCtx *ctx)
 
     /* Unwind codes for .text section with handler. */
     p = uwc;
+    CADD_FP(192);              /* +2 */
     CSAVE_REGS(19, 28, 176);   /* +5*2 */
     CSAVE_FREGS(8, 15, 96);    /* +4*2 */
     CSAVE_FPLR(192);           /* +1 */
     CALLOC_S(208);             /* +1 */
-    CEND_ALIGN;                        /* +1 +3 -> 24 */
+    CEND_ALIGN;                        /* +1 +1 -> 24 */
 
     u32 = ((24u >> 2) << 27) | (1u << 20) | (fcofs >> 2);
     owrite(ctx, &u32, 4);
index 3044a8ac4ecb8be8db39233ef0c0dfedfedc82a5..269736861b0cc94628db71f8157de05d989dd353 100644 (file)
@@ -430,6 +430,7 @@ static void build_subroutines(BuildCtx *ctx)
   |
   |->vm_unwind_c:                      // Unwind C stack, return from vm_pcall.
   |  // (void *cframe, int errcode)
+  |  add fp, CARG1, # SAVE_FP_LR_
   |  mov sp, CARG1
   |  mov CRET1, CARG2
   |  ldr L, SAVE_L
@@ -441,7 +442,8 @@ static void build_subroutines(BuildCtx *ctx)
   |
   |->vm_unwind_ff:                     // Unwind C stack, return from ff pcall.
   |  // (void *cframe)
-  |  and sp, CARG1, #CFRAME_RAWMASK
+  |  add fp, CARG1, # SAVE_FP_LR_
+  |  mov sp, CARG1
   |  ldr L, SAVE_L
   |    movz TISNUM, #(LJ_TISNUM>>1)&0xffff, lsl #48
   |    movz TISNUMhi, #(LJ_TISNUM>>1)&0xffff, lsl #16