summary refs log tree commit diff
path: root/amd64/emit.c
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin@c9x.me>2022-01-31 22:03:18 +0100
committerQuentin Carbonneaux <quentin@c9x.me>2022-02-02 21:09:37 +0100
commit2ca6fb25a238842418019a3f9ee8d1beb1327f7e (patch)
treebe083fc02dc8c1175f454b0adfd23d662f96476f /amd64/emit.c
parent20ee522ce8c4d1ffdd7b6e24a4f7af587c35404a (diff)
downloadroux-2ca6fb25a238842418019a3f9ee8d1beb1327f7e.tar.gz
shared linkage logic for func/data
Diffstat (limited to 'amd64/emit.c')
-rw-r--r--amd64/emit.c13
1 files changed, 2 insertions, 11 deletions
diff --git a/amd64/emit.c b/amd64/emit.c
index 4cb340d..b8e9e8e 100644
--- a/amd64/emit.c
+++ b/amd64/emit.c
@@ -548,18 +548,9 @@ 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", p, fn->name);
-	fprintf(f,
-		"%s%s:\n"
-		"\tpushq %%rbp\n"
-		"\tmovq %%rsp, %%rbp\n",
-		p, fn->name
-	);
+	gasemitlnk(fn->name, &fn->lnk, ".text", f);
+	fputs("\tpushq %rbp\n\tmovq %rsp, %rbp\n", f);
 	fs = framesz(fn);
 	if (fs)
 		fprintf(f, "\tsubq $%"PRIu64", %%rsp\n", fs);