summary refs log tree commit diff
path: root/amd64
diff options
context:
space:
mode:
Diffstat (limited to 'amd64')
-rw-r--r--amd64/emit.c11
-rw-r--r--amd64/isel.c3
2 files changed, 8 insertions, 6 deletions
diff --git a/amd64/emit.c b/amd64/emit.c
index db6ead8..cf36ebe 100644
--- a/amd64/emit.c
+++ b/amd64/emit.c
@@ -166,8 +166,11 @@ emitcon(Con *con, FILE *f)
 	switch (con->type) {
 	case CAddr:
 		l = str(con->label);
-		p = con->local ? T.asloc : l[0] == '"' ? "" : T.assym;
-		fprintf(f, "%s%s", p, l);
+		p = l[0] == '"' ? "" : T.assym;
+		if (con->rel == RelThr)
+			fprintf(f, "%%fs:%s%s@tpoff", p, l);
+		else
+			fprintf(f, "%s%s", p, l);
 		if (con->bits.i)
 			fprintf(f, "%+"PRId64, con->bits.i);
 		break;
@@ -337,7 +340,7 @@ Next:
 		case RCon:
 			off = fn->con[ref.val];
 			emitcon(&off, f);
-			if (off.type == CAddr)
+			if (off.type == CAddr && off.rel != RelThr)
 				fprintf(f, "(%%rip)");
 			break;
 		case RTmp:
@@ -549,7 +552,7 @@ emitfn(Fn *fn, FILE *f)
 	int *r, c, o, n, lbl;
 	uint64_t fs;
 
-	emitlnk(fn->name, &fn->lnk, ".text", f);
+	emitfnlnk(fn->name, &fn->lnk, f);
 	fputs("\tpushq %rbp\n\tmovq %rsp, %rbp\n", f);
 	fs = framesz(fn);
 	if (fs)
diff --git a/amd64/isel.c b/amd64/isel.c
index 640bf12..a562441 100644
--- a/amd64/isel.c
+++ b/amd64/isel.c
@@ -78,9 +78,8 @@ fixarg(Ref *r, int k, Ins *i, Fn *fn)
 		vgrow(&fn->mem, ++fn->nmem);
 		memset(&a, 0, sizeof a);
 		a.offset.type = CAddr;
-		a.offset.local = 1;
 		n = stashbits(&fn->con[r0.val].bits, KWIDE(k) ? 8 : 4);
-		sprintf(buf, "fp%d", n);
+		sprintf(buf, "\"%sfp%d\"", T.asloc, n);
 		a.offset.label = intern(buf);
 		fn->mem[fn->nmem-1] = a;
 	}