diff options
author | Mike Pall <mike> | 2010-03-07 14:29:04 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2010-03-07 14:29:04 +0100 |
commit | b4299256cd895df5323efaaf52e2aa11c504b669 (patch) | |
tree | 6cee8faf0545c3f1b262574e47d654892fa25e20 /src/buildvm_x86.h | |
parent | 88244c63726a3282d3bf0e92eff309fa57f439f8 (diff) | |
download | luajit-b4299256cd895df5323efaaf52e2aa11c504b669.tar.gz luajit-b4299256cd895df5323efaaf52e2aa11c504b669.tar.bz2 luajit-b4299256cd895df5323efaaf52e2aa11c504b669.zip |
Fix unwind info for assembler part for OSX.
Diffstat (limited to 'src/buildvm_x86.h')
-rw-r--r-- | src/buildvm_x86.h | 97 |
1 files changed, 61 insertions, 36 deletions
diff --git a/src/buildvm_x86.h b/src/buildvm_x86.h index 35e3893e..eaf6aafe 100644 --- a/src/buildvm_x86.h +++ b/src/buildvm_x86.h | |||
@@ -2503,13 +2503,17 @@ static void emit_asm_debug(BuildCtx *ctx) | |||
2503 | "\t.align " SZPTR "\n" | 2503 | "\t.align " SZPTR "\n" |
2504 | "LEFDE1:\n\n", LJ_32 ? "_" : "", (int)ctx->codesz, CFRAME_SIZE); | 2504 | "LEFDE1:\n\n", LJ_32 ? "_" : "", (int)ctx->codesz, CFRAME_SIZE); |
2505 | break; | 2505 | break; |
2506 | case BUILD_machasm: | 2506 | /* Mental note: never let Apple design an assembler. |
2507 | ** Or a linker. Or a plastic case. But I digress. | ||
2508 | */ | ||
2509 | case BUILD_machasm: { | ||
2510 | int i; | ||
2507 | fprintf(ctx->fp, "\t.section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support\n"); | 2511 | fprintf(ctx->fp, "\t.section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support\n"); |
2508 | fprintf(ctx->fp, | 2512 | fprintf(ctx->fp, |
2509 | "EH_frame1:\n" | 2513 | "EH_frame1:\n" |
2510 | "\t.set L$set$0,LECIE1-LSCIE1\n" | 2514 | "\t.set L$set$x,LECIEX-LSCIEX\n" |
2511 | "\t.long L$set$0\n" | 2515 | "\t.long L$set$x\n" |
2512 | "LSCIE1:\n" | 2516 | "LSCIEX:\n" |
2513 | "\t.long 0\n" | 2517 | "\t.long 0\n" |
2514 | "\t.byte 0x1\n" | 2518 | "\t.byte 0x1\n" |
2515 | "\t.ascii \"zPR\\0\"\n" | 2519 | "\t.ascii \"zPR\\0\"\n" |
@@ -2520,51 +2524,72 @@ static void emit_asm_debug(BuildCtx *ctx) | |||
2520 | "\t.byte 0x9b\n" /* indirect|pcrel|sdata4 */ | 2524 | "\t.byte 0x9b\n" /* indirect|pcrel|sdata4 */ |
2521 | #if LJ_64 | 2525 | #if LJ_64 |
2522 | "\t.long _lj_err_unwind_dwarf+4@GOTPCREL\n" | 2526 | "\t.long _lj_err_unwind_dwarf+4@GOTPCREL\n" |
2523 | #else | ||
2524 | "\t.long L_lj_err_unwind_dwarf$non_lazy_ptr-.\n" | ||
2525 | #endif | ||
2526 | "\t.byte 0x1b\n" /* pcrel|sdata4 */ | 2527 | "\t.byte 0x1b\n" /* pcrel|sdata4 */ |
2527 | #if LJ_64 | ||
2528 | "\t.byte 0xc\n\t.byte " REG_SP "\n\t.byte " SZPTR "\n" | 2528 | "\t.byte 0xc\n\t.byte " REG_SP "\n\t.byte " SZPTR "\n" |
2529 | #else | 2529 | #else |
2530 | "\t.long L_lj_err_unwind_dwarf$non_lazy_ptr-.\n" | ||
2531 | "\t.byte 0x1b\n" /* pcrel|sdata4 */ | ||
2530 | "\t.byte 0xc\n\t.byte 0x5\n\t.byte 0x4\n" /* esp=5 on 32 bit MACH-O. */ | 2532 | "\t.byte 0xc\n\t.byte 0x5\n\t.byte 0x4\n" /* esp=5 on 32 bit MACH-O. */ |
2531 | #endif | 2533 | #endif |
2532 | "\t.byte 0x80+" REG_RA "\n\t.byte 0x1\n" | 2534 | "\t.byte 0x80+" REG_RA "\n\t.byte 0x1\n" |
2533 | "\t.align " BSZPTR "\n" | 2535 | "\t.align " BSZPTR "\n" |
2534 | "LECIE1:\n\n"); | 2536 | "LECIEX:\n\n"); |
2535 | fprintf(ctx->fp, | 2537 | for (i = 0; i < ctx->nsym; i++) { |
2536 | "_lj_vm_asm_begin.eh:\n" | 2538 | int pi = ctx->perm[i]; |
2537 | "LSFDE1:\n" | 2539 | int ni = ctx->perm[i+1]; |
2538 | "\t.set L$set$1,LEFDE1-LASFDE1\n" | 2540 | int size = ctx->sym_ofs[ni] - ctx->sym_ofs[pi]; |
2539 | "\t.long L$set$1\n" | 2541 | if (ctx->sym_ofs[pi] >= 0 && size > 0) { |
2540 | "LASFDE1:\n" | 2542 | char name[80]; |
2541 | "\t.long LASFDE1-EH_frame1\n" | 2543 | if (pi >= ctx->npc) { |
2542 | "\t.long _lj_vm_asm_begin-.\n" | 2544 | char *p; |
2543 | "\t.long %d\n" | 2545 | sprintf(name, "_" LABEL_PREFIX "%s", ctx->globnames[pi - ctx->npc]); |
2544 | "\t.byte 0\n" /* augmentation length */ | 2546 | p = strchr(name, '@'); if (p) *p = '\0'; |
2545 | "\t.byte 0xe\n\t.byte %d\n" /* def_cfa_offset */ | 2547 | #if LJ_HASJIT |
2548 | } else { | ||
2549 | #else | ||
2550 | } else if (!(pi == BC_JFORI || pi == BC_JFORL || pi == BC_JITERL || | ||
2551 | pi == BC_JLOOP || pi == BC_IFORL || pi == BC_IITERL || | ||
2552 | pi == BC_ILOOP)) { | ||
2553 | #endif | ||
2554 | sprintf(name, "_" LABEL_PREFIX_BC "%s", bc_names[pi]); | ||
2555 | } | ||
2556 | fprintf(ctx->fp, | ||
2557 | "%s.eh:\n" | ||
2558 | "LSFDE%d:\n" | ||
2559 | "\t.set L$set$%d,LEFDE%d-LASFDE%d\n" | ||
2560 | "\t.long L$set$%d\n" | ||
2561 | "LASFDE%d:\n" | ||
2562 | "\t.long LASFDE%d-EH_frame1\n" | ||
2563 | "\t.long %s-.\n" | ||
2564 | "\t.long %d\n" | ||
2565 | "\t.byte 0\n" /* augmentation length */ | ||
2566 | "\t.byte 0xe\n\t.byte %d\n" /* def_cfa_offset */ | ||
2546 | #if LJ_64 | 2567 | #if LJ_64 |
2547 | "\t.byte 0x86\n\t.uleb128 0x2\n" /* offset rbp */ | 2568 | "\t.byte 0x86\n\t.byte 0x2\n" /* offset rbp */ |
2548 | "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset rbx */ | 2569 | "\t.byte 0x83\n\t.byte 0x3\n" /* offset rbx */ |
2549 | "\t.byte 0x8f\n\t.uleb128 0x4\n" /* offset r15 */ | 2570 | "\t.byte 0x8f\n\t.byte 0x4\n" /* offset r15 */ |
2550 | "\t.byte 0x8e\n\t.uleb128 0x5\n" /* offset r14 */ | 2571 | "\t.byte 0x8e\n\t.byte 0x5\n" /* offset r14 */ |
2551 | #else | 2572 | #else |
2552 | "\t.byte 0x84\n\t.byte 0x2\n" /* offset ebp (4 for MACH-O)*/ | 2573 | "\t.byte 0x84\n\t.byte 0x2\n" /* offset ebp (4 for MACH-O)*/ |
2553 | "\t.byte 0x87\n\t.byte 0x3\n" /* offset edi */ | 2574 | "\t.byte 0x87\n\t.byte 0x3\n" /* offset edi */ |
2554 | "\t.byte 0x86\n\t.byte 0x4\n" /* offset esi */ | 2575 | "\t.byte 0x86\n\t.byte 0x4\n" /* offset esi */ |
2555 | "\t.byte 0x83\n\t.byte 0x5\n" /* offset ebx */ | 2576 | "\t.byte 0x83\n\t.byte 0x5\n" /* offset ebx */ |
2556 | #endif | 2577 | #endif |
2557 | "\t.align " BSZPTR "\n" | 2578 | "\t.align " BSZPTR "\n" |
2558 | "LEFDE1:\n\n", (int)ctx->codesz, CFRAME_SIZE); | 2579 | "LEFDE%d:\n\n", |
2580 | name, i, i, i, i, i, i, i, name, size, CFRAME_SIZE, i); | ||
2581 | } | ||
2582 | } | ||
2559 | #if LJ_64 | 2583 | #if LJ_64 |
2560 | fprintf(ctx->fp, "\t.subsections_via_symbols\n"); | 2584 | fprintf(ctx->fp, "\t.subsections_via_symbols\n"); |
2561 | #else | 2585 | #else |
2562 | fprintf(ctx->fp, | 2586 | fprintf(ctx->fp, |
2563 | "\t.non_lazy_symbol_pointer\n" | 2587 | "\t.non_lazy_symbol_pointer\n" |
2564 | "L_lj_err_unwind_dwarf$non_lazy_ptr:\n" | 2588 | "L_lj_err_unwind_dwarf$non_lazy_ptr:\n" |
2565 | ".indirect_symbol _lj_err_unwind_dwarf\n" | 2589 | ".indirect_symbol _lj_err_unwind_dwarf\n" |
2566 | ".long 0\n"); | 2590 | ".long 0\n"); |
2567 | #endif | 2591 | #endif |
2592 | } | ||
2568 | break; | 2593 | break; |
2569 | default: /* Difficult for other modes. */ | 2594 | default: /* Difficult for other modes. */ |
2570 | break; | 2595 | break; |