diff options
author | Mike Pall <mike> | 2010-01-22 01:56:49 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2010-01-22 01:56:49 +0100 |
commit | 43f1e134709b06be7091ad8f6cfaaaa78adec886 (patch) | |
tree | 38d5819e5a6406c66cc2cf91bb5465d552d1c37b /src | |
parent | c56811bb7acf40174ac9b63e69f58b42adf85bd7 (diff) | |
download | luajit-43f1e134709b06be7091ad8f6cfaaaa78adec886.tar.gz luajit-43f1e134709b06be7091ad8f6cfaaaa78adec886.tar.bz2 luajit-43f1e134709b06be7091ad8f6cfaaaa78adec886.zip |
Integrate MinGW build with DWARF2 exception handling.
Only works with DWARF2-enabled GCC 4.x (not the default MinGW GCC).
Fix fastcall symbol names for COFF assembler output.
Add DWARF2 unwind info to COFF assembler output.
Use COFF assembler mode for MinGW builds.
Always enable the DWARF2 handler if compiled with GCC.
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile | 3 | ||||
-rw-r--r-- | src/buildvm_asm.c | 60 | ||||
-rw-r--r-- | src/buildvm_x64.h | 45 | ||||
-rw-r--r-- | src/buildvm_x64win.h | 45 | ||||
-rw-r--r-- | src/buildvm_x86.dasc | 45 | ||||
-rw-r--r-- | src/buildvm_x86.h | 45 | ||||
-rw-r--r-- | src/lj_err.c | 4 |
7 files changed, 216 insertions, 31 deletions
diff --git a/src/Makefile b/src/Makefile index 96039ba0..da9d143b 100644 --- a/src/Makefile +++ b/src/Makefile | |||
@@ -299,8 +299,7 @@ ifeq (Windows,$(HOST_SYS)) | |||
299 | endif | 299 | endif |
300 | ifeq (Windows,$(TARGET_SYS)) | 300 | ifeq (Windows,$(TARGET_SYS)) |
301 | TARGET_DYNCC= $(STATIC_CC) | 301 | TARGET_DYNCC= $(STATIC_CC) |
302 | LJVM_BOUT= $(LJVM_O) | 302 | LJVM_MODE= coffasm |
303 | LJVM_MODE= peobj | ||
304 | LUAJIT_SO= $(TARGET_DLLNAME) | 303 | LUAJIT_SO= $(TARGET_DLLNAME) |
305 | LUAJIT_T= luajit.exe | 304 | LUAJIT_T= luajit.exe |
306 | ifneq ($(HOST_SYS),$(TARGET_SYS)) | 305 | ifneq ($(HOST_SYS),$(TARGET_SYS)) |
diff --git a/src/buildvm_asm.c b/src/buildvm_asm.c index bd835ebc..2d0ba3b5 100644 --- a/src/buildvm_asm.c +++ b/src/buildvm_asm.c | |||
@@ -33,14 +33,14 @@ static void emit_asm_reloc(BuildCtx *ctx, int type, const char *sym) | |||
33 | fprintf(ctx->fp, "\t.long %s\n", sym); | 33 | fprintf(ctx->fp, "\t.long %s\n", sym); |
34 | break; | 34 | break; |
35 | case BUILD_coffasm: | 35 | case BUILD_coffasm: |
36 | fprintf(ctx->fp, "\t.def _%s; .scl 3; .type 32; .endef\n", sym); | 36 | fprintf(ctx->fp, "\t.def %s; .scl 3; .type 32; .endef\n", sym); |
37 | if (type) | 37 | if (type) |
38 | fprintf(ctx->fp, "\t.long _%s-.-4\n", sym); | 38 | fprintf(ctx->fp, "\t.long %s-.-4\n", sym); |
39 | else | 39 | else |
40 | fprintf(ctx->fp, "\t.long _%s\n", sym); | 40 | fprintf(ctx->fp, "\t.long %s\n", sym); |
41 | break; | 41 | break; |
42 | default: /* BUILD_machasm for relative relocations handled below. */ | 42 | default: /* BUILD_machasm for relative relocations handled below. */ |
43 | fprintf(ctx->fp, "\t.long _%s\n", sym); | 43 | fprintf(ctx->fp, "\t.long %s\n", sym); |
44 | break; | 44 | break; |
45 | } | 45 | } |
46 | } | 46 | } |
@@ -70,7 +70,7 @@ err: | |||
70 | exit(1); | 70 | exit(1); |
71 | } | 71 | } |
72 | emit_asm_bytes(ctx, cp, n); | 72 | emit_asm_bytes(ctx, cp, n); |
73 | fprintf(ctx->fp, "\t%s _%s\n", opname, sym); | 73 | fprintf(ctx->fp, "\t%s %s\n", opname, sym); |
74 | } | 74 | } |
75 | 75 | ||
76 | /* Emit an assembler label. */ | 76 | /* Emit an assembler label. */ |
@@ -87,15 +87,15 @@ static void emit_asm_label(BuildCtx *ctx, const char *name, int size, int isfunc | |||
87 | name, name, name, isfunc ? "function" : "object", name, size, name); | 87 | name, name, name, isfunc ? "function" : "object", name, size, name); |
88 | break; | 88 | break; |
89 | case BUILD_coffasm: | 89 | case BUILD_coffasm: |
90 | fprintf(ctx->fp, "\n\t.globl _%s\n", name); | 90 | fprintf(ctx->fp, "\n\t.globl %s\n", name); |
91 | if (isfunc) | 91 | if (isfunc) |
92 | fprintf(ctx->fp, "\t.def _%s; .scl 3; .type 32; .endef\n", name); | 92 | fprintf(ctx->fp, "\t.def %s; .scl 3; .type 32; .endef\n", name); |
93 | fprintf(ctx->fp, "_%s:\n", name); | 93 | fprintf(ctx->fp, "%s:\n", name); |
94 | break; | 94 | break; |
95 | case BUILD_machasm: | 95 | case BUILD_machasm: |
96 | fprintf(ctx->fp, | 96 | fprintf(ctx->fp, |
97 | "\n\t.private_extern _%s\n" | 97 | "\n\t.private_extern %s\n" |
98 | "_%s:\n", name, name); | 98 | "%s:\n", name, name); |
99 | break; | 99 | break; |
100 | default: | 100 | default: |
101 | break; | 101 | break; |
@@ -126,13 +126,22 @@ void emit_asm(BuildCtx *ctx) | |||
126 | char name[80]; | 126 | char name[80]; |
127 | int32_t prev; | 127 | int32_t prev; |
128 | int i, pi, rel; | 128 | int i, pi, rel; |
129 | #if LJ_64 | ||
130 | const char *symprefix = ctx->mode == BUILD_machasm ? "_" : ""; | ||
131 | int keepfc = 0; | ||
132 | #else | ||
133 | const char *symprefix = ctx->mode != BUILD_elfasm ? "_" : ""; | ||
134 | /* Keep fastcall suffix for COFF on WIN32. */ | ||
135 | int keepfc = (ctx->mode == BUILD_coffasm); | ||
136 | #endif | ||
129 | 137 | ||
130 | fprintf(ctx->fp, "\t.file \"buildvm_%s.dasc\"\n", ctx->dasm_arch); | 138 | fprintf(ctx->fp, "\t.file \"buildvm_%s.dasc\"\n", ctx->dasm_arch); |
131 | fprintf(ctx->fp, "\t.text\n"); | 139 | fprintf(ctx->fp, "\t.text\n"); |
132 | emit_asm_align(ctx, 4); | 140 | emit_asm_align(ctx, 4); |
133 | 141 | ||
134 | emit_asm_label(ctx, LABEL_ASM_BEGIN, 0, 0); | 142 | sprintf(name, "%s" LABEL_ASM_BEGIN, symprefix); |
135 | if (ctx->mode == BUILD_elfasm) | 143 | emit_asm_label(ctx, name, 0, 0); |
144 | if (ctx->mode != BUILD_machasm) | ||
136 | fprintf(ctx->fp, ".Lbegin:\n"); | 145 | fprintf(ctx->fp, ".Lbegin:\n"); |
137 | 146 | ||
138 | i = 0; | 147 | i = 0; |
@@ -148,10 +157,10 @@ void emit_asm(BuildCtx *ctx) | |||
148 | int32_t stop = next; | 157 | int32_t stop = next; |
149 | if (pi >= ctx->npc) { | 158 | if (pi >= ctx->npc) { |
150 | char *p; | 159 | char *p; |
151 | sprintf(name, LABEL_PREFIX "%s", ctx->globnames[pi-ctx->npc]); | 160 | sprintf(name, "%s" LABEL_PREFIX "%s", symprefix, |
152 | /* Always strip fastcall suffix. Wrong for (unused) COFF on Win32. */ | 161 | ctx->globnames[pi-ctx->npc]); |
153 | p = strchr(name, '@'); | 162 | p = strchr(name, '@'); |
154 | if (p) *p = '\0'; | 163 | if (p) { if (keepfc) name[0] = '@'; else *p = '\0'; } |
155 | emit_asm_label(ctx, name, size, 1); | 164 | emit_asm_label(ctx, name, size, 1); |
156 | #if LJ_HASJIT | 165 | #if LJ_HASJIT |
157 | } else { | 166 | } else { |
@@ -160,25 +169,21 @@ void emit_asm(BuildCtx *ctx) | |||
160 | pi == BC_JLOOP || pi == BC_IFORL || pi == BC_IITERL || | 169 | pi == BC_JLOOP || pi == BC_IFORL || pi == BC_IITERL || |
161 | pi == BC_ILOOP)) { | 170 | pi == BC_ILOOP)) { |
162 | #endif | 171 | #endif |
163 | sprintf(name, LABEL_PREFIX_BC "%s", bc_names[pi]); | 172 | sprintf(name, "%s" LABEL_PREFIX_BC "%s", symprefix, bc_names[pi]); |
164 | emit_asm_label(ctx, name, size, 1); | 173 | emit_asm_label(ctx, name, size, 1); |
165 | } | 174 | } |
166 | while (rel < ctx->nreloc && ctx->reloc[rel].ofs < stop) { | 175 | while (rel < ctx->nreloc && ctx->reloc[rel].ofs < stop) { |
167 | BuildReloc *r = &ctx->reloc[rel]; | 176 | BuildReloc *r = &ctx->reloc[rel]; |
168 | int n = r->ofs - prev; | 177 | int n = r->ofs - prev; |
169 | const char *sym = ctx->extnames[r->sym]; | 178 | char *p; |
170 | const char *p = strchr(sym, '@'); | 179 | sprintf(name, "%s%s", symprefix, ctx->extnames[r->sym]); |
171 | if (p) { | 180 | p = strchr(name, '@'); |
172 | /* Always strip fastcall suffix. Wrong for (unused) COFF on Win32. */ | 181 | if (p) { if (keepfc) name[0] = '@'; else *p = '\0'; } |
173 | strncpy(name, sym, p-sym); | ||
174 | name[p-sym] = '\0'; | ||
175 | sym = name; | ||
176 | } | ||
177 | if (ctx->mode == BUILD_machasm && r->type != 0) { | 182 | if (ctx->mode == BUILD_machasm && r->type != 0) { |
178 | emit_asm_reloc_mach(ctx, ctx->code+prev, n, sym); | 183 | emit_asm_reloc_mach(ctx, ctx->code+prev, n, name); |
179 | } else { | 184 | } else { |
180 | emit_asm_bytes(ctx, ctx->code+prev, n); | 185 | emit_asm_bytes(ctx, ctx->code+prev, n); |
181 | emit_asm_reloc(ctx, r->type, sym); | 186 | emit_asm_reloc(ctx, r->type, name); |
182 | } | 187 | } |
183 | prev += n+4; | 188 | prev += n+4; |
184 | rel++; | 189 | rel++; |
@@ -203,7 +208,8 @@ void emit_asm(BuildCtx *ctx) | |||
203 | } | 208 | } |
204 | emit_asm_align(ctx, 5); | 209 | emit_asm_align(ctx, 5); |
205 | 210 | ||
206 | emit_asm_label(ctx, LABEL_OP_OFS, 2*ctx->npc, 0); | 211 | sprintf(name, "%s" LABEL_OP_OFS, symprefix); |
212 | emit_asm_label(ctx, name, 2*ctx->npc, 0); | ||
207 | for (i = 0; i < ctx->npc; i++) | 213 | for (i = 0; i < ctx->npc; i++) |
208 | fprintf(ctx->fp, "\t.short %d\n", ctx->sym_ofs[i]); | 214 | fprintf(ctx->fp, "\t.short %d\n", ctx->sym_ofs[i]); |
209 | 215 | ||
diff --git a/src/buildvm_x64.h b/src/buildvm_x64.h index 76c640da..615b9b82 100644 --- a/src/buildvm_x64.h +++ b/src/buildvm_x64.h | |||
@@ -2252,6 +2252,51 @@ static void emit_asm_debug(BuildCtx *ctx) | |||
2252 | "\t.align " SZPTR "\n" | 2252 | "\t.align " SZPTR "\n" |
2253 | ".LEFDE1:\n\n", (int)ctx->codesz, CFRAME_SIZE); | 2253 | ".LEFDE1:\n\n", (int)ctx->codesz, CFRAME_SIZE); |
2254 | break; | 2254 | break; |
2255 | case BUILD_coffasm: | ||
2256 | fprintf(ctx->fp, "\t.section .eh_frame,\"dr\"\n"); | ||
2257 | fprintf(ctx->fp, | ||
2258 | "\t.def %slj_err_unwind_dwarf; .scl 2; .type 32; .endef\n", | ||
2259 | LJ_32 ? "_" : ""); | ||
2260 | fprintf(ctx->fp, | ||
2261 | "Lframe1:\n" | ||
2262 | "\t.long LECIE1-LSCIE1\n" | ||
2263 | "LSCIE1:\n" | ||
2264 | "\t.long 0\n" | ||
2265 | "\t.byte 0x1\n" | ||
2266 | "\t.string \"zP\"\n" | ||
2267 | "\t.uleb128 0x1\n" | ||
2268 | "\t.sleb128 -" SZPTR "\n" | ||
2269 | "\t.byte " REG_RA "\n" | ||
2270 | "\t.uleb128 5\n" /* augmentation length */ | ||
2271 | "\t.byte 0x00\n" /* absptr */ | ||
2272 | "\t.long %slj_err_unwind_dwarf\n" | ||
2273 | "\t.byte 0xc\n\t.uleb128 " REG_SP "\n\t.uleb128 " SZPTR "\n" | ||
2274 | "\t.byte 0x80+" REG_RA "\n\t.uleb128 0x1\n" | ||
2275 | "\t.align " SZPTR "\n" | ||
2276 | "LECIE1:\n\n", LJ_32 ? "_" : ""); | ||
2277 | fprintf(ctx->fp, | ||
2278 | "LSFDE1:\n" | ||
2279 | "\t.long LEFDE1-LASFDE1\n" | ||
2280 | "LASFDE1:\n" | ||
2281 | "\t.long LASFDE1-Lframe1\n" | ||
2282 | "\t.long %slj_vm_asm_begin\n" | ||
2283 | "\t.long %d\n" | ||
2284 | "\t.uleb128 0\n" /* augmentation length */ | ||
2285 | "\t.byte 0xe\n\t.uleb128 %d\n" /* def_cfa_offset */ | ||
2286 | #if LJ_64 | ||
2287 | "\t.byte 0x86\n\t.uleb128 0x2\n" /* offset rbp */ | ||
2288 | "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset rbx */ | ||
2289 | "\t.byte 0x8f\n\t.uleb128 0x4\n" /* offset r15 */ | ||
2290 | "\t.byte 0x8e\n\t.uleb128 0x5\n" /* offset r14 */ | ||
2291 | #else | ||
2292 | "\t.byte 0x85\n\t.uleb128 0x2\n" /* offset ebp */ | ||
2293 | "\t.byte 0x87\n\t.uleb128 0x3\n" /* offset edi */ | ||
2294 | "\t.byte 0x86\n\t.uleb128 0x4\n" /* offset esi */ | ||
2295 | "\t.byte 0x83\n\t.uleb128 0x5\n" /* offset ebx */ | ||
2296 | #endif | ||
2297 | "\t.align " SZPTR "\n" | ||
2298 | "LEFDE1:\n\n", LJ_32 ? "_" : "", (int)ctx->codesz, CFRAME_SIZE); | ||
2299 | break; | ||
2255 | case BUILD_machasm: | 2300 | case BUILD_machasm: |
2256 | fprintf(ctx->fp, "\t.section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support\n"); | 2301 | fprintf(ctx->fp, "\t.section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support\n"); |
2257 | fprintf(ctx->fp, | 2302 | fprintf(ctx->fp, |
diff --git a/src/buildvm_x64win.h b/src/buildvm_x64win.h index e4cb8851..2ea21bb8 100644 --- a/src/buildvm_x64win.h +++ b/src/buildvm_x64win.h | |||
@@ -2248,6 +2248,51 @@ static void emit_asm_debug(BuildCtx *ctx) | |||
2248 | "\t.align " SZPTR "\n" | 2248 | "\t.align " SZPTR "\n" |
2249 | ".LEFDE1:\n\n", (int)ctx->codesz, CFRAME_SIZE); | 2249 | ".LEFDE1:\n\n", (int)ctx->codesz, CFRAME_SIZE); |
2250 | break; | 2250 | break; |
2251 | case BUILD_coffasm: | ||
2252 | fprintf(ctx->fp, "\t.section .eh_frame,\"dr\"\n"); | ||
2253 | fprintf(ctx->fp, | ||
2254 | "\t.def %slj_err_unwind_dwarf; .scl 2; .type 32; .endef\n", | ||
2255 | LJ_32 ? "_" : ""); | ||
2256 | fprintf(ctx->fp, | ||
2257 | "Lframe1:\n" | ||
2258 | "\t.long LECIE1-LSCIE1\n" | ||
2259 | "LSCIE1:\n" | ||
2260 | "\t.long 0\n" | ||
2261 | "\t.byte 0x1\n" | ||
2262 | "\t.string \"zP\"\n" | ||
2263 | "\t.uleb128 0x1\n" | ||
2264 | "\t.sleb128 -" SZPTR "\n" | ||
2265 | "\t.byte " REG_RA "\n" | ||
2266 | "\t.uleb128 5\n" /* augmentation length */ | ||
2267 | "\t.byte 0x00\n" /* absptr */ | ||
2268 | "\t.long %slj_err_unwind_dwarf\n" | ||
2269 | "\t.byte 0xc\n\t.uleb128 " REG_SP "\n\t.uleb128 " SZPTR "\n" | ||
2270 | "\t.byte 0x80+" REG_RA "\n\t.uleb128 0x1\n" | ||
2271 | "\t.align " SZPTR "\n" | ||
2272 | "LECIE1:\n\n", LJ_32 ? "_" : ""); | ||
2273 | fprintf(ctx->fp, | ||
2274 | "LSFDE1:\n" | ||
2275 | "\t.long LEFDE1-LASFDE1\n" | ||
2276 | "LASFDE1:\n" | ||
2277 | "\t.long LASFDE1-Lframe1\n" | ||
2278 | "\t.long %slj_vm_asm_begin\n" | ||
2279 | "\t.long %d\n" | ||
2280 | "\t.uleb128 0\n" /* augmentation length */ | ||
2281 | "\t.byte 0xe\n\t.uleb128 %d\n" /* def_cfa_offset */ | ||
2282 | #if LJ_64 | ||
2283 | "\t.byte 0x86\n\t.uleb128 0x2\n" /* offset rbp */ | ||
2284 | "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset rbx */ | ||
2285 | "\t.byte 0x8f\n\t.uleb128 0x4\n" /* offset r15 */ | ||
2286 | "\t.byte 0x8e\n\t.uleb128 0x5\n" /* offset r14 */ | ||
2287 | #else | ||
2288 | "\t.byte 0x85\n\t.uleb128 0x2\n" /* offset ebp */ | ||
2289 | "\t.byte 0x87\n\t.uleb128 0x3\n" /* offset edi */ | ||
2290 | "\t.byte 0x86\n\t.uleb128 0x4\n" /* offset esi */ | ||
2291 | "\t.byte 0x83\n\t.uleb128 0x5\n" /* offset ebx */ | ||
2292 | #endif | ||
2293 | "\t.align " SZPTR "\n" | ||
2294 | "LEFDE1:\n\n", LJ_32 ? "_" : "", (int)ctx->codesz, CFRAME_SIZE); | ||
2295 | break; | ||
2251 | case BUILD_machasm: | 2296 | case BUILD_machasm: |
2252 | fprintf(ctx->fp, "\t.section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support\n"); | 2297 | fprintf(ctx->fp, "\t.section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support\n"); |
2253 | fprintf(ctx->fp, | 2298 | fprintf(ctx->fp, |
diff --git a/src/buildvm_x86.dasc b/src/buildvm_x86.dasc index 1878613e..4e4ccc49 100644 --- a/src/buildvm_x86.dasc +++ b/src/buildvm_x86.dasc | |||
@@ -4920,6 +4920,51 @@ static void emit_asm_debug(BuildCtx *ctx) | |||
4920 | "\t.align " SZPTR "\n" | 4920 | "\t.align " SZPTR "\n" |
4921 | ".LEFDE1:\n\n", (int)ctx->codesz, CFRAME_SIZE); | 4921 | ".LEFDE1:\n\n", (int)ctx->codesz, CFRAME_SIZE); |
4922 | break; | 4922 | break; |
4923 | case BUILD_coffasm: | ||
4924 | fprintf(ctx->fp, "\t.section .eh_frame,\"dr\"\n"); | ||
4925 | fprintf(ctx->fp, | ||
4926 | "\t.def %slj_err_unwind_dwarf; .scl 2; .type 32; .endef\n", | ||
4927 | LJ_32 ? "_" : ""); | ||
4928 | fprintf(ctx->fp, | ||
4929 | "Lframe1:\n" | ||
4930 | "\t.long LECIE1-LSCIE1\n" | ||
4931 | "LSCIE1:\n" | ||
4932 | "\t.long 0\n" | ||
4933 | "\t.byte 0x1\n" | ||
4934 | "\t.string \"zP\"\n" | ||
4935 | "\t.uleb128 0x1\n" | ||
4936 | "\t.sleb128 -" SZPTR "\n" | ||
4937 | "\t.byte " REG_RA "\n" | ||
4938 | "\t.uleb128 5\n" /* augmentation length */ | ||
4939 | "\t.byte 0x00\n" /* absptr */ | ||
4940 | "\t.long %slj_err_unwind_dwarf\n" | ||
4941 | "\t.byte 0xc\n\t.uleb128 " REG_SP "\n\t.uleb128 " SZPTR "\n" | ||
4942 | "\t.byte 0x80+" REG_RA "\n\t.uleb128 0x1\n" | ||
4943 | "\t.align " SZPTR "\n" | ||
4944 | "LECIE1:\n\n", LJ_32 ? "_" : ""); | ||
4945 | fprintf(ctx->fp, | ||
4946 | "LSFDE1:\n" | ||
4947 | "\t.long LEFDE1-LASFDE1\n" | ||
4948 | "LASFDE1:\n" | ||
4949 | "\t.long LASFDE1-Lframe1\n" | ||
4950 | "\t.long %slj_vm_asm_begin\n" | ||
4951 | "\t.long %d\n" | ||
4952 | "\t.uleb128 0\n" /* augmentation length */ | ||
4953 | "\t.byte 0xe\n\t.uleb128 %d\n" /* def_cfa_offset */ | ||
4954 | #if LJ_64 | ||
4955 | "\t.byte 0x86\n\t.uleb128 0x2\n" /* offset rbp */ | ||
4956 | "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset rbx */ | ||
4957 | "\t.byte 0x8f\n\t.uleb128 0x4\n" /* offset r15 */ | ||
4958 | "\t.byte 0x8e\n\t.uleb128 0x5\n" /* offset r14 */ | ||
4959 | #else | ||
4960 | "\t.byte 0x85\n\t.uleb128 0x2\n" /* offset ebp */ | ||
4961 | "\t.byte 0x87\n\t.uleb128 0x3\n" /* offset edi */ | ||
4962 | "\t.byte 0x86\n\t.uleb128 0x4\n" /* offset esi */ | ||
4963 | "\t.byte 0x83\n\t.uleb128 0x5\n" /* offset ebx */ | ||
4964 | #endif | ||
4965 | "\t.align " SZPTR "\n" | ||
4966 | "LEFDE1:\n\n", LJ_32 ? "_" : "", (int)ctx->codesz, CFRAME_SIZE); | ||
4967 | break; | ||
4923 | case BUILD_machasm: | 4968 | case BUILD_machasm: |
4924 | fprintf(ctx->fp, "\t.section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support\n"); | 4969 | fprintf(ctx->fp, "\t.section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support\n"); |
4925 | fprintf(ctx->fp, | 4970 | fprintf(ctx->fp, |
diff --git a/src/buildvm_x86.h b/src/buildvm_x86.h index 68f27f93..e98d2622 100644 --- a/src/buildvm_x86.h +++ b/src/buildvm_x86.h | |||
@@ -2403,6 +2403,51 @@ static void emit_asm_debug(BuildCtx *ctx) | |||
2403 | "\t.align " SZPTR "\n" | 2403 | "\t.align " SZPTR "\n" |
2404 | ".LEFDE1:\n\n", (int)ctx->codesz, CFRAME_SIZE); | 2404 | ".LEFDE1:\n\n", (int)ctx->codesz, CFRAME_SIZE); |
2405 | break; | 2405 | break; |
2406 | case BUILD_coffasm: | ||
2407 | fprintf(ctx->fp, "\t.section .eh_frame,\"dr\"\n"); | ||
2408 | fprintf(ctx->fp, | ||
2409 | "\t.def %slj_err_unwind_dwarf; .scl 2; .type 32; .endef\n", | ||
2410 | LJ_32 ? "_" : ""); | ||
2411 | fprintf(ctx->fp, | ||
2412 | "Lframe1:\n" | ||
2413 | "\t.long LECIE1-LSCIE1\n" | ||
2414 | "LSCIE1:\n" | ||
2415 | "\t.long 0\n" | ||
2416 | "\t.byte 0x1\n" | ||
2417 | "\t.string \"zP\"\n" | ||
2418 | "\t.uleb128 0x1\n" | ||
2419 | "\t.sleb128 -" SZPTR "\n" | ||
2420 | "\t.byte " REG_RA "\n" | ||
2421 | "\t.uleb128 5\n" /* augmentation length */ | ||
2422 | "\t.byte 0x00\n" /* absptr */ | ||
2423 | "\t.long %slj_err_unwind_dwarf\n" | ||
2424 | "\t.byte 0xc\n\t.uleb128 " REG_SP "\n\t.uleb128 " SZPTR "\n" | ||
2425 | "\t.byte 0x80+" REG_RA "\n\t.uleb128 0x1\n" | ||
2426 | "\t.align " SZPTR "\n" | ||
2427 | "LECIE1:\n\n", LJ_32 ? "_" : ""); | ||
2428 | fprintf(ctx->fp, | ||
2429 | "LSFDE1:\n" | ||
2430 | "\t.long LEFDE1-LASFDE1\n" | ||
2431 | "LASFDE1:\n" | ||
2432 | "\t.long LASFDE1-Lframe1\n" | ||
2433 | "\t.long %slj_vm_asm_begin\n" | ||
2434 | "\t.long %d\n" | ||
2435 | "\t.uleb128 0\n" /* augmentation length */ | ||
2436 | "\t.byte 0xe\n\t.uleb128 %d\n" /* def_cfa_offset */ | ||
2437 | #if LJ_64 | ||
2438 | "\t.byte 0x86\n\t.uleb128 0x2\n" /* offset rbp */ | ||
2439 | "\t.byte 0x83\n\t.uleb128 0x3\n" /* offset rbx */ | ||
2440 | "\t.byte 0x8f\n\t.uleb128 0x4\n" /* offset r15 */ | ||
2441 | "\t.byte 0x8e\n\t.uleb128 0x5\n" /* offset r14 */ | ||
2442 | #else | ||
2443 | "\t.byte 0x85\n\t.uleb128 0x2\n" /* offset ebp */ | ||
2444 | "\t.byte 0x87\n\t.uleb128 0x3\n" /* offset edi */ | ||
2445 | "\t.byte 0x86\n\t.uleb128 0x4\n" /* offset esi */ | ||
2446 | "\t.byte 0x83\n\t.uleb128 0x5\n" /* offset ebx */ | ||
2447 | #endif | ||
2448 | "\t.align " SZPTR "\n" | ||
2449 | "LEFDE1:\n\n", LJ_32 ? "_" : "", (int)ctx->codesz, CFRAME_SIZE); | ||
2450 | break; | ||
2406 | case BUILD_machasm: | 2451 | case BUILD_machasm: |
2407 | fprintf(ctx->fp, "\t.section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support\n"); | 2452 | fprintf(ctx->fp, "\t.section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support\n"); |
2408 | fprintf(ctx->fp, | 2453 | fprintf(ctx->fp, |
diff --git a/src/lj_err.c b/src/lj_err.c index 5ec81302..56ca0c37 100644 --- a/src/lj_err.c +++ b/src/lj_err.c | |||
@@ -63,7 +63,7 @@ | |||
63 | ** EXT is mandatory on POSIX/x64 since the interpreter doesn't save r12/r13. | 63 | ** EXT is mandatory on POSIX/x64 since the interpreter doesn't save r12/r13. |
64 | */ | 64 | */ |
65 | 65 | ||
66 | #if defined(__ELF__) || defined(__MACH__) | 66 | #if defined(__GNUC__) |
67 | #if LJ_TARGET_X86 | 67 | #if LJ_TARGET_X86 |
68 | #ifdef LUAJIT_UNWIND_EXTERNAL | 68 | #ifdef LUAJIT_UNWIND_EXTERNAL |
69 | #define LJ_UNWIND_EXT 1 | 69 | #define LJ_UNWIND_EXT 1 |
@@ -532,7 +532,7 @@ static void *err_unwind(lua_State *L, void *stopcf, int errcode) | |||
532 | 532 | ||
533 | /* -- External frame unwinding -------------------------------------------- */ | 533 | /* -- External frame unwinding -------------------------------------------- */ |
534 | 534 | ||
535 | #if defined(__ELF__) || defined(__MACH__) | 535 | #if defined(__GNUC__) |
536 | 536 | ||
537 | #include <unwind.h> | 537 | #include <unwind.h> |
538 | 538 | ||