File 0015-Fix-remaining-unwind-values-on-vm-frames.patch of Package lua51-luajit

From 5866b0a1ed6abe9eab60332905eca2bbc80f1478 Mon Sep 17 00:00:00 2001
From: Gustavo Serra Scalet <gustavo.scalet@eldorado.org.br>
Date: Mon, 4 Sep 2017 10:51:51 -0300
Subject: [PATCH 15/15] Fix remaining unwind values on vm frames

Despite unwind working for vm frames, the change sent before was not
fully correct. By analysing the DWARF code with
"readelf --debug-dump=frames luajit" I noticed it was not well formated.
---
 src/vm_ppc64.dasc | 41 +++++++++++++++++++++--------------------
 1 file changed, 21 insertions(+), 20 deletions(-)

diff --git a/src/vm_ppc64.dasc b/src/vm_ppc64.dasc
index b92de564f4d0..dde11b954540 100644
--- a/src/vm_ppc64.dasc
+++ b/src/vm_ppc64.dasc
@@ -4390,39 +4390,40 @@ static void emit_asm_debug(BuildCtx *ctx)
 	"\t.long 0xffffffff\n"		/* CIE_Id */
 	"\t.byte 0x1\n"			/* Version */
 	"\t.string \"\"\n"		/* augmentation */
-	"\t.uleb128 0x1\n"		/* code_alignment_factor */
+	"\t.uleb128 4\n"		/* code_alignment_factor */
 	"\t.sleb128 -8\n"		/* data_alignment_factor */
 	"\t.byte 65\n"			/* return_address_register (LR) */
-	"\t.byte 0xc\n\t.uleb128 1\n\t.uleb128 %d\n"	/* DW_CFA_def_cfa */
-	"\t.align 2\n"
-	".LECIE0:\n\n",
-        CFRAME_SIZE);
+	/* DW_CFA_def_cfa */
+	"\t.byte 0xc\n\t.uleb128 1\n\t.uleb128 0\n"
+	"\t.align 3\n"
+	".LECIE0:\n\n");
     fprintf(ctx->fp,
 	".LSFDE0:\n"			/* Frame Description Entry (FDE) */
 	"\t.long .LEFDE0-.LASFDE0\n"	/* length */
 	".LASFDE0:\n"
 	"\t.long .Lframe0\n"		/* CIE_ptr */
-	"\t.long .Lbegin\n"		/* initial_location */
-	"\t.long %d\n"			/* address_range */
-	"\t.byte 0xe\n\t.uleb128 %d\n"	/* DW_CFA_def_cfa_offset */
-	/* DW_CFA_offset_extended_sf (TOC) */
-	"\t.byte 0x11\n\t.uleb128 2\n\t.sleb128 %d\n"
+	"\t.quad .Lbegin\n"		/* initial_location */
+	"\t.quad %d\n"			/* address_range */
 
-        /* DW_CFA_val_expression of size 9 for LR register */
-	"\t.byte 0x16\n\t.uleb128 65\n\t.uleb128 9\n"
-	"\t.byte 0x70\n\t.uleb128 1\n\t.sleb128 0\n"    /* DW_OP_breg */
-	"\t.byte 0x06\n"                /* DW_OP_deref */
-	"\t.byte 0x11\n\t.sleb128 16\n" /* DW_OP_consts */
-	"\t.byte 0x22\n"                /* DW_OP_plus */
-	"\t.byte 0x06\n",               /* DW_OP_deref */
-	(int)ctx->codesz, CFRAME_SIZE, 24 / -8);
+	/* DW_CFA_def_cfa_offset */
+	"\t.byte 0xe\n\t.uleb128 %d\n"
+
+	/* DW_CFA_offset_extended_sf $lr */
+	"\t.byte 0x11\n\t.uleb128 65\n\t.sleb128 %d\n"
+
+	/* DW_CFA_offset (TOC) */
+	"\t.byte 0x82\n\t.uleb128 %d\n",
+
+	(int)ctx->codesz, CFRAME_SIZE, 16/-8, (24-400)/-8);
     for (i = 14; i <= 31; i++)
       fprintf(ctx->fp,
 	"\t.byte %d\n\t.uleb128 %d\n"	/* DW_CFA_offset from r14 to r31 */
 	"\t.byte %d\n\t.uleb128 %d\n",	/* DW_CFA_offset from f14 to f31 */
-	0x80+i, 38+2*(31-i), 0x80+32+i, 2+2*(31-i));
+	// SAVE_GPR_ SAVE_FPR_
+	0x80+i, (112-400)/-8 + 14-i, 0x80+32+i, (256-400)/-8 + 14-i);
+
     fprintf(ctx->fp,
-	"\t.align 2\n"
+	"\t.align 3\n"
 	".LEFDE0:\n\n");
     break;
   default:
-- 
2.20.1