aboutsummaryrefslogtreecommitdiff
path: root/tccgen.c
diff options
context:
space:
mode:
Diffstat (limited to 'tccgen.c')
-rw-r--r--tccgen.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/tccgen.c b/tccgen.c
index 7a675cc..99cab53 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -446,7 +446,7 @@ ST_FUNC void vpush_global_sym(CType *type, int v)
ST_FUNC void vset(CType *type, int r, int v)
{
- CValue cval;
+ CValue cval = {0};
cval.i = v;
vsetc(type, r, &cval);
@@ -1955,7 +1955,9 @@ static void gen_cast(CType *type)
s = 24;
else if ((dbt & VT_BTYPE) == VT_SHORT)
s = 16;
-
+#ifdef TCC_TARGET_X86_64
+ if (!(dbt & (VT_PTR|VT_LLONG|VT_FUNC|VT_STRUCT)))
+#endif
if(dbt & VT_UNSIGNED)
vtop->c.ui = ((unsigned int)vtop->c.ll << s) >> s;
else
@@ -3906,7 +3908,11 @@ ST_FUNC void unary(void)
/* if forward reference, we must point to s */
if (vtop->r & VT_SYM) {
vtop->sym = s;
- vtop->c.ul = 0;
+#ifdef TCC_TARGET_X86_64
+ s1->vtop->c.ull = 0;
+#else
+ s1->vtop->c.ul = 0;
+#endif
}
break;
}
@@ -5120,6 +5126,12 @@ static void init_putv(CType *type, Section *sec, unsigned long c,
case VT_LLONG:
*(long long *)ptr |= (vtop->c.ll & bit_mask) << bit_pos;
break;
+ case VT_PTR:
+ if (s1->vtop->r & VT_SYM) {
+ greloc(s1, sec, s1->vtop->sym, c, R_DATA_PTR);
+ }
+ *(addr_t *)ptr |= (s1->vtop->c.ull & bit_mask) << bit_pos;
+ break;
default:
if (vtop->r & VT_SYM) {
greloc(sec, vtop->sym, c, R_DATA_PTR);