History

Fixes for PE x86_64 for fail in code

int (*fn1)=0x13fde16b5; and int fn1(int a) {...} struct { int (*fn2)(int a); } b = { fn1 };

Archidemon committed 12 years ago

Commit ea7b17f1 parent 935d8161 file · +15 −3Browse files

Unified · Split

tccgen.c+15−3
@@ -446,7 +446,7 @@ ST_FUNC void vpush_global_sym(CType *type, int v) · 445 unmodified lines
446446
447447 ST_FUNC void vset(CType *type, int r, int v)
448448 {
449− CValue cval;
449+ CValue cval = {0};
450450
451451 cval.i = v;
452452 vsetc(type, r, &cval);
@@ -1955,7 +1955,9 @@ static void gen_cast(CType *type) · 1502 unmodified lines
19551955 s = 24;
19561956 else if ((dbt & VT_BTYPE) == VT_SHORT)
19571957 s = 16;
1958−
1958+#ifdef TCC_TARGET_X86_64
1959+ if (!(dbt & (VT_PTR|VT_LLONG|VT_FUNC|VT_STRUCT)))
1960+#endif
19591961 if(dbt & VT_UNSIGNED)
19601962 vtop->c.ui = ((unsigned int)vtop->c.ll << s) >> s;
19611963 else
@@ -3906,7 +3908,11 @@ ST_FUNC void unary(void) · 1944 unmodified lines
39063908 /* if forward reference, we must point to s */
39073909 if (vtop->r & VT_SYM) {
39083910 vtop->sym = s;
3909− vtop->c.ul = 0;
3911+#ifdef TCC_TARGET_X86_64
3912+ s1->vtop->c.ull = 0;
3913+#else
3914+ s1->vtop->c.ul = 0;
3915+#endif
39103916 }
39113917 break;
39123918 }
@@ -5120,6 +5126,12 @@ static void init_putv(CType *type, Section *sec, unsigned long c, · 1207 unmodified lines
51205126 case VT_LLONG:
51215127 *(long long *)ptr |= (vtop->c.ll & bit_mask) << bit_pos;
51225128 break;
5129+ case VT_PTR:
5130+ if (s1->vtop->r & VT_SYM) {
5131+ greloc(s1, sec, s1->vtop->sym, c, R_DATA_PTR);
5132+ }
5133+ *(addr_t *)ptr |= (s1->vtop->c.ull & bit_mask) << bit_pos;
5134+ break;
51235135 default:
51245136 if (vtop->r & VT_SYM) {
51255137 greloc(sec, vtop->sym, c, R_DATA_PTR);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t