Bomb lab assignment I cant figure out phase 4 Dump of assemb
Bomb lab assignment, I can\'t figure out phase 4.
Dump of assembler code for function phase_4:
=> 0x0000000000401159 <+0>: sub $0x18,%rsp
0x000000000040115d <+4>: mov %fs:0x28,%rax
0x0000000000401166 <+13>: mov %rax,0x8(%rsp)
0x000000000040116b <+18>: xor %eax,%eax
0x000000000040116d <+20>: mov %rsp,%rcx
0x0000000000401170 <+23>: lea 0x4(%rsp),%rdx
0x0000000000401175 <+28>: mov $0x402a6d,%esi
0x000000000040117a <+33>: callq 0x400c40 <__isoc99_sscanf@plt>
0x000000000040117f <+38>: cmp $0x2,%eax
0x0000000000401182 <+41>: jne 0x40118f <phase_4+54>
0x0000000000401184 <+43>: mov (%rsp),%eax
0x0000000000401187 <+46>: sub $0x2,%eax
0x000000000040118a <+49>: cmp $0x2,%eax
0x000000000040118d <+52>: jbe 0x401194 <phase_4+59>
0x000000000040118f <+54>: callq 0x40177c <explode_bomb>
0x0000000000401194 <+59>: mov (%rsp),%esi
0x0000000000401197 <+62>: mov $0x8,%edi
0x000000000040119c <+67>: callq 0x40111e <func4>
0x00000000004011a1 <+72>: cmp 0x4(%rsp),%eax
0x00000000004011a5 <+76>: je 0x4011ac <phase_4+83>
0x00000000004011a7 <+78>: callq 0x40177c <explode_bomb>
0x00000000004011ac <+83>: mov 0x8(%rsp),%rax
0x00000000004011b1 <+88>: xor %fs:0x28,%rax
0x00000000004011ba <+97>: je 0x4011c1 <phase_4+104>
0x00000000004011bc <+99>: callq 0x400b90 <__stack_chk_fail@plt>
0x00000000004011c1 <+104>: add $0x18,%rsp
0x00000000004011c5 <+108>: retq
End of assembler dump.
Dump of assembler code for function func4:
0x000000000040111e <+0>: test %edi,%edi
0x0000000000401120 <+2>: jle 0x40114d <func4+47>
0x0000000000401122 <+4>: mov %esi,%eax
0x0000000000401124 <+6>: cmp $0x1,%edi
0x0000000000401127 <+9>: je 0x401157 <func4+57>
0x0000000000401129 <+11>: push %r12
0x000000000040112b <+13>: push %rbp
0x000000000040112c <+14>: push %rbx
0x000000000040112d <+15>: mov %esi,%ebp
0x000000000040112f <+17>: mov %edi,%ebx
0x0000000000401131 <+19>: lea -0x1(%rdi),%edi
0x0000000000401134 <+22>: callq 0x40111e <func4>
0x0000000000401139 <+27>: lea 0x0(%rbp,%rax,1),%r12d
0x000000000040113e <+32>: lea -0x2(%rbx),%edi
0x0000000000401141 <+35>: mov %ebp,%esi
0x0000000000401143 <+37>: callq 0x40111e <func4>
0x0000000000401148 <+42>: add %r12d,%eax
0x000000000040114b <+45>: jmp 0x401153 <func4+53>
0x000000000040114d <+47>: mov $0x0,%eax
0x0000000000401152 <+52>: retq
0x0000000000401153 <+53>: pop %rbx
0x0000000000401154 <+54>: pop %rbp
0x0000000000401155 <+55>: pop %r12
0x0000000000401157 <+57>: repz retq
Solution
Dump of assembler code for function func4 <+0>: mov %rbx,-0x18(%rsp) <+5>: mov %rbp, -0x10(%rsp) <+10>: mov %r12,-0x8(%rsp) <+15>: sub $0x18,%rsp <+19>: mov %edi,%ebx <+21>: mov %esi,%ebp <+23>: test %edi, %edi <+25>: jg 0x400fb2
