diff options
Diffstat (limited to 'src/host/buildvm.c')
-rw-r--r-- | src/host/buildvm.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/host/buildvm.c b/src/host/buildvm.c index b9560f31..de23fabd 100644 --- a/src/host/buildvm.c +++ b/src/host/buildvm.c | |||
@@ -59,10 +59,10 @@ static int collect_reloc(BuildCtx *ctx, uint8_t *addr, int idx, int type); | |||
59 | #include "../dynasm/dasm_x86.h" | 59 | #include "../dynasm/dasm_x86.h" |
60 | #elif LJ_TARGET_ARM | 60 | #elif LJ_TARGET_ARM |
61 | #include "../dynasm/dasm_arm.h" | 61 | #include "../dynasm/dasm_arm.h" |
62 | #elif LJ_TARGET_ARM64 | ||
63 | #include "../dynasm/dasm_arm64.h" | ||
62 | #elif LJ_TARGET_PPC | 64 | #elif LJ_TARGET_PPC |
63 | #include "../dynasm/dasm_ppc.h" | 65 | #include "../dynasm/dasm_ppc.h" |
64 | #elif LJ_TARGET_PPCSPE | ||
65 | #include "../dynasm/dasm_ppc.h" | ||
66 | #elif LJ_TARGET_MIPS | 66 | #elif LJ_TARGET_MIPS |
67 | #include "../dynasm/dasm_mips.h" | 67 | #include "../dynasm/dasm_mips.h" |
68 | #else | 68 | #else |
@@ -110,11 +110,11 @@ static const char *sym_decorate(BuildCtx *ctx, | |||
110 | if (p) { | 110 | if (p) { |
111 | #if LJ_TARGET_X86ORX64 | 111 | #if LJ_TARGET_X86ORX64 |
112 | if (!LJ_64 && (ctx->mode == BUILD_coffasm || ctx->mode == BUILD_peobj)) | 112 | if (!LJ_64 && (ctx->mode == BUILD_coffasm || ctx->mode == BUILD_peobj)) |
113 | name[0] = '@'; | 113 | name[0] = name[1] == 'R' ? '_' : '@'; /* Just for _RtlUnwind@16. */ |
114 | else | 114 | else |
115 | *p = '\0'; | 115 | *p = '\0'; |
116 | #elif (LJ_TARGET_PPC || LJ_TARGET_PPCSPE) && !LJ_TARGET_CONSOLE | 116 | #elif LJ_TARGET_PPC && !LJ_TARGET_CONSOLE |
117 | /* Keep @plt. */ | 117 | /* Keep @plt etc. */ |
118 | #else | 118 | #else |
119 | *p = '\0'; | 119 | *p = '\0'; |
120 | #endif | 120 | #endif |
@@ -179,6 +179,7 @@ static int build_code(BuildCtx *ctx) | |||
179 | ctx->nreloc = 0; | 179 | ctx->nreloc = 0; |
180 | 180 | ||
181 | ctx->globnames = globnames; | 181 | ctx->globnames = globnames; |
182 | ctx->extnames = extnames; | ||
182 | ctx->relocsym = (const char **)malloc(NRELOCSYM*sizeof(const char *)); | 183 | ctx->relocsym = (const char **)malloc(NRELOCSYM*sizeof(const char *)); |
183 | ctx->nrelocsym = 0; | 184 | ctx->nrelocsym = 0; |
184 | for (i = 0; i < (int)NRELOCSYM; i++) relocmap[i] = -1; | 185 | for (i = 0; i < (int)NRELOCSYM; i++) relocmap[i] = -1; |
@@ -320,20 +321,20 @@ static void emit_vmdef(BuildCtx *ctx) | |||
320 | char buf[80]; | 321 | char buf[80]; |
321 | int i; | 322 | int i; |
322 | fprintf(ctx->fp, "-- This is a generated file. DO NOT EDIT!\n\n"); | 323 | fprintf(ctx->fp, "-- This is a generated file. DO NOT EDIT!\n\n"); |
323 | fprintf(ctx->fp, "module(...)\n\n"); | 324 | fprintf(ctx->fp, "return {\n\n"); |
324 | 325 | ||
325 | fprintf(ctx->fp, "bcnames = \""); | 326 | fprintf(ctx->fp, "bcnames = \""); |
326 | for (i = 0; bc_names[i]; i++) fprintf(ctx->fp, "%-6s", bc_names[i]); | 327 | for (i = 0; bc_names[i]; i++) fprintf(ctx->fp, "%-6s", bc_names[i]); |
327 | fprintf(ctx->fp, "\"\n\n"); | 328 | fprintf(ctx->fp, "\",\n\n"); |
328 | 329 | ||
329 | fprintf(ctx->fp, "irnames = \""); | 330 | fprintf(ctx->fp, "irnames = \""); |
330 | for (i = 0; ir_names[i]; i++) fprintf(ctx->fp, "%-6s", ir_names[i]); | 331 | for (i = 0; ir_names[i]; i++) fprintf(ctx->fp, "%-6s", ir_names[i]); |
331 | fprintf(ctx->fp, "\"\n\n"); | 332 | fprintf(ctx->fp, "\",\n\n"); |
332 | 333 | ||
333 | fprintf(ctx->fp, "irfpm = { [0]="); | 334 | fprintf(ctx->fp, "irfpm = { [0]="); |
334 | for (i = 0; irfpm_names[i]; i++) | 335 | for (i = 0; irfpm_names[i]; i++) |
335 | fprintf(ctx->fp, "\"%s\", ", lower(buf, irfpm_names[i])); | 336 | fprintf(ctx->fp, "\"%s\", ", lower(buf, irfpm_names[i])); |
336 | fprintf(ctx->fp, "}\n\n"); | 337 | fprintf(ctx->fp, "},\n\n"); |
337 | 338 | ||
338 | fprintf(ctx->fp, "irfield = { [0]="); | 339 | fprintf(ctx->fp, "irfield = { [0]="); |
339 | for (i = 0; irfield_names[i]; i++) { | 340 | for (i = 0; irfield_names[i]; i++) { |
@@ -343,17 +344,17 @@ static void emit_vmdef(BuildCtx *ctx) | |||
343 | if (p) *p = '.'; | 344 | if (p) *p = '.'; |
344 | fprintf(ctx->fp, "\"%s\", ", buf); | 345 | fprintf(ctx->fp, "\"%s\", ", buf); |
345 | } | 346 | } |
346 | fprintf(ctx->fp, "}\n\n"); | 347 | fprintf(ctx->fp, "},\n\n"); |
347 | 348 | ||
348 | fprintf(ctx->fp, "ircall = {\n[0]="); | 349 | fprintf(ctx->fp, "ircall = {\n[0]="); |
349 | for (i = 0; ircall_names[i]; i++) | 350 | for (i = 0; ircall_names[i]; i++) |
350 | fprintf(ctx->fp, "\"%s\",\n", ircall_names[i]); | 351 | fprintf(ctx->fp, "\"%s\",\n", ircall_names[i]); |
351 | fprintf(ctx->fp, "}\n\n"); | 352 | fprintf(ctx->fp, "},\n\n"); |
352 | 353 | ||
353 | fprintf(ctx->fp, "traceerr = {\n[0]="); | 354 | fprintf(ctx->fp, "traceerr = {\n[0]="); |
354 | for (i = 0; trace_errors[i]; i++) | 355 | for (i = 0; trace_errors[i]; i++) |
355 | fprintf(ctx->fp, "\"%s\",\n", trace_errors[i]); | 356 | fprintf(ctx->fp, "\"%s\",\n", trace_errors[i]); |
356 | fprintf(ctx->fp, "}\n\n"); | 357 | fprintf(ctx->fp, "},\n\n"); |
357 | } | 358 | } |
358 | 359 | ||
359 | /* -- Argument parsing ---------------------------------------------------- */ | 360 | /* -- Argument parsing ---------------------------------------------------- */ |
@@ -490,6 +491,7 @@ int main(int argc, char **argv) | |||
490 | case BUILD_vmdef: | 491 | case BUILD_vmdef: |
491 | emit_vmdef(ctx); | 492 | emit_vmdef(ctx); |
492 | emit_lib(ctx); | 493 | emit_lib(ctx); |
494 | fprintf(ctx->fp, "}\n\n"); | ||
493 | break; | 495 | break; |
494 | case BUILD_ffdef: | 496 | case BUILD_ffdef: |
495 | case BUILD_libdef: | 497 | case BUILD_libdef: |