diff options
author | Ori Bernstein <ori@eigenstate.org> | 2016-03-10 19:43:20 -0800 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2016-03-10 19:44:55 -0800 |
commit | 5269edd399f1b55f98e10fc5e809e22bec6c7bb1 (patch) | |
tree | 2f53682f7058f8071250f581f72b49d5623bf45d /6 | |
parent | f15c3cc3fc96cc9cd383f53d6dd662bfb835a1b2 (diff) | |
download | mc-5269edd399f1b55f98e10fc5e809e22bec6c7bb1.tar.gz |
Fix build on OSX, by deduping syms correctly.
With macho, we need to set a different attribute for asm
than we need on ELF targets.
Diffstat (limited to '6')
-rw-r--r-- | 6/asm.h | 3 | ||||
-rw-r--r-- | 6/gen.c | 10 | ||||
-rw-r--r-- | 6/gengas.c | 15 | ||||
-rw-r--r-- | 6/main.c | 9 |
4 files changed, 30 insertions, 7 deletions
@@ -53,7 +53,8 @@ typedef enum { } Rclass; typedef enum { - Gnugas, + Gnugaself, + Gnugasmacho, Plan9, } Asmsyntax; @@ -152,8 +152,12 @@ char *tydescid(char *buf, size_t bufsz, Type *ty) void gen(Node *file, char *out) { switch (asmsyntax) { - case Plan9: genp9(file, out); break; - case Gnugas: gengas(file, out); break; - default: die("unknown target"); break; + case Plan9: + genp9(file, out); break; + case Gnugaself: + case Gnugasmacho: + gengas(file, out); break; + default: + die("unknown target"); break; } } @@ -297,6 +297,19 @@ static void encodemin(FILE *fd, uint64_t val) } } +static void emitonce(FILE *fd, Blob *b) +{ + if (asmsyntax == Gnugaself) { + fprintf(fd, ".section .text.%s%s,\"aG\",%s%s,comdat\n", + Symprefix, b->lbl, Symprefix, b->lbl); + } else if (asmsyntax == Gnugasmacho) { + if (b->isglobl) + fprintf(fd, ".weak_def_can_be_hidden %s%s\n", Symprefix, b->lbl); + } else { + die("Unknown asm flavor"); + } +} + static void writeblob(FILE *fd, Blob *b) { size_t i; @@ -305,7 +318,7 @@ static void writeblob(FILE *fd, Blob *b) return; if (b->lbl) { if (b->iscomdat) - fprintf(fd, ".section .text.%s%s,\"aG\",%s%s,comdat\n", Symprefix, b->lbl, Symprefix, b->lbl); + emitonce(fd, b); if (b->isglobl) fprintf(fd, ".globl %s%s\n", Symprefix, b->lbl); fprintf(fd, "%s%s:\n", Symprefix, b->lbl); @@ -165,7 +165,7 @@ int main(int argc, char **argv) outfile = NULL; - optinit(&ctx, "cd:?hSo:I:9G", argv, argc); + optinit(&ctx, "cd:?hSo:I:9G:", argv, argc); asmsyntax = Defaultasm; while (!optdone(&ctx)) { switch (optnext(&ctx)) { @@ -191,7 +191,12 @@ int main(int argc, char **argv) asmsyntax = Plan9; break; case 'G': - asmsyntax = Gnugas; + if (!strcmp(ctx.optarg, "e")) + asmsyntax = Gnugaself; + else if (!strcmp(ctx.optarg, "m")) + asmsyntax = Gnugasmacho; + else + die("unknown gnu syntax flavor"); break; case 'I': lappend(&incpaths, &nincpaths, ctx.optarg); |