diff options
| author | Michael Matz <matz@suse.de> | 2016-07-11 16:26:36 +0200 |
|---|---|---|
| committer | Michael Matz <matz@suse.de> | 2016-12-15 17:47:07 +0100 |
| commit | 10c351488901667059181cf034dd500354f352ed (patch) | |
| tree | f4d97bfb0151f724a21fc9e653e59a372fd82ae1 /tccgen.c | |
| parent | 920474115c3182b19008598b0def86cb8fdf1318 (diff) | |
| download | tinycc-10c351488901667059181cf034dd500354f352ed.tar.gz tinycc-10c351488901667059181cf034dd500354f352ed.tar.bz2 | |
Accept symbols in initializers also on 64 bit
Those should use long or long long type, and generate a 64bit reloc.
Diffstat (limited to 'tccgen.c')
| -rw-r--r-- | tccgen.c | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -5777,7 +5777,7 @@ static void init_putv(CType *type, Section *sec, unsigned long c, /* XXX: make code faster ? */ if (!(type->t & VT_BITFIELD)) { bit_pos = 0; - bit_size = 32; + bit_size = PTR_SIZE * 8; bit_mask = -1LL; } else { bit_pos = (vtop->type.t >> VT_STRUCT_SHIFT) & 0x3f; @@ -5789,8 +5789,14 @@ static void init_putv(CType *type, Section *sec, unsigned long c, bt == VT_SHORT || bt == VT_DOUBLE || bt == VT_LDOUBLE || - bt == VT_LLONG || - (bt == VT_INT && bit_size != 32))) +#if PTR_SIZE == 8 + (bt == VT_LLONG && bit_size != 64) || + bt == VT_INT +#else + bt == VT_LLONG || + (bt == VT_INT && bit_size != 32) +#endif + )) tcc_error("initializer element is not computable at load time"); switch(bt) { /* XXX: when cross-compiling we assume that each type has the @@ -5815,9 +5821,13 @@ static void init_putv(CType *type, Section *sec, unsigned long c, else tcc_error("can't cross compile long double constants"); break; +#if PTR_SIZE != 8 case VT_LLONG: *(long long *)ptr |= (vtop->c.i & bit_mask) << bit_pos; break; +#else + case VT_LLONG: +#endif case VT_PTR: { addr_t val = (vtop->c.i & bit_mask) << bit_pos; #if defined(TCC_TARGET_ARM64) || defined(TCC_TARGET_X86_64) |
