Use something like objdump -f
to show you the numeric value of the entry point address. Or inside gdb, info files
will show you the entry point.
Copy/paste that value into a gdb command: b *0x...
to break at the entry point. You can then single-step from there.
See also the bottom of the x86 tag wiki for some asm-debugging tips, like layout reg
.
Sample output from objdump -f
:
/bin/ls: file format elf64-x86-64
architecture: i386:x86-64, flags 0x00000112:
EXEC_P, HAS_SYMS, D_PAGED
start address 0x0000000000404870 <<---- copy this address
Instead of finding the entry-point address
b *0
will cause an error when gdb tries to set the breakpoint. This results in stopping before any instructions execute, at the entry point. Delete the bogus breakpoint (or it will keep erroring when you try to single-step or continue).
Stopping at the first machine code instruction in GDB