ARM64: Restore fp before sp in C stack unwinders.

Thanks to Peter Cawley. #1096
This commit is contained in:
Mike Pall 2023-10-08 21:17:43 +02:00
parent becf5cc65d
commit 007e4dce13
2 changed files with 5 additions and 2 deletions

View File

@ -373,11 +373,12 @@ void emit_peobj(BuildCtx *ctx)
/* Unwind codes for .text section with handler. */ /* Unwind codes for .text section with handler. */
p = uwc; p = uwc;
CADD_FP(192); /* +2 */
CSAVE_REGS(19, 28, 176); /* +5*2 */ CSAVE_REGS(19, 28, 176); /* +5*2 */
CSAVE_FREGS(8, 15, 96); /* +4*2 */ CSAVE_FREGS(8, 15, 96); /* +4*2 */
CSAVE_FPLR(192); /* +1 */ CSAVE_FPLR(192); /* +1 */
CALLOC_S(208); /* +1 */ CALLOC_S(208); /* +1 */
CEND_ALIGN; /* +1 +3 -> 24 */ CEND_ALIGN; /* +1 +1 -> 24 */
u32 = ((24u >> 2) << 27) | (1u << 20) | (fcofs >> 2); u32 = ((24u >> 2) << 27) | (1u << 20) | (fcofs >> 2);
owrite(ctx, &u32, 4); owrite(ctx, &u32, 4);

View File

@ -430,6 +430,7 @@ static void build_subroutines(BuildCtx *ctx)
| |
|->vm_unwind_c: // Unwind C stack, return from vm_pcall. |->vm_unwind_c: // Unwind C stack, return from vm_pcall.
| // (void *cframe, int errcode) | // (void *cframe, int errcode)
| add fp, CARG1, # SAVE_FP_LR_
| mov sp, CARG1 | mov sp, CARG1
| mov CRET1, CARG2 | mov CRET1, CARG2
| ldr L, SAVE_L | ldr L, SAVE_L
@ -441,7 +442,8 @@ static void build_subroutines(BuildCtx *ctx)
| |
|->vm_unwind_ff: // Unwind C stack, return from ff pcall. |->vm_unwind_ff: // Unwind C stack, return from ff pcall.
| // (void *cframe) | // (void *cframe)
| and sp, CARG1, #CFRAME_RAWMASK | add fp, CARG1, # SAVE_FP_LR_
| mov sp, CARG1
| ldr L, SAVE_L | ldr L, SAVE_L
| movz TISNUM, #(LJ_TISNUM>>1)&0xffff, lsl #48 | movz TISNUM, #(LJ_TISNUM>>1)&0xffff, lsl #48
| movz TISNUMhi, #(LJ_TISNUM>>1)&0xffff, lsl #16 | movz TISNUMhi, #(LJ_TISNUM>>1)&0xffff, lsl #16