Переглянути джерело

amd64_sysv: fix offsets in thread-local Oaddr

Quentin Carbonneaux 2 роки тому
батько
коміт
56f4b5be4c
1 змінених файлів з 9 додано та 4 видалено
  1. 9 4
      amd64/emit.c

+ 9 - 4
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;