From 9e7e5bffc4e4af37a6c29657ba87fbb6a1123cf2 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Tue, 14 May 2019 14:34:23 -0700 Subject: Allow specifying literal global names --- amd64/emit.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'amd64/emit.c') 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) -- cgit 1.4.1