I'm working on a homework assignment. We're given a pre-compiled binary and we have to use gdb
to get assembly dumps, traverse data structures, view values stored in memory, etc. in order to puzzle out what the binary does. Here are a few lines of disassembler dump from a function call:
0x08048e14 <+21>: test %esi,%esi
0x08048e16 <+23>: jne 0x8048e4b <fun6+76>
0x08048e18 <+25>: jmp 0x8048e5d <fun6+94>
I assumed that test %esi,%esi
would always return a result of "equals" (or, rather, the equivalent statement expressed using the register flags, which I believe is only ZF
is set?), and that the jne
instruction would never execute, and instead the program would execute the instruction at line <+25>
. However, after stepping through these instructions, the program jumps to line <+76>
! Why does this happen? I am so baffled.
In case it helps explain the answer, here are the register flags after the test
instruction at line <+21>
(ZF
isn't set?)(I still don't know exactly how to interpret the flags):
eflags 0x202 [ IF ]