summaryrefslogtreecommitdiff
path: root/src/buildvm_x86.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/buildvm_x86.h')
-rw-r--r--src/buildvm_x86.h88
1 files changed, 65 insertions, 23 deletions
diff --git a/src/buildvm_x86.h b/src/buildvm_x86.h
index c9907583..c7eb42e3 100644
--- a/src/buildvm_x86.h
+++ b/src/buildvm_x86.h
@@ -2305,6 +2305,17 @@ static int build_backend(BuildCtx *ctx)
2305/* Emit pseudo frame-info for all assembler functions. */ 2305/* Emit pseudo frame-info for all assembler functions. */
2306static void emit_asm_debug(BuildCtx *ctx) 2306static void emit_asm_debug(BuildCtx *ctx)
2307{ 2307{
2308#if LJ_64
2309#define SZPTR "8"
2310#define BSZPTR "3"
2311#define REG_SP "0x7"
2312#define REG_RA "0x10"
2313#else
2314#define SZPTR "4"
2315#define BSZPTR "2"
2316#define REG_SP "0x4"
2317#define REG_RA "0x8"
2318#endif
2308 switch (ctx->mode) { 2319 switch (ctx->mode) {
2309 case BUILD_elfasm: 2320 case BUILD_elfasm:
2310 fprintf(ctx->fp, "\t.section .debug_frame,\"\",@progbits\n"); 2321 fprintf(ctx->fp, "\t.section .debug_frame,\"\",@progbits\n");
@@ -2316,11 +2327,11 @@ static void emit_asm_debug(BuildCtx *ctx)
2316 "\t.byte 0x1\n" 2327 "\t.byte 0x1\n"
2317 "\t.string \"\"\n" 2328 "\t.string \"\"\n"
2318 "\t.uleb128 0x1\n" 2329 "\t.uleb128 0x1\n"
2319 "\t.sleb128 -4\n" 2330 "\t.sleb128 -" SZPTR "\n"
2320 "\t.byte 0x8\n" 2331 "\t.byte " REG_RA "\n"
2321 "\t.byte 0xc\n\t.uleb128 0x4\n\t.uleb128 0x4\n" 2332 "\t.byte 0xc\n\t.uleb128 " REG_SP "\n\t.uleb128 " SZPTR "\n"
2322 "\t.byte 0x88\n\t.uleb128 0x1\n" 2333 "\t.byte 0x80+" REG_RA "\n\t.uleb128 0x1\n"
2323 "\t.align 4\n" 2334 "\t.align " SZPTR "\n"
2324 ".LECIE0:\n\n"); 2335 ".LECIE0:\n\n");
2325 fprintf(ctx->fp, 2336 fprintf(ctx->fp,
2326 ".LSFDE0:\n" 2337 ".LSFDE0:\n"
@@ -2329,13 +2340,22 @@ static void emit_asm_debug(BuildCtx *ctx)
2329 "\t.long .Lframe0\n" 2340 "\t.long .Lframe0\n"
2330 "\t.long .Lbegin\n" 2341 "\t.long .Lbegin\n"
2331 "\t.long %d\n" 2342 "\t.long %d\n"
2332 "\t.byte 0xe\n\t.uleb128 0x30\n" /* def_cfa_offset */ 2343 "\t.byte 0xe\n\t.uleb128 %d\n" /* def_cfa_offset */
2344#if LJ_64
2345 "\t.byte 0x86\n\t.uleb128 0x2\n" /* offset rbp */
2346 "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset rbx */
2347 "\t.byte 0x8f\n\t.uleb128 0x4\n" /* offset r15 */
2348 "\t.byte 0x8e\n\t.uleb128 0x5\n" /* offset r14 */
2349 "\t.byte 0x8d\n\t.uleb128 0x6\n" /* offset r13 */
2350 "\t.byte 0x8c\n\t.uleb128 0x7\n" /* offset r12 */
2351#else
2333 "\t.byte 0x85\n\t.uleb128 0x2\n" /* offset ebp */ 2352 "\t.byte 0x85\n\t.uleb128 0x2\n" /* offset ebp */
2334 "\t.byte 0x87\n\t.uleb128 0x3\n" /* offset edi */ 2353 "\t.byte 0x87\n\t.uleb128 0x3\n" /* offset edi */
2335 "\t.byte 0x86\n\t.uleb128 0x4\n" /* offset esi */ 2354 "\t.byte 0x86\n\t.uleb128 0x4\n" /* offset esi */
2336 "\t.byte 0x83\n\t.uleb128 0x5\n" /* offset ebx */ 2355 "\t.byte 0x83\n\t.uleb128 0x5\n" /* offset ebx */
2337 "\t.align 4\n" 2356#endif
2338 ".LEFDE0:\n\n", (int)ctx->codesz); 2357 "\t.align " SZPTR "\n"
2358 ".LEFDE0:\n\n", (int)ctx->codesz, CFRAME_SIZE);
2339 fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@progbits\n"); 2359 fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@progbits\n");
2340 fprintf(ctx->fp, 2360 fprintf(ctx->fp,
2341 ".Lframe1:\n" 2361 ".Lframe1:\n"
@@ -2345,15 +2365,15 @@ static void emit_asm_debug(BuildCtx *ctx)
2345 "\t.byte 0x1\n" 2365 "\t.byte 0x1\n"
2346 "\t.string \"zPR\"\n" 2366 "\t.string \"zPR\"\n"
2347 "\t.uleb128 0x1\n" 2367 "\t.uleb128 0x1\n"
2348 "\t.sleb128 -4\n" 2368 "\t.sleb128 -" SZPTR "\n"
2349 "\t.byte 0x8\n" 2369 "\t.byte " REG_RA "\n"
2350 "\t.uleb128 6\n" /* augmentation length */ 2370 "\t.uleb128 6\n" /* augmentation length */
2351 "\t.byte 0x1b\n" /* pcrel|sdata4 */ 2371 "\t.byte 0x1b\n" /* pcrel|sdata4 */
2352 "\t.long lj_err_unwind_dwarf-.\n" 2372 "\t.long lj_err_unwind_dwarf-.\n"
2353 "\t.byte 0x1b\n" /* pcrel|sdata4 */ 2373 "\t.byte 0x1b\n" /* pcrel|sdata4 */
2354 "\t.byte 0xc\n\t.uleb128 0x4\n\t.uleb128 0x4\n" 2374 "\t.byte 0xc\n\t.uleb128 " REG_SP "\n\t.uleb128 " SZPTR "\n"
2355 "\t.byte 0x88\n\t.uleb128 0x1\n" 2375 "\t.byte 0x80+" REG_RA "\n\t.uleb128 0x1\n"
2356 "\t.align 4\n" 2376 "\t.align " SZPTR "\n"
2357 ".LECIE1:\n\n"); 2377 ".LECIE1:\n\n");
2358 fprintf(ctx->fp, 2378 fprintf(ctx->fp,
2359 ".LSFDE1:\n" 2379 ".LSFDE1:\n"
@@ -2363,13 +2383,22 @@ static void emit_asm_debug(BuildCtx *ctx)
2363 "\t.long .Lbegin-.\n" 2383 "\t.long .Lbegin-.\n"
2364 "\t.long %d\n" 2384 "\t.long %d\n"
2365 "\t.uleb128 0\n" /* augmentation length */ 2385 "\t.uleb128 0\n" /* augmentation length */
2366 "\t.byte 0xe\n\t.uleb128 0x30\n" /* def_cfa_offset */ 2386 "\t.byte 0xe\n\t.uleb128 %d\n" /* def_cfa_offset */
2387#if LJ_64
2388 "\t.byte 0x86\n\t.uleb128 0x2\n" /* offset rbp */
2389 "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset rbx */
2390 "\t.byte 0x8f\n\t.uleb128 0x4\n" /* offset r15 */
2391 "\t.byte 0x8e\n\t.uleb128 0x5\n" /* offset r14 */
2392 "\t.byte 0x8d\n\t.uleb128 0x6\n" /* offset r13 */
2393 "\t.byte 0x8c\n\t.uleb128 0x7\n" /* offset r12 */
2394#else
2367 "\t.byte 0x85\n\t.uleb128 0x2\n" /* offset ebp */ 2395 "\t.byte 0x85\n\t.uleb128 0x2\n" /* offset ebp */
2368 "\t.byte 0x87\n\t.uleb128 0x3\n" /* offset edi */ 2396 "\t.byte 0x87\n\t.uleb128 0x3\n" /* offset edi */
2369 "\t.byte 0x86\n\t.uleb128 0x4\n" /* offset esi */ 2397 "\t.byte 0x86\n\t.uleb128 0x4\n" /* offset esi */
2370 "\t.byte 0x83\n\t.uleb128 0x5\n" /* offset ebx */ 2398 "\t.byte 0x83\n\t.uleb128 0x5\n" /* offset ebx */
2371 "\t.align 4\n" 2399#endif
2372 ".LEFDE1:\n\n", (int)ctx->codesz); 2400 "\t.align " SZPTR "\n"
2401 ".LEFDE1:\n\n", (int)ctx->codesz, CFRAME_SIZE);
2373 break; 2402 break;
2374 case BUILD_machasm: 2403 case BUILD_machasm:
2375 fprintf(ctx->fp, "\t.section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support\n"); 2404 fprintf(ctx->fp, "\t.section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support\n");
@@ -2382,15 +2411,19 @@ static void emit_asm_debug(BuildCtx *ctx)
2382 "\t.byte 0x1\n" 2411 "\t.byte 0x1\n"
2383 "\t.ascii \"zPR\\0\"\n" 2412 "\t.ascii \"zPR\\0\"\n"
2384 "\t.byte 0x1\n" 2413 "\t.byte 0x1\n"
2385 "\t.byte 128-4\n" 2414 "\t.byte 128-" SZPTR "\n"
2386 "\t.byte 0x8\n" 2415 "\t.byte " REG_RA "\n"
2387 "\t.byte 6\n" /* augmentation length */ 2416 "\t.byte 6\n" /* augmentation length */
2388 "\t.byte 0x9b\n" /* indirect|pcrel|sdata4 */ 2417 "\t.byte 0x9b\n" /* indirect|pcrel|sdata4 */
2389 "\t.long L_lj_err_unwind_dwarf$non_lazy_ptr-.\n" 2418 "\t.long L_lj_err_unwind_dwarf$non_lazy_ptr-.\n"
2390 "\t.byte 0x1b\n" /* pcrel|sdata4 */ 2419 "\t.byte 0x1b\n" /* pcrel|sdata4 */
2420#if LJ_64
2421 "\t.byte 0xc\n\t.byte " REG_SP "\n\t.byte " SZPTR "\n"
2422#else
2391 "\t.byte 0xc\n\t.byte 0x5\n\t.byte 0x4\n" /* esp=5 on 32 bit MACH-O. */ 2423 "\t.byte 0xc\n\t.byte 0x5\n\t.byte 0x4\n" /* esp=5 on 32 bit MACH-O. */
2392 "\t.byte 0x88\n\t.byte 0x1\n" 2424#endif
2393 "\t.align 2\n" 2425 "\t.byte 0x80+" REG_RA "\n\t.byte 0x1\n"
2426 "\t.align " BSZPTR "\n"
2394 "LECIE1:\n\n"); 2427 "LECIE1:\n\n");
2395 fprintf(ctx->fp, 2428 fprintf(ctx->fp,
2396 "_lj_vm_asm_begin.eh:\n" 2429 "_lj_vm_asm_begin.eh:\n"
@@ -2402,13 +2435,22 @@ static void emit_asm_debug(BuildCtx *ctx)
2402 "\t.long _lj_vm_asm_begin-.\n" 2435 "\t.long _lj_vm_asm_begin-.\n"
2403 "\t.long %d\n" 2436 "\t.long %d\n"
2404 "\t.byte 0\n" /* augmentation length */ 2437 "\t.byte 0\n" /* augmentation length */
2405 "\t.byte 0xe\n\t.byte 0x30\n" /* def_cfa_offset */ 2438 "\t.byte 0xe\n\t.byte %d\n" /* def_cfa_offset */
2439#if LJ_64
2440 "\t.byte 0x86\n\t.uleb128 0x2\n" /* offset rbp */
2441 "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset rbx */
2442 "\t.byte 0x8f\n\t.uleb128 0x4\n" /* offset r15 */
2443 "\t.byte 0x8e\n\t.uleb128 0x5\n" /* offset r14 */
2444 "\t.byte 0x8d\n\t.uleb128 0x6\n" /* offset r13 */
2445 "\t.byte 0x8c\n\t.uleb128 0x7\n" /* offset r12 */
2446#else
2406 "\t.byte 0x84\n\t.byte 0x2\n" /* offset ebp (4 for MACH-O)*/ 2447 "\t.byte 0x84\n\t.byte 0x2\n" /* offset ebp (4 for MACH-O)*/
2407 "\t.byte 0x87\n\t.byte 0x3\n" /* offset edi */ 2448 "\t.byte 0x87\n\t.byte 0x3\n" /* offset edi */
2408 "\t.byte 0x86\n\t.byte 0x4\n" /* offset esi */ 2449 "\t.byte 0x86\n\t.byte 0x4\n" /* offset esi */
2409 "\t.byte 0x83\n\t.byte 0x5\n" /* offset ebx */ 2450 "\t.byte 0x83\n\t.byte 0x5\n" /* offset ebx */
2410 "\t.align 2\n" 2451#endif
2411 "LEFDE1:\n\n", (int)ctx->codesz); 2452 "\t.align " BSZPTR "\n"
2453 "LEFDE1:\n\n", (int)ctx->codesz, CFRAME_SIZE);
2412 fprintf(ctx->fp, 2454 fprintf(ctx->fp,
2413 "\t.non_lazy_symbol_pointer\n" 2455 "\t.non_lazy_symbol_pointer\n"
2414 "L_lj_err_unwind_dwarf$non_lazy_ptr:\n" 2456 "L_lj_err_unwind_dwarf$non_lazy_ptr:\n"