diff options
author | Michael Forney <mforney@mforney.org> | 2019-05-14 14:34:23 -0700 |
---|---|---|
committer | Quentin Carbonneaux <quentin@c9x.me> | 2019-05-15 10:20:12 +0200 |
commit | 9e7e5bffc4e4af37a6c29657ba87fbb6a1123cf2 (patch) | |
tree | 9273d3f42153ce7d08db6ad6c97bb4852ebd2d0a /amd64 | |
parent | 72f2e8445adaeeb4916690263f65d6b61ffa5c1d (diff) | |
download | roux-9e7e5bffc4e4af37a6c29657ba87fbb6a1123cf2.tar.gz |
Allow specifying literal global names
Diffstat (limited to 'amd64')
-rw-r--r-- | amd64/emit.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/amd64/emit.c b/amd64/emit.c index d4bd54c..d8b29bd 100644 --- a/amd64/emit.c +++ b/amd64/emit.c @@ -161,12 +161,13 @@ slot(int s, Fn *fn) static void emitcon(Con *con, FILE *f) { - char *p; + char *p, *l; switch (con->type) { case CAddr: - p = con->local ? gasloc : gassym; - fprintf(f, "%s%s", p, str(con->label)); + l = str(con->label); + p = con->local ? gasloc : l[0] == '"' ? "" : gassym; + fprintf(f, "%s%s", p, l); if (con->bits.i) fprintf(f, "%+"PRId64, con->bits.i); break; @@ -539,15 +540,17 @@ amd64_emitfn(Fn *fn, FILE *f) Ins *i, itmp; int *r, c, o, n, lbl; uint64_t fs; + char *p; + p = fn->name[0] == '"' ? "" : gassym; fprintf(f, ".text\n"); if (fn->export) - fprintf(f, ".globl %s%s\n", gassym, fn->name); + fprintf(f, ".globl %s%s\n", p, fn->name); fprintf(f, "%s%s:\n" "\tpushq %%rbp\n" "\tmovq %%rsp, %%rbp\n", - gassym, fn->name + p, fn->name ); fs = framesz(fn); if (fs) |