summaryrefslogtreecommitdiff
path: root/6
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-11-18 11:29:09 -0800
committerOri Bernstein <ori@eigenstate.org>2015-11-18 11:45:43 -0800
commitf2027c43e0e85e679c4988954b8e9b35c0a1bdd3 (patch)
tree2eb9fbbd4529bf25c6cc408ecc7733b3911a62e1 /6
parent82ffa8d68b897200ae2fedc863aa7ac064660d1d (diff)
downloadmc-f2027c43e0e85e679c4988954b8e9b35c0a1bdd3.tar.gz
Fix BSS on OSX.
Our alignment was too big, and we really didn't need to leading '_'. In fact, we didn't even need zero blobs.
Diffstat (limited to '6')
-rw-r--r--6/asm.h2
-rw-r--r--6/blob.c13
-rw-r--r--6/gengas.c19
-rw-r--r--6/genp9.c2
4 files changed, 9 insertions, 27 deletions
diff --git a/6/asm.h b/6/asm.h
index 5d0477f..9b6dd1a 100644
--- a/6/asm.h
+++ b/6/asm.h
@@ -67,7 +67,6 @@ typedef enum {
Btbytes,
Btseq,
Btpad,
- Btzero,
} Blobtype;
struct Blob {
@@ -254,7 +253,6 @@ void gengas(Node *file, char *out);
void genp9(Node *file, char *out);
/* blob stuff */
-Blob *mkblobzero(size_t sz);
Blob *mkblobpad(size_t sz);
Blob *mkblobi(Blobtype type, uint64_t ival);
Blob *mkblobbytes(char *buf, size_t len);
diff --git a/6/blob.c b/6/blob.c
index bb3ab0c..a215e93 100644
--- a/6/blob.c
+++ b/6/blob.c
@@ -27,16 +27,6 @@ Blob *mkblobi(Blobtype type, uint64_t ival)
return b;
}
-Blob *mkblobzero(size_t sz)
-{
- Blob *b;
-
- b = zalloc(sizeof(Blob));
- b->type = Btzero;
- b->npad = sz;
- return b;
-}
-
Blob *mkblobpad(size_t sz)
{
Blob *b;
@@ -118,7 +108,8 @@ void b(Blob *b, Blob *n)
static size_t blobpad(Blob *seq, size_t sz)
{
- b(seq, mkblobpad(sz));
+ if (sz)
+ b(seq, mkblobpad(sz));
return sz;
}
diff --git a/6/gengas.c b/6/gengas.c
index 4d325c9..1b8cd62 100644
--- a/6/gengas.c
+++ b/6/gengas.c
@@ -300,13 +300,9 @@ static void writeblob(FILE *fd, Blob *b)
if (!b)
return;
if (b->lbl) {
- if (b->type == Btzero) {
- fprintf(fd, ".comm %s%s,%zd,16\n", Symprefix, b->lbl, b->npad);
- } else {
- if (b->isglobl)
- fprintf(fd, ".globl %s%s\n", Symprefix, b->lbl);
- fprintf(fd, "%s%s:\n", Symprefix, b->lbl);
- }
+ if (b->isglobl)
+ fprintf(fd, ".globl %s%s\n", Symprefix, b->lbl);
+ fprintf(fd, "%s%s:\n", Symprefix, b->lbl);
}
switch (b->type) {
case Btimin: encodemin(fd, b->ival); break;
@@ -316,7 +312,6 @@ static void writeblob(FILE *fd, Blob *b)
case Bti64: fprintf(fd, "\t.quad %zd\n", b->ival); break;
case Btbytes: writebytes(fd, b->bytes.buf, b->bytes.len); break;
case Btpad: fprintf(fd, "\t.fill %zd,1,0\n", b->npad); break;
- case Btzero: fprintf(fd, "\t.fill %zd,1,0\n", b->npad); break;
case Btref: fprintf(fd, "\t.quad %s + %zd\n", b->ref.str, b->ref.off); break;
case Btseq:
for (i = 0; i < b->seq.nsub; i++)
@@ -372,13 +367,13 @@ void genblob(FILE *fd, Node *blob, Htab *globls, Htab *strtab)
if (blob->decl.init) {
fprintf(fd, ".align %zd\n", tyalign(decltype(blob)));
fprintf(fd, "%s:\n", lbl);
+
b = litblob(globls, strtab, blob->decl.init);
+ writeblob(fd, b);
+ blobfree(b);
} else {
- b = mkblobzero(size(blob));
- b->lbl = lbl;
+ fprintf(fd, ".comm %s,%zd,5\n", lbl, size(blob));
}
- writeblob(fd, b);
- blobfree(b);
}
void gengas(Node *file, char *out)
diff --git a/6/genp9.c b/6/genp9.c
index a0d1d94..68e9d1b 100644
--- a/6/genp9.c
+++ b/6/genp9.c
@@ -355,8 +355,6 @@ static size_t writeblob(FILE *fd, Blob *b, size_t off, char *lbl)
fprintf(fd, "DATA %s+%zd(SB)/1,$0\n", lbl, off+n+i);
n += b->npad;
break;
- case Btzero:
- break;
}
return n;
}