diff options
-rw-r--r-- | src/buildvm_x64.h | 97 | ||||
-rw-r--r-- | src/buildvm_x64win.h | 97 | ||||
-rw-r--r-- | src/buildvm_x86.dasc | 97 | ||||
-rw-r--r-- | src/buildvm_x86.h | 97 |
4 files changed, 244 insertions, 144 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; |
diff --git a/src/buildvm_x64win.h b/src/buildvm_x64win.h index eb0a7eab..a365810f 100644 --- a/src/buildvm_x64win.h +++ b/src/buildvm_x64win.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; |
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; |
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; |