ソースを参照

ARM: Add frame unwind info for assembler part.

Mike Pall 14 年 前
コミット
3bcb48c6a1
1 ファイル変更37 行追加1 行削除
  1. 37 1
      src/buildvm_arm.dasc

+ 37 - 1
src/buildvm_arm.dasc

@@ -1004,6 +1004,42 @@ static int build_backend(BuildCtx *ctx)
 /* Emit pseudo frame-info for all assembler functions. */
 /* Emit pseudo frame-info for all assembler functions. */
 static void emit_asm_debug(BuildCtx *ctx)
 static void emit_asm_debug(BuildCtx *ctx)
 {
 {
-  UNUSED(ctx);  /* NYI */
+  int i;
+  switch (ctx->mode) {
+  case BUILD_elfasm:
+    fprintf(ctx->fp, "\t.section .debug_frame,\"\",%%progbits\n");
+    fprintf(ctx->fp,
+	".Lframe0:\n"
+	"\t.long .LECIE0-.LSCIE0\n"
+	".LSCIE0:\n"
+	"\t.long 0xffffffff\n"
+	"\t.byte 0x1\n"
+	"\t.string \"\"\n"
+	"\t.uleb128 0x1\n"
+	"\t.sleb128 -4\n"
+	"\t.byte 0xe\n"				/* Return address is in lr. */
+	"\t.byte 0xc\n\t.uleb128 0xd\n\t.uleb128 0\n"	/* def_cfa sp */
+	"\t.align 2\n"
+	".LECIE0:\n\n");
+    fprintf(ctx->fp,
+	".LSFDE0:\n"
+	"\t.long .LEFDE0-.LASFDE0\n"
+	".LASFDE0:\n"
+	"\t.long .Lframe0\n"
+	"\t.long .Lbegin\n"
+	"\t.long %d\n"
+	"\t.byte 0xe\n\t.uleb128 %d\n"		/* def_cfa_offset */
+	"\t.byte 0x8e\n\t.uleb128 1\n",		/* Restore lr. */
+	(int)ctx->codesz, CFRAME_SIZE);
+    for (i = 11; i >= 4; i--)  /* Restore r4-r11. */
+      fprintf(ctx->fp, "\t.byte %d\n\t.uleb128 %d\n", 0x80+i, 2+(11-i));
+    fprintf(ctx->fp,
+	"\t.align 2\n"
+	".LEFDE0:\n\n");
+    /* NYI: emit ARM.exidx. */
+    break;
+  default:
+    break;
+  }
 }
 }