Skip to content

Commit bcfde38

Browse files
committed
Tweak the missing switch case example binary
1 parent 73cc322 commit bcfde38

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

testbins/missing_switch_case_x64.asm

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ default rel
2626
%endif
2727

2828
start:
29-
; get pointer past switch constraint
29+
; get pointer past switch constraint (which binja static analyzed)
3030
lea rbx, [function_with_switch]
3131
mov edi, 14
3232
call mapper ; returns 7
33-
add rbx, rax
33+
add rbx, rax ; skip over switch constraint
3434

3535
; call secret cases
3636
mov rcx, 4
@@ -52,8 +52,6 @@ start:
5252
mov rdi, 3
5353
call function_with_switch
5454

55-
; exit
56-
5755
%ifdef OS_IS_LINUX
5856
mov rdi, 0 ; arg0: status
5957
mov rax, 60 ; __NR_exit
@@ -71,6 +69,9 @@ start:
7169
call ExitProcess
7270
%endif
7371

72+
; exit (so Binja knows end-of-function)
73+
ret
74+
7475
function_with_switch:
7576
; 00000000: 0x48, 0x89, 0xf9
7677
mov rcx, rdi ; arg0: 0,1,2,3
@@ -84,35 +85,35 @@ function_with_switch:
8485
jmp rdx
8586

8687
.case0:
87-
add rax, 0
88+
mov rax, 0
8889
jmp .switch_end
8990

9091
.case1:
91-
add rax, 1
92+
mov rax, 1
9293
jmp .switch_end
9394

9495
.case2:
95-
add rax, 2
96+
mov rax, 2
9697
jmp .switch_end
9798

9899
.case3:
99-
add rax, 3
100+
mov rax, 3
100101
jmp .switch_end
101102

102103
.case4:
103-
add rax, 4
104+
mov rax, 4
104105
jmp .switch_end
105106

106107
.case5:
107-
add rax, 5
108+
mov rax, 5
108109
jmp .switch_end
109110

110111
.case6:
111-
add rax, 6
112+
mov rax, 6
112113
jmp .switch_end
113114

114115
.case7:
115-
add rax, 7
116+
mov rax, 7
116117
jmp .switch_end
117118

118119
.switch_end:

0 commit comments

Comments
 (0)