-
Notifications
You must be signed in to change notification settings - Fork 58
/
vex-r3400.patch
210 lines (194 loc) · 7.49 KB
/
vex-r3400.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
Index: Makefile-gcc
===================================================================
--- Makefile-gcc (revision 3400)
+++ Makefile-gcc (working copy)
@@ -43,7 +43,7 @@
priv/ir_match.o \
priv/ir_opt.o \
priv/ir_inject.o \
- priv/main_main.o \
+ priv/multiarch_main_main.o \
priv/main_globals.o \
priv/main_util.o \
priv/s390_disasm.o \
@@ -119,10 +119,6 @@
# (the above are for icc 8.0 -- 8.0.0.55 I think)
# 186: pointless comparison of unsigned integer with zero
-# kludge: stops V biarch builds screwing up at -j 2 or above
-# The Right fix is to autoconf/automake-ise vex.
-.NOTPARALLEL:
-
all: vex
# Empty, needed for Valgrind
@@ -254,6 +250,10 @@
$(CC) $(CCFLAGS) $(ALL_INCLUDES) -o priv/ir_opt.o \
-c priv/ir_opt.c
+priv/multiarch_main_main.o: $(ALL_HEADERS) priv/multiarch_main_main.c
+ $(CC) $(CCFLAGS) $(ALL_INCLUDES) -o priv/multiarch_main_main.o \
+ -c priv/multiarch_main_main.c
+
priv/main_main.o: $(ALL_HEADERS) priv/main_main.c
$(CC) $(CCFLAGS) $(ALL_INCLUDES) -o priv/main_main.o \
-c priv/main_main.c
Index: priv/config.h
===================================================================
--- priv/config.h (nonexistent)
+++ priv/config.h (working copy)
@@ -0,0 +1 @@
+/* Placeholder because we don't run configure */
Index: priv/guest_arm_toIR.c
===================================================================
--- priv/guest_arm_toIR.c (revision 3400)
+++ priv/guest_arm_toIR.c (working copy)
@@ -19143,7 +19143,7 @@
vassert(0 == (pc & 1));
UInt pageoff = pc & 0xFFF;
- if (pageoff >= 18) {
+ if (0 && pageoff >= 18) {
/* It's safe to poke about in the 9 halfwords preceding this
insn. So, have a look at them. */
guaranteedUnconditional = True; /* assume no 'it' insn found,
Index: priv/guest_x86_toIR.c
===================================================================
--- priv/guest_x86_toIR.c (revision 3400)
+++ priv/guest_x86_toIR.c (working copy)
@@ -2824,6 +2824,11 @@
if (epartIsReg(modrm)) {
switch (gregOfRM(modrm)) {
+ case 1: /* Undocumented synonym of 1 */
+ /* The Intel docs imply this insn is undefined and binutils
+ agrees. Unfortunately Core 2 will run it (with who
+ knows what result?) sandpile.org reckons it's an alias
+ for case 0. We live dangerously. */
case 0: { /* TEST */
delta++; d32 = getUDisp(sz, delta); delta += sz;
dst1 = newTemp(ty);
@@ -2835,13 +2840,6 @@
nameIReg(sz, eregOfRM(modrm)));
break;
}
- case 1: /* UNDEFINED */
- /* The Intel docs imply this insn is undefined and binutils
- agrees. Unfortunately Core 2 will run it (with who
- knows what result?) sandpile.org reckons it's an alias
- for case 0. We play safe. */
- *decode_OK = False;
- break;
case 2: /* NOT */
delta++;
putIReg(sz, eregOfRM(modrm),
@@ -2895,6 +2893,8 @@
delta += len;
assign(t1, loadLE(ty,mkexpr(addr)));
switch (gregOfRM(modrm)) {
+ case 1: /* Undocumented synonym of 1 */
+ /* See comment above on R case */
case 0: { /* TEST */
d32 = getUDisp(sz, delta); delta += sz;
dst1 = newTemp(ty);
@@ -2904,10 +2904,6 @@
DIP("test%c $0x%x, %s\n", nameISize(sz), d32, dis_buf);
break;
}
- case 1: /* UNDEFINED */
- /* See comment above on R case */
- *decode_OK = False;
- break;
case 2: /* NOT */
dst1 = newTemp(ty);
assign(dst1, unop(mkSizedOp(ty,Iop_Not8), mkexpr(t1)));
@@ -6247,7 +6243,6 @@
mkpair = Iop_32HLto64;
getres = left_shift ? Iop_64HIto32 : Iop_64to32;
shift = left_shift ? Iop_Shl64 : Iop_Shr64;
- mask = mkU8(31);
} else {
/* sz == 2 */
tmpL = newTemp(Ity_I32);
@@ -6256,9 +6251,16 @@
mkpair = Iop_16HLto32;
getres = left_shift ? Iop_32HIto16 : Iop_32to16;
shift = left_shift ? Iop_Shl32 : Iop_Shr32;
- mask = mkU8(15);
}
+ /* Note that we keep 5 bits of the shift amount even for 16-bit
+ operands. The manual says the result is undefined when the
+ shift amount is greater than the operand size, but that means
+ we still need to handle the case of shift_amt = 16 for 16-bit
+ operands. Luckily because we're doing the shift at double width,
+ this is compatible with the primops' restrictions. */
+ mask = mkU8(31);
+
/* Do the shift, calculate the subshift value, and set
the flag thunk. */
@@ -7626,7 +7628,8 @@
/* Generate IR to set the guest %EFLAGS from the pushfl-format image
in the given 32-bit temporary. The flags that are set are: O S Z A
- C P D ID AC.
+ C P D ID AC, except that ID and AC are not set if this was a 16-bit
+ popw.
In all cases, code to set AC is generated. However, VEX actually
ignores the AC value and so can optionally emit an emulation
@@ -7640,9 +7643,11 @@
static
void set_EFLAGS_from_value ( IRTemp t1,
Bool emit_AC_emwarn,
+ Int sz,
Addr32 next_insn_EIP )
{
vassert(typeOfIRTemp(irsb->tyenv,t1) == Ity_I32);
+ vassert(sz == 2 || sz == 4);
/* t1 is the flag word. Mask out everything except OSZACP and set
the flags thunk to X86G_CC_OP_COPY. */
@@ -7674,6 +7679,7 @@
mkU32(1)))
);
+ if (sz > 2) {
/* Set the ID flag */
stmt( IRStmt_Put(
OFFB_IDFLAG,
@@ -7712,6 +7718,7 @@
)
);
}
+ }
}
@@ -13097,6 +13104,7 @@
of iret. All it really does is:
popl %EIP; popl %CS; popl %EFLAGS.
%CS is set but ignored (as it is in (eg) popw %cs)". */
+ if (sz != 4) goto decode_failure; /* iretw is not yet supported */
t1 = newTemp(Ity_I32); /* ESP */
t2 = newTemp(Ity_I32); /* new EIP */
t3 = newTemp(Ity_I32); /* new CS */
@@ -13110,7 +13118,8 @@
/* set %CS (which is ignored anyway) */
putSReg( R_CS, unop(Iop_32to16, mkexpr(t3)) );
/* set %EFLAGS */
- set_EFLAGS_from_value( t4, False/*!emit_AC_emwarn*/, 0/*unused*/ );
+ set_EFLAGS_from_value( t4, False/*!emit_AC_emwarn*/, 4/*sz*/,
+ 0/*unused*/ );
/* goto new EIP value */
jmp_treg(&dres, Ijk_Ret, t2);
vassert(dres.whatNext == Dis_StopHere);
@@ -13118,11 +13127,13 @@
break;
case 0xE8: /* CALL J4 */
+ if (sz != 4) goto decode_failure;
d32 = getUDisp32(delta); delta += 4;
d32 += (guest_EIP_bbstart+delta);
/* (guest_eip_bbstart+delta) == return-to addr, d32 == call-to addr */
if (d32 == guest_EIP_bbstart+delta && getIByte(delta) >= 0x58
- && getIByte(delta) <= 0x5F) {
+ && getIByte(delta) <= 0x5F
+ && resteerOkFn( callback_opaque, (Addr64)(Addr32)d32 )) {
/* Specially treat the position-independent-code idiom
call X
X: popl %reg
@@ -13970,7 +13981,7 @@
/* Generate IR to set %EFLAGS{O,S,Z,A,C,P,D,ID,AC} from the
value in t1. */
- set_EFLAGS_from_value( t1, True/*emit_AC_emwarn*/,
+ set_EFLAGS_from_value( t1, True/*emit_AC_emwarn*/, sz,
((Addr32)guest_EIP_bbstart)+delta );
DIP("popf%c\n", nameISize(sz));