aboutsummaryrefslogtreecommitdiff
path: root/x86_64-gen.c
diff options
context:
space:
mode:
authorgrischka <grischka>2009-07-18 22:07:03 +0200
committergrischka <grischka>2009-07-18 22:07:03 +0200
commitbb5e0df79acbe7fa36d0ff14485657b94cc5cd5f (patch)
tree9edacb40152eae879adb444b25254b5ec24f0f80 /x86_64-gen.c
parentfc977d56c90b6c6a54b7e831b5c88e37f54a5cae (diff)
downloadtinycc-bb5e0df79acbe7fa36d0ff14485657b94cc5cd5f.tar.gz
tinycc-bb5e0df79acbe7fa36d0ff14485657b94cc5cd5f.tar.bz2
x86-64: fix load() for const pointers: (void*)-2
Diffstat (limited to 'x86_64-gen.c')
-rw-r--r--x86_64-gen.c43
1 files changed, 22 insertions, 21 deletions
diff --git a/x86_64-gen.c b/x86_64-gen.c
index cc68e34..593cd61 100644
--- a/x86_64-gen.c
+++ b/x86_64-gen.c
@@ -191,6 +191,7 @@ static int oad(int c, int s)
return s;
}
+#if 0
/* output constant with relocation if 'r & VT_SYM' is true */
static void gen_addr64(int r, Sym *sym, int64_t c)
{
@@ -198,6 +199,7 @@ static void gen_addr64(int r, Sym *sym, int64_t c)
greloc(cur_text_section, sym, ind, R_X86_64_64);
gen_le64(c);
}
+#endif
/* output constant with relocation if 'r & VT_SYM' is true */
static void gen_addrpc32(int r, Sym *sym, int c)
@@ -354,30 +356,29 @@ void load(int r, SValue *sv)
gen_modrm(r, fr, sv->sym, fc);
} else {
if (v == VT_CONST) {
- if ((ft & VT_BTYPE) == VT_LLONG) {
- assert(!(fr & VT_SYM));
+ if (fr & VT_SYM) {
+#ifdef TCC_TARGET_PE
+ o(0x8d48);
+ o(0x05 + REG_VALUE(r) * 8); /* lea xx(%rip), r */
+ gen_addrpc32(fr, sv->sym, fc);
+#else
+ if (sv->sym->type.t & VT_STATIC) {
+ o(0x8d48);
+ o(0x05 + REG_VALUE(r) * 8); /* lea xx(%rip), r */
+ gen_addrpc32(fr, sv->sym, fc);
+ } else {
+ o(0x8b48);
+ o(0x05 + REG_VALUE(r) * 8); /* mov xx(%rip), r */
+ gen_gotpcrel(r, sv->sym, fc);
+ }
+#endif
+ } else if (is64_type(ft)) {
o(0x48);
o(0xb8 + REG_VALUE(r)); /* mov $xx, r */
- gen_addr64(fr, sv->sym, sv->c.ull);
+ gen_le64(sv->c.ull);
} else {
- if (fr & VT_SYM) {
-#ifndef TCC_TARGET_PE
- if (sv->sym->type.t & VT_STATIC) {
-#endif
- o(0x8d48);
- o(0x05 + REG_VALUE(r) * 8); /* lea xx(%rip), r */
- gen_addrpc32(fr, sv->sym, fc);
-#ifndef TCC_TARGET_PE
- } else {
- o(0x8b48);
- o(0x05 + REG_VALUE(r) * 8); /* mov xx(%rip), r */
- gen_gotpcrel(r, sv->sym, fc);
- }
-#endif
- } else {
- o(0xb8 + REG_VALUE(r)); /* mov $xx, r */
- gen_le32(fc);
- }
+ o(0xb8 + REG_VALUE(r)); /* mov $xx, r */
+ gen_le32(fc);
}
} else if (v == VT_LOCAL) {
o(0x48 | REX_BASE(r));