aboutsummaryrefslogtreecommitdiff
path: root/x86_64-gen.c
diff options
context:
space:
mode:
authorMichael Matz <matz@suse.de>2012-04-15 19:29:45 +0200
committerMichael Matz <matz@suse.de>2012-04-18 20:57:13 +0200
commit1d0a5c251553d8d9199ad18d4780bf356f456298 (patch)
tree1b15ed00535f7cbbff15a9e2ec5f3acbfa08654b /x86_64-gen.c
parent86ac6b9beec1c142867b53350006c02e20e4a7ef (diff)
downloadtinycc-1d0a5c251553d8d9199ad18d4780bf356f456298.tar.gz
tinycc-1d0a5c251553d8d9199ad18d4780bf356f456298.tar.bz2
x86_64: Fix segfault for global data
When offsetted addresses of global non-static data are computed multiple times in the same statement the x86_64 backend uses gen_gotpcrel with offset, which implements an add insn on the register given. load() uses the R member of the to-be-loaded value, which doesn't yet have a reg assigned in all cases. So use the register we're supposed to load the value into as that register.
Diffstat (limited to 'x86_64-gen.c')
-rw-r--r--x86_64-gen.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/x86_64-gen.c b/x86_64-gen.c
index 49cfdd1..0f86b3a 100644
--- a/x86_64-gen.c
+++ b/x86_64-gen.c
@@ -414,7 +414,7 @@ void load(int r, SValue *sv)
} else {
orex(1,0,r,0x8b);
o(0x05 + REG_VALUE(r) * 8); /* mov xx(%rip), r */
- gen_gotpcrel(fr, sv->sym, fc);
+ gen_gotpcrel(r, sv->sym, fc);
}
#endif
} else if (is64_type(ft)) {