diff options
author | Quentin Carbonneaux <quentin@c9x.me> | 2022-09-09 17:40:31 +0200 |
---|---|---|
committer | Quentin Carbonneaux <quentin@c9x.me> | 2022-10-08 21:48:42 +0200 |
commit | 00a30954aca97004cb6f586bdeeabb488f1e3c3f (patch) | |
tree | 951dc4c0a5be04fe7d5aed13f4201eb90c60f841 /amd64/emit.c | |
parent | 5cea0c20ee3573949a2c24e4b3dea65fcbf6e48b (diff) | |
download | roux-00a30954aca97004cb6f586bdeeabb488f1e3c3f.tar.gz |
add support for thread-local storage
The apple targets are not done yet.
Diffstat (limited to 'amd64/emit.c')
-rw-r--r-- | amd64/emit.c | 11 |
1 files changed, 7 insertions, 4 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) |