From 56f4b5be4cce50048e3f7980c59079de4748c6b9 Mon Sep 17 00:00:00 2001 From: Quentin Carbonneaux Date: Sun, 2 Apr 2023 15:44:28 +0200 Subject: amd64_sysv: fix offsets in thread-local Oaddr --- amd64/emit.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/amd64/emit.c b/amd64/emit.c index 7b2681e..46de3d9 100644 --- a/amd64/emit.c +++ b/amd64/emit.c @@ -372,6 +372,7 @@ emitins(Ins i, Fn *fn, FILE *f) int64_t val; int o, t0; Ins ineg; + Con *con; char *sym; switch (i.op) { @@ -498,10 +499,14 @@ emitins(Ins i, Fn *fn, FILE *f) /* derive the symbol address from the TCB * address at offset 0 of %fs */ assert(isreg(i.to)); - sym = str(fn->con[i.arg[0].val].sym.id); - emitf("movq %%fs:0, %=", &i, fn, f); - fprintf(f, "\tleaq %s%s@tpoff(%%%s), %%%s\n", - sym[0] == '"' ? "" : T.assym, sym, + con = &fn->con[i.arg[0].val]; + sym = str(con->sym.id); + emitf("movq %%fs:0, %L=", &i, fn, f); + fprintf(f, "\tleaq %s%s@tpoff", + sym[0] == '"' ? "" : T.assym, sym); + if (con->bits.i) + fprintf(f, "%+"PRId64, con->bits.i); + fprintf(f, "(%%%s), %%%s\n", regtoa(i.to.val, SLong), regtoa(i.to.val, SLong)); break; -- cgit 1.4.1