diff options
| author | Mike Pall <mike> | 2010-01-10 09:39:05 +0100 |
|---|---|---|
| committer | Mike Pall <mike> | 2010-01-10 09:39:05 +0100 |
| commit | 767035f0311cd16fca001acbb26a4a6cca239405 (patch) | |
| tree | 9bb2e4cbe7f03e69ce3999e328ba48ca1b518c2f | |
| parent | 99d153bef9725db226614558d01df829afafee3c (diff) | |
| download | luajit-767035f0311cd16fca001acbb26a4a6cca239405.tar.gz luajit-767035f0311cd16fca001acbb26a4a6cca239405.tar.bz2 luajit-767035f0311cd16fca001acbb26a4a6cca239405.zip | |
Strip '@' suffix from external symbols for MACH-O, too.
Fixes OSX build.
| -rw-r--r-- | src/buildvm_asm.c | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/src/buildvm_asm.c b/src/buildvm_asm.c index cc821365..bd835ebc 100644 --- a/src/buildvm_asm.c +++ b/src/buildvm_asm.c | |||
| @@ -23,27 +23,18 @@ static void emit_asm_bytes(BuildCtx *ctx, uint8_t *p, int n) | |||
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | /* Emit relocation */ | 25 | /* Emit relocation */ |
| 26 | static void emit_asm_reloc(BuildCtx *ctx, BuildReloc *r) | 26 | static void emit_asm_reloc(BuildCtx *ctx, int type, const char *sym) |
| 27 | { | 27 | { |
| 28 | const char *sym = ctx->extnames[r->sym]; | ||
| 29 | const char *p = strchr(sym, '@'); | ||
| 30 | char buf[80]; | ||
| 31 | if (p) { | ||
| 32 | /* Always strip fastcall suffix. Wrong for (unused) COFF on Win32. */ | ||
| 33 | strncpy(buf, sym, p-sym); | ||
| 34 | buf[p-sym] = '\0'; | ||
| 35 | sym = buf; | ||
| 36 | } | ||
| 37 | switch (ctx->mode) { | 28 | switch (ctx->mode) { |
| 38 | case BUILD_elfasm: | 29 | case BUILD_elfasm: |
| 39 | if (r->type) | 30 | if (type) |
| 40 | fprintf(ctx->fp, "\t.long %s-.-4\n", sym); | 31 | fprintf(ctx->fp, "\t.long %s-.-4\n", sym); |
| 41 | else | 32 | else |
| 42 | fprintf(ctx->fp, "\t.long %s\n", sym); | 33 | fprintf(ctx->fp, "\t.long %s\n", sym); |
| 43 | break; | 34 | break; |
| 44 | case BUILD_coffasm: | 35 | case BUILD_coffasm: |
| 45 | 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); |
| 46 | if (r->type) | 37 | if (type) |
| 47 | fprintf(ctx->fp, "\t.long _%s-.-4\n", sym); | 38 | fprintf(ctx->fp, "\t.long _%s-.-4\n", sym); |
| 48 | else | 39 | else |
| 49 | fprintf(ctx->fp, "\t.long _%s\n", sym); | 40 | fprintf(ctx->fp, "\t.long _%s\n", sym); |
| @@ -173,13 +164,21 @@ void emit_asm(BuildCtx *ctx) | |||
| 173 | emit_asm_label(ctx, name, size, 1); | 164 | emit_asm_label(ctx, name, size, 1); |
| 174 | } | 165 | } |
| 175 | while (rel < ctx->nreloc && ctx->reloc[rel].ofs < stop) { | 166 | while (rel < ctx->nreloc && ctx->reloc[rel].ofs < stop) { |
| 176 | int n = ctx->reloc[rel].ofs - prev; | 167 | BuildReloc *r = &ctx->reloc[rel]; |
| 177 | if (ctx->mode == BUILD_machasm && ctx->reloc[rel].type != 0) { | 168 | int n = r->ofs - prev; |
| 178 | emit_asm_reloc_mach(ctx, ctx->code+prev, n, | 169 | const char *sym = ctx->extnames[r->sym]; |
| 179 | ctx->extnames[ctx->reloc[rel].sym]); | 170 | const char *p = strchr(sym, '@'); |
| 171 | if (p) { | ||
| 172 | /* Always strip fastcall suffix. Wrong for (unused) COFF on Win32. */ | ||
| 173 | strncpy(name, sym, p-sym); | ||
| 174 | name[p-sym] = '\0'; | ||
| 175 | sym = name; | ||
| 176 | } | ||
| 177 | if (ctx->mode == BUILD_machasm && r->type != 0) { | ||
| 178 | emit_asm_reloc_mach(ctx, ctx->code+prev, n, sym); | ||
| 180 | } else { | 179 | } else { |
| 181 | emit_asm_bytes(ctx, ctx->code+prev, n); | 180 | emit_asm_bytes(ctx, ctx->code+prev, n); |
| 182 | emit_asm_reloc(ctx, &ctx->reloc[rel]); | 181 | emit_asm_reloc(ctx, r->type, sym); |
| 183 | } | 182 | } |
| 184 | prev += n+4; | 183 | prev += n+4; |
| 185 | rel++; | 184 | rel++; |
