diff options
| author | Archidemon <_dangerdl@mail.ru> | 2014-01-10 09:45:18 +0600 |
|---|---|---|
| committer | Archidemon <_dangerdl@mail.ru> | 2014-01-10 09:45:18 +0600 |
| commit | ea7b17f641cb962d0e9a79137e93c7e1e24b99ce (patch) | |
| tree | 5d75b4773d85acbcfae6f87b135512c8c7f87981 /tccgen.c | |
| parent | 935d8169b8e3570f1a5e726c5295be2f460c1540 (diff) | |
| download | tinycc-ea7b17f641cb962d0e9a79137e93c7e1e24b99ce.tar.gz tinycc-ea7b17f641cb962d0e9a79137e93c7e1e24b99ce.tar.bz2 | |
Fixes for PE x86_64 for fail in code
int (*fn1)=0x13fde16b5;
and
int fn1(int a) {...}
struct {
int (*fn2)(int a);
} b = { fn1 };
Diffstat (limited to 'tccgen.c')
| -rw-r--r-- | tccgen.c | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -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); |
