-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathasm.txt
More file actions
328 lines (269 loc) · 7.06 KB
/
asm.txt
File metadata and controls
328 lines (269 loc) · 7.06 KB
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
translated static_table_translate(index Index)
{
static const translated Table[] =
{
TRANSLATED_A, // INDEX_A
TRANSLATED_B, // INDEX_B
TRANSLATED_C, // INDEX_C
TRANSLATED_D // INDEX_D
};
static_assert(sizeof(Table) / sizeof(translated) == INDEX_COUNT, "The translation table needs to be updated.");
assert(Index < INDEX_COUNT);
return Table[Index];
}
// Apple Clang 6.0
.globl __ZN12translation422static_table_translateENS_5indexE
.align 4, 0x90
__ZN12translation422static_table_translateENS_5indexE: ## @_ZN12translation422static_table_translateENS_5indexE
.cfi_startproc
## BB#0:
pushq %rbp
Ltmp7:
.cfi_def_cfa_offset 16
Ltmp8:
.cfi_offset %rbp, -16
movq %rsp, %rbp
Ltmp9:
.cfi_def_cfa_register %rbp
movl %edi, %eax
leaq __ZZN12translation422static_table_translateENS_5indexEE5Table(%rip), %rcx
movl (%rcx,%rax,4), %eax
popq %rbp
retq
.cfi_endproc
// Visual C++ 2013 - 'static const'
?static_table_translate@translation4@@YA?AW4translated@1@W4index@1@@Z PROC ; translation4::static_table_translate
; 51 : static const translated Table[] =
; 52 : {
; 53 : TRANSLATED_A, // INDEX_A
; 54 : TRANSLATED_B, // INDEX_B
; 55 : TRANSLATED_C, // INDEX_C
; 56 : TRANSLATED_D // INDEX_D
; 57 : };
; 58 :
; 59 : static_assert(sizeof(Table) / sizeof(translated) == INDEX_COUNT, "The translation table needs to be updated.");
; 60 : assert(Index < INDEX_COUNT);
; 61 :
; 62 : return Table[Index];
movsxd rax, ecx
lea rcx, OFFSET FLAT:?Table@?1??static_table_translate@translation4@@YA?AW4translated@2@W4index@2@@Z@4QBW432@B
mov eax, DWORD PTR [rcx+rax*4]
; 63 : }
// Visual C++ 2013 - 'const'
?const_table_translate@translation4@@YA?AW4translated@1@W4index@1@@Z PROC ; translation4::const_table_translate
; 34 : {
$LN4:
sub rsp, 40 ; 00000028H
mov rax, QWORD PTR __security_cookie
xor rax, rsp
mov QWORD PTR __$ArrayPad$[rsp], rax
movdqa xmm0, XMMWORD PTR __xmm@00008aef00002c35000001c20000a0e7
; 35 : const translated Table[] =
; 36 : {
; 37 : TRANSLATED_A, // INDEX_A
; 38 : TRANSLATED_B, // INDEX_B
; 39 : TRANSLATED_C, // INDEX_C
; 40 : TRANSLATED_D // INDEX_D
; 41 : };
; 42 :
; 43 : static_assert(sizeof(Table) / sizeof(translated) == INDEX_COUNT, "The translation table needs to be updated.");
; 44 : assert(Index < INDEX_COUNT);
; 45 :
; 46 : return Table[Index];
movsxd rax, ecx
movdqu XMMWORD PTR Table$[rsp], xmm0
mov eax, DWORD PTR Table$[rsp+rax*4]
; 47 : }
mov rcx, QWORD PTR __$ArrayPad$[rsp]
xor rcx, rsp
call __security_check_cookie
add rsp, 40 ; 00000028H
ret 0
?const_table_translate@translation4@@YA?AW4translated@1@W4index@1@@Z ENDP ; translation4::const_table_translate
ret 0
?static_table_translate@translation4@@YA?AW4translated@1@W4index@1@@Z ENDP ; translation4::static_table_translate
translated index_switch_translate(index Index)
{
switch(Index)
{
default:
case INDEX_A: return TRANSLATED_A;
case INDEX_B: return TRANSLATED_B;
case INDEX_C: return TRANSLATED_C;
case INDEX_D: return TRANSLATED_D;
}
}
.globl __ZN12translation422index_switch_translateENS_5indexE
.align 4, 0x90
__ZN12translation422index_switch_translateENS_5indexE: ## @_ZN12translation422index_switch_translateENS_5indexE
.cfi_startproc
## BB#0:
pushq %rbp
Ltmp37:
.cfi_def_cfa_offset 16
Ltmp38:
.cfi_offset %rbp, -16
movq %rsp, %rbp
Ltmp39:
.cfi_def_cfa_register %rbp
decl %edi
cmpl $2, %edi
ja LBB7_2
## BB#1: ## %switch.lookup
movslq %edi, %rax
leaq l_switch.table(%rip), %rcx
movl (%rcx,%rax,4), %eax
popq %rbp
retq
LBB7_2:
movl $41191, %eax ## imm = 0xA0E7
popq %rbp
retq
.cfi_endproc
// Visual C++ 2013
?index_switch_translate@translation4@@YA?AW4translated@1@W4index@1@@Z PROC ; translation4::index_switch_translate
; 100 : switch(Index)
test ecx, ecx
je SHORT $LN4@index_swit
dec ecx
je SHORT $LN3@index_swit
dec ecx
je SHORT $LN2@index_swit
dec ecx
jne SHORT $LN5@index_swit
; 105 : case INDEX_D: return TRANSLATED_D;
mov eax, 35567 ; 00008aefH
; 106 : }
; 107 : }
ret 0
$LN2@index_swit:
; 104 : case INDEX_C: return TRANSLATED_C;
mov eax, 11317 ; 00002c35H
; 106 : }
; 107 : }
ret 0
$LN3@index_swit:
; 103 : case INDEX_B: return TRANSLATED_B;
mov eax, 450 ; 000001c2H
; 106 : }
; 107 : }
ret 0
$LN4@index_swit:
; 101 : {
; 102 : case INDEX_A: return TRANSLATED_A;
mov eax, 41191 ; 0000a0e7H
$LN5@index_swit:
; 106 : }
; 107 : }
ret 0
?index_switch_translate@translation4@@YA?AW4translated@1@W4index@1@@Z ENDP ; translation4::index_switch_translate
// Clang - Without 'default:''
.globl __ZN12translation422index_switch_translateENS_5indexE
.align 4, 0x90
__ZN12translation422index_switch_translateENS_5indexE: ## @_ZN12translation422index_switch_translateENS_5indexE
.cfi_startproc
## BB#0:
pushq %rbp
Ltmp37:
.cfi_def_cfa_offset 16
Ltmp38:
.cfi_offset %rbp, -16
movq %rsp, %rbp
Ltmp39:
.cfi_def_cfa_register %rbp
cmpl $3, %edi
ja LBB7_2
## BB#1: ## %switch.lookup
movslq %edi, %rax
leaq l_switch.table(%rip), %rcx
movl (%rcx,%rax,4), %eax
LBB7_2:
popq %rbp
retq
.cfi_endproc
index value_switch_translate(translated Value)
{
switch(Value)
{
default:
case TRANSLATED_A: return INDEX_A;
case TRANSLATED_B: return INDEX_B;
case TRANSLATED_C: return INDEX_C;
case TRANSLATED_D: return INDEX_D;
}
}
Apple Clang 6.0.0
.globl __ZN12translation422value_switch_translateENS_10translatedE
.align 4, 0x90
__ZN12translation422value_switch_translateENS_10translatedE: ## @_ZN12translation422value_switch_translateENS_10translatedE
.cfi_startproc
## BB#0:
pushq %rbp
Ltmp42:
.cfi_def_cfa_offset 16
Ltmp43:
.cfi_offset %rbp, -16
movq %rsp, %rbp
Ltmp44:
.cfi_def_cfa_register %rbp
cmpl $35567, %edi ## imm = 0x8AEF
je LBB8_5
## BB#1:
cmpl $11317, %edi ## imm = 0x2C35
jne LBB8_2
## BB#4:
movl $2, %eax
popq %rbp
retq
LBB8_5:
movl $3, %eax
jmp LBB8_6
LBB8_2:
xorl %eax, %eax
cmpl $450, %edi ## imm = 0x1C2
jne LBB8_6
## BB#3:
movl $1, %eax
popq %rbp
retq
LBB8_6:
popq %rbp
retq
.cfi_endproc
Visual C++ 2013
?value_switch_translate@translation4@@YA?AW4index@1@W4translated@1@@Z PROC ; translation4::value_switch_translate
; 111 : switch(Value)
cmp ecx, 450 ; 000001c2H
je SHORT $LN3@value_swit
cmp ecx, 11317 ; 00002c35H
je SHORT $LN2@value_swit
cmp ecx, 35567 ; 00008aefH
je SHORT $LN1@value_swit
cmp ecx, 41191 ; 0000a0e7H
jne SHORT $LN5@value_swit
; 112 : {
; 113 : case TRANSLATED_A: return INDEX_A;
xor eax, eax
; 117 : }
; 118 : }
ret 0
$LN1@value_swit:
; 116 : case TRANSLATED_D: return INDEX_D;
mov eax, 3
; 117 : }
; 118 : }
ret 0
$LN2@value_swit:
; 115 : case TRANSLATED_C: return INDEX_C;
mov eax, 2
; 117 : }
; 118 : }
ret 0
$LN3@value_swit:
; 114 : case TRANSLATED_B: return INDEX_B;
mov eax, 1
$LN5@value_swit:
; 117 : }
; 118 : }
ret 0
?value_switch_translate@translation4@@YA?AW4index@1@W4translated@1@@Z ENDP ; translation4::value_switch_translates