summaryrefslogtreecommitdiff
path: root/6
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-03-10 19:43:20 -0800
committerOri Bernstein <ori@eigenstate.org>2016-03-10 19:44:55 -0800
commit5269edd399f1b55f98e10fc5e809e22bec6c7bb1 (patch)
tree2f53682f7058f8071250f581f72b49d5623bf45d /6
parentf15c3cc3fc96cc9cd383f53d6dd662bfb835a1b2 (diff)
downloadmc-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.h3
-rw-r--r--6/gen.c10
-rw-r--r--6/gengas.c15
-rw-r--r--6/main.c9
4 files changed, 30 insertions, 7 deletions
diff --git a/6/asm.h b/6/asm.h
index ed75659..5b8f061 100644
--- a/6/asm.h
+++ b/6/asm.h
@@ -53,7 +53,8 @@ typedef enum {
} Rclass;
typedef enum {
- Gnugas,
+ Gnugaself,
+ Gnugasmacho,
Plan9,
} Asmsyntax;
diff --git a/6/gen.c b/6/gen.c
index a942b9e..1dd387a 100644
--- a/6/gen.c
+++ b/6/gen.c
@@ -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;
}
}
diff --git a/6/gengas.c b/6/gengas.c
index 6008d82..d439141 100644
--- a/6/gengas.c
+++ b/6/gengas.c
@@ -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);
diff --git a/6/main.c b/6/main.c
index d8ee23b..3315b40 100644
--- a/6/main.c
+++ b/6/main.c
@@ -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);