aboutsummaryrefslogtreecommitdiff
path: root/src/buildvm_x86.dasc
diff options
context:
space:
mode:
authorMike Pall <mike>2010-03-07 14:29:04 +0100
committerMike Pall <mike>2010-03-07 14:29:04 +0100
commitb4299256cd895df5323efaaf52e2aa11c504b669 (patch)
tree6cee8faf0545c3f1b262574e47d654892fa25e20 /src/buildvm_x86.dasc
parent88244c63726a3282d3bf0e92eff309fa57f439f8 (diff)
downloadluajit-b4299256cd895df5323efaaf52e2aa11c504b669.tar.gz
luajit-b4299256cd895df5323efaaf52e2aa11c504b669.tar.bz2
luajit-b4299256cd895df5323efaaf52e2aa11c504b669.zip
Fix unwind info for assembler part for OSX.
Diffstat (limited to 'src/buildvm_x86.dasc')
-rw-r--r--src/buildvm_x86.dasc97
1 files changed, 61 insertions, 36 deletions
diff --git a/src/buildvm_x86.dasc b/src/buildvm_x86.dasc
index 3ad0d812..4a2194a5 100644
--- a/src/buildvm_x86.dasc
+++ b/src/buildvm_x86.dasc
@@ -5093,13 +5093,17 @@ static void emit_asm_debug(BuildCtx *ctx)
5093 "\t.align " SZPTR "\n" 5093 "\t.align " SZPTR "\n"
5094 "LEFDE1:\n\n", LJ_32 ? "_" : "", (int)ctx->codesz, CFRAME_SIZE); 5094 "LEFDE1:\n\n", LJ_32 ? "_" : "", (int)ctx->codesz, CFRAME_SIZE);
5095 break; 5095 break;
5096 case BUILD_machasm: 5096 /* Mental note: never let Apple design an assembler.
5097 ** Or a linker. Or a plastic case. But I digress.
5098 */
5099 case BUILD_machasm: {
5100 int i;
5097 fprintf(ctx->fp, "\t.section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support\n"); 5101 fprintf(ctx->fp, "\t.section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support\n");
5098 fprintf(ctx->fp, 5102 fprintf(ctx->fp,
5099 "EH_frame1:\n" 5103 "EH_frame1:\n"
5100 "\t.set L$set$0,LECIE1-LSCIE1\n" 5104 "\t.set L$set$x,LECIEX-LSCIEX\n"
5101 "\t.long L$set$0\n" 5105 "\t.long L$set$x\n"
5102 "LSCIE1:\n" 5106 "LSCIEX:\n"
5103 "\t.long 0\n" 5107 "\t.long 0\n"
5104 "\t.byte 0x1\n" 5108 "\t.byte 0x1\n"
5105 "\t.ascii \"zPR\\0\"\n" 5109 "\t.ascii \"zPR\\0\"\n"
@@ -5110,51 +5114,72 @@ static void emit_asm_debug(BuildCtx *ctx)
5110 "\t.byte 0x9b\n" /* indirect|pcrel|sdata4 */ 5114 "\t.byte 0x9b\n" /* indirect|pcrel|sdata4 */
5111#if LJ_64 5115#if LJ_64
5112 "\t.long _lj_err_unwind_dwarf+4@GOTPCREL\n" 5116 "\t.long _lj_err_unwind_dwarf+4@GOTPCREL\n"
5113#else
5114 "\t.long L_lj_err_unwind_dwarf$non_lazy_ptr-.\n"
5115#endif
5116 "\t.byte 0x1b\n" /* pcrel|sdata4 */ 5117 "\t.byte 0x1b\n" /* pcrel|sdata4 */
5117#if LJ_64
5118 "\t.byte 0xc\n\t.byte " REG_SP "\n\t.byte " SZPTR "\n" 5118 "\t.byte 0xc\n\t.byte " REG_SP "\n\t.byte " SZPTR "\n"
5119#else 5119#else
5120 "\t.long L_lj_err_unwind_dwarf$non_lazy_ptr-.\n"
5121 "\t.byte 0x1b\n" /* pcrel|sdata4 */
5120 "\t.byte 0xc\n\t.byte 0x5\n\t.byte 0x4\n" /* esp=5 on 32 bit MACH-O. */ 5122 "\t.byte 0xc\n\t.byte 0x5\n\t.byte 0x4\n" /* esp=5 on 32 bit MACH-O. */
5121#endif 5123#endif
5122 "\t.byte 0x80+" REG_RA "\n\t.byte 0x1\n" 5124 "\t.byte 0x80+" REG_RA "\n\t.byte 0x1\n"
5123 "\t.align " BSZPTR "\n" 5125 "\t.align " BSZPTR "\n"
5124 "LECIE1:\n\n"); 5126 "LECIEX:\n\n");
5125 fprintf(ctx->fp, 5127 for (i = 0; i < ctx->nsym; i++) {
5126 "_lj_vm_asm_begin.eh:\n" 5128 int pi = ctx->perm[i];
5127 "LSFDE1:\n" 5129 int ni = ctx->perm[i+1];
5128 "\t.set L$set$1,LEFDE1-LASFDE1\n" 5130 int size = ctx->sym_ofs[ni] - ctx->sym_ofs[pi];
5129 "\t.long L$set$1\n" 5131 if (ctx->sym_ofs[pi] >= 0 && size > 0) {
5130 "LASFDE1:\n" 5132 char name[80];
5131 "\t.long LASFDE1-EH_frame1\n" 5133 if (pi >= ctx->npc) {
5132 "\t.long _lj_vm_asm_begin-.\n" 5134 char *p;
5133 "\t.long %d\n" 5135 sprintf(name, "_" LABEL_PREFIX "%s", ctx->globnames[pi - ctx->npc]);
5134 "\t.byte 0\n" /* augmentation length */ 5136 p = strchr(name, '@'); if (p) *p = '\0';
5135 "\t.byte 0xe\n\t.byte %d\n" /* def_cfa_offset */ 5137#if LJ_HASJIT
5138 } else {
5139#else
5140 } else if (!(pi == BC_JFORI || pi == BC_JFORL || pi == BC_JITERL ||
5141 pi == BC_JLOOP || pi == BC_IFORL || pi == BC_IITERL ||
5142 pi == BC_ILOOP)) {
5143#endif
5144 sprintf(name, "_" LABEL_PREFIX_BC "%s", bc_names[pi]);
5145 }
5146 fprintf(ctx->fp,
5147 "%s.eh:\n"
5148 "LSFDE%d:\n"
5149 "\t.set L$set$%d,LEFDE%d-LASFDE%d\n"
5150 "\t.long L$set$%d\n"
5151 "LASFDE%d:\n"
5152 "\t.long LASFDE%d-EH_frame1\n"
5153 "\t.long %s-.\n"
5154 "\t.long %d\n"
5155 "\t.byte 0\n" /* augmentation length */
5156 "\t.byte 0xe\n\t.byte %d\n" /* def_cfa_offset */
5136#if LJ_64 5157#if LJ_64
5137 "\t.byte 0x86\n\t.uleb128 0x2\n" /* offset rbp */ 5158 "\t.byte 0x86\n\t.byte 0x2\n" /* offset rbp */
5138 "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset rbx */ 5159 "\t.byte 0x83\n\t.byte 0x3\n" /* offset rbx */
5139 "\t.byte 0x8f\n\t.uleb128 0x4\n" /* offset r15 */ 5160 "\t.byte 0x8f\n\t.byte 0x4\n" /* offset r15 */
5140 "\t.byte 0x8e\n\t.uleb128 0x5\n" /* offset r14 */ 5161 "\t.byte 0x8e\n\t.byte 0x5\n" /* offset r14 */
5141#else 5162#else
5142 "\t.byte 0x84\n\t.byte 0x2\n" /* offset ebp (4 for MACH-O)*/ 5163 "\t.byte 0x84\n\t.byte 0x2\n" /* offset ebp (4 for MACH-O)*/
5143 "\t.byte 0x87\n\t.byte 0x3\n" /* offset edi */ 5164 "\t.byte 0x87\n\t.byte 0x3\n" /* offset edi */
5144 "\t.byte 0x86\n\t.byte 0x4\n" /* offset esi */ 5165 "\t.byte 0x86\n\t.byte 0x4\n" /* offset esi */
5145 "\t.byte 0x83\n\t.byte 0x5\n" /* offset ebx */ 5166 "\t.byte 0x83\n\t.byte 0x5\n" /* offset ebx */
5146#endif 5167#endif
5147 "\t.align " BSZPTR "\n" 5168 "\t.align " BSZPTR "\n"
5148 "LEFDE1:\n\n", (int)ctx->codesz, CFRAME_SIZE); 5169 "LEFDE%d:\n\n",
5170 name, i, i, i, i, i, i, i, name, size, CFRAME_SIZE, i);
5171 }
5172 }
5149#if LJ_64 5173#if LJ_64
5150 fprintf(ctx->fp, "\t.subsections_via_symbols\n"); 5174 fprintf(ctx->fp, "\t.subsections_via_symbols\n");
5151#else 5175#else
5152 fprintf(ctx->fp, 5176 fprintf(ctx->fp,
5153 "\t.non_lazy_symbol_pointer\n" 5177 "\t.non_lazy_symbol_pointer\n"
5154 "L_lj_err_unwind_dwarf$non_lazy_ptr:\n" 5178 "L_lj_err_unwind_dwarf$non_lazy_ptr:\n"
5155 ".indirect_symbol _lj_err_unwind_dwarf\n" 5179 ".indirect_symbol _lj_err_unwind_dwarf\n"
5156 ".long 0\n"); 5180 ".long 0\n");
5157#endif 5181#endif
5182 }
5158 break; 5183 break;
5159 default: /* Difficult for other modes. */ 5184 default: /* Difficult for other modes. */
5160 break; 5185 break;