diff options
Diffstat (limited to 'src/buildvm_x64.h')
-rw-r--r-- | src/buildvm_x64.h | 97 |
1 files changed, 61 insertions, 36 deletions
diff --git a/src/buildvm_x64.h b/src/buildvm_x64.h index f19189f9..311679d2 100644 --- a/src/buildvm_x64.h +++ b/src/buildvm_x64.h | |||
@@ -2375,13 +2375,17 @@ static void emit_asm_debug(BuildCtx *ctx) | |||
2375 | "\t.align " SZPTR "\n" | 2375 | "\t.align " SZPTR "\n" |
2376 | "LEFDE1:\n\n", LJ_32 ? "_" : "", (int)ctx->codesz, CFRAME_SIZE); | 2376 | "LEFDE1:\n\n", LJ_32 ? "_" : "", (int)ctx->codesz, CFRAME_SIZE); |
2377 | break; | 2377 | break; |
2378 | case BUILD_machasm: | 2378 | /* Mental note: never let Apple design an assembler. |
2379 | ** Or a linker. Or a plastic case. But I digress. | ||
2380 | */ | ||
2381 | case BUILD_machasm: { | ||
2382 | int i; | ||
2379 | fprintf(ctx->fp, "\t.section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support\n"); | 2383 | fprintf(ctx->fp, "\t.section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support\n"); |
2380 | fprintf(ctx->fp, | 2384 | fprintf(ctx->fp, |
2381 | "EH_frame1:\n" | 2385 | "EH_frame1:\n" |
2382 | "\t.set L$set$0,LECIE1-LSCIE1\n" | 2386 | "\t.set L$set$x,LECIEX-LSCIEX\n" |
2383 | "\t.long L$set$0\n" | 2387 | "\t.long L$set$x\n" |
2384 | "LSCIE1:\n" | 2388 | "LSCIEX:\n" |
2385 | "\t.long 0\n" | 2389 | "\t.long 0\n" |
2386 | "\t.byte 0x1\n" | 2390 | "\t.byte 0x1\n" |
2387 | "\t.ascii \"zPR\\0\"\n" | 2391 | "\t.ascii \"zPR\\0\"\n" |
@@ -2392,51 +2396,72 @@ static void emit_asm_debug(BuildCtx *ctx) | |||
2392 | "\t.byte 0x9b\n" /* indirect|pcrel|sdata4 */ | 2396 | "\t.byte 0x9b\n" /* indirect|pcrel|sdata4 */ |
2393 | #if LJ_64 | 2397 | #if LJ_64 |
2394 | "\t.long _lj_err_unwind_dwarf+4@GOTPCREL\n" | 2398 | "\t.long _lj_err_unwind_dwarf+4@GOTPCREL\n" |
2395 | #else | ||
2396 | "\t.long L_lj_err_unwind_dwarf$non_lazy_ptr-.\n" | ||
2397 | #endif | ||
2398 | "\t.byte 0x1b\n" /* pcrel|sdata4 */ | 2399 | "\t.byte 0x1b\n" /* pcrel|sdata4 */ |
2399 | #if LJ_64 | ||
2400 | "\t.byte 0xc\n\t.byte " REG_SP "\n\t.byte " SZPTR "\n" | 2400 | "\t.byte 0xc\n\t.byte " REG_SP "\n\t.byte " SZPTR "\n" |
2401 | #else | 2401 | #else |
2402 | "\t.long L_lj_err_unwind_dwarf$non_lazy_ptr-.\n" | ||
2403 | "\t.byte 0x1b\n" /* pcrel|sdata4 */ | ||
2402 | "\t.byte 0xc\n\t.byte 0x5\n\t.byte 0x4\n" /* esp=5 on 32 bit MACH-O. */ | 2404 | "\t.byte 0xc\n\t.byte 0x5\n\t.byte 0x4\n" /* esp=5 on 32 bit MACH-O. */ |
2403 | #endif | 2405 | #endif |
2404 | "\t.byte 0x80+" REG_RA "\n\t.byte 0x1\n" | 2406 | "\t.byte 0x80+" REG_RA "\n\t.byte 0x1\n" |
2405 | "\t.align " BSZPTR "\n" | 2407 | "\t.align " BSZPTR "\n" |
2406 | "LECIE1:\n\n"); | 2408 | "LECIEX:\n\n"); |
2407 | fprintf(ctx->fp, | 2409 | for (i = 0; i < ctx->nsym; i++) { |
2408 | "_lj_vm_asm_begin.eh:\n" | 2410 | int pi = ctx->perm[i]; |
2409 | "LSFDE1:\n" | 2411 | int ni = ctx->perm[i+1]; |
2410 | "\t.set L$set$1,LEFDE1-LASFDE1\n" | 2412 | int size = ctx->sym_ofs[ni] - ctx->sym_ofs[pi]; |
2411 | "\t.long L$set$1\n" | 2413 | if (ctx->sym_ofs[pi] >= 0 && size > 0) { |
2412 | "LASFDE1:\n" | 2414 | char name[80]; |
2413 | "\t.long LASFDE1-EH_frame1\n" | 2415 | if (pi >= ctx->npc) { |
2414 | "\t.long _lj_vm_asm_begin-.\n" | 2416 | char *p; |
2415 | "\t.long %d\n" | 2417 | sprintf(name, "_" LABEL_PREFIX "%s", ctx->globnames[pi - ctx->npc]); |
2416 | "\t.byte 0\n" /* augmentation length */ | 2418 | p = strchr(name, '@'); if (p) *p = '\0'; |
2417 | "\t.byte 0xe\n\t.byte %d\n" /* def_cfa_offset */ | 2419 | #if LJ_HASJIT |
2420 | } else { | ||
2421 | #else | ||
2422 | } else if (!(pi == BC_JFORI || pi == BC_JFORL || pi == BC_JITERL || | ||
2423 | pi == BC_JLOOP || pi == BC_IFORL || pi == BC_IITERL || | ||
2424 | pi == BC_ILOOP)) { | ||
2425 | #endif | ||
2426 | sprintf(name, "_" LABEL_PREFIX_BC "%s", bc_names[pi]); | ||
2427 | } | ||
2428 | fprintf(ctx->fp, | ||
2429 | "%s.eh:\n" | ||
2430 | "LSFDE%d:\n" | ||
2431 | "\t.set L$set$%d,LEFDE%d-LASFDE%d\n" | ||
2432 | "\t.long L$set$%d\n" | ||
2433 | "LASFDE%d:\n" | ||
2434 | "\t.long LASFDE%d-EH_frame1\n" | ||
2435 | "\t.long %s-.\n" | ||
2436 | "\t.long %d\n" | ||
2437 | "\t.byte 0\n" /* augmentation length */ | ||
2438 | "\t.byte 0xe\n\t.byte %d\n" /* def_cfa_offset */ | ||
2418 | #if LJ_64 | 2439 | #if LJ_64 |
2419 | "\t.byte 0x86\n\t.uleb128 0x2\n" /* offset rbp */ | 2440 | "\t.byte 0x86\n\t.byte 0x2\n" /* offset rbp */ |
2420 | "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset rbx */ | 2441 | "\t.byte 0x83\n\t.byte 0x3\n" /* offset rbx */ |
2421 | "\t.byte 0x8f\n\t.uleb128 0x4\n" /* offset r15 */ | 2442 | "\t.byte 0x8f\n\t.byte 0x4\n" /* offset r15 */ |
2422 | "\t.byte 0x8e\n\t.uleb128 0x5\n" /* offset r14 */ | 2443 | "\t.byte 0x8e\n\t.byte 0x5\n" /* offset r14 */ |
2423 | #else | 2444 | #else |
2424 | "\t.byte 0x84\n\t.byte 0x2\n" /* offset ebp (4 for MACH-O)*/ | 2445 | "\t.byte 0x84\n\t.byte 0x2\n" /* offset ebp (4 for MACH-O)*/ |
2425 | "\t.byte 0x87\n\t.byte 0x3\n" /* offset edi */ | 2446 | "\t.byte 0x87\n\t.byte 0x3\n" /* offset edi */ |
2426 | "\t.byte 0x86\n\t.byte 0x4\n" /* offset esi */ | 2447 | "\t.byte 0x86\n\t.byte 0x4\n" /* offset esi */ |
2427 | "\t.byte 0x83\n\t.byte 0x5\n" /* offset ebx */ | 2448 | "\t.byte 0x83\n\t.byte 0x5\n" /* offset ebx */ |
2428 | #endif | 2449 | #endif |
2429 | "\t.align " BSZPTR "\n" | 2450 | "\t.align " BSZPTR "\n" |
2430 | "LEFDE1:\n\n", (int)ctx->codesz, CFRAME_SIZE); | 2451 | "LEFDE%d:\n\n", |
2452 | name, i, i, i, i, i, i, i, name, size, CFRAME_SIZE, i); | ||
2453 | } | ||
2454 | } | ||
2431 | #if LJ_64 | 2455 | #if LJ_64 |
2432 | fprintf(ctx->fp, "\t.subsections_via_symbols\n"); | 2456 | fprintf(ctx->fp, "\t.subsections_via_symbols\n"); |
2433 | #else | 2457 | #else |
2434 | fprintf(ctx->fp, | 2458 | fprintf(ctx->fp, |
2435 | "\t.non_lazy_symbol_pointer\n" | 2459 | "\t.non_lazy_symbol_pointer\n" |
2436 | "L_lj_err_unwind_dwarf$non_lazy_ptr:\n" | 2460 | "L_lj_err_unwind_dwarf$non_lazy_ptr:\n" |
2437 | ".indirect_symbol _lj_err_unwind_dwarf\n" | 2461 | ".indirect_symbol _lj_err_unwind_dwarf\n" |
2438 | ".long 0\n"); | 2462 | ".long 0\n"); |
2439 | #endif | 2463 | #endif |
2464 | } | ||
2440 | break; | 2465 | break; |
2441 | default: /* Difficult for other modes. */ | 2466 | default: /* Difficult for other modes. */ |
2442 | break; | 2467 | break; |