Set Intel For GDB:
reader@hacking:~/booksrc $ gdb -q (gdb) set dis intel (gdb) quit reader@hacking:~/booksrc $ echo "set dis intel" > ~/.gdbinit reader@hacking:~/booksrc $ cat ~/.gdbinit set dis intel
0 Comments
Source: Hacking: The Art of Exploitation, Jon Erickson
#include <stdio.h> int main() { int i; for(i=0; i < 10; i++) { printf("Hello, world!\n"); } return 0; } gcc -o firstprog.out firstprog.c objdump -D a.out | grep -A20 main.: objdump -M intel -D a.out | grep -A20 main.: x86 General Purpose Registers
EIP - instruction pointer ESP - stack pointer EBP - base pointer ESI - source index EDI - destination index EAX - accumulator EBX - base ECX - counter EDX - data EAX, ECX, EDX, and EBX-> Accumulator, Counter, Data, and Base registers [They are used for a variety of purposes, but they mainly act as temporary variables for the CPU when it is executing machine instructions] ESP, EBP, ESI, and EDI ->Stack Pointer, Base Pointer, Source Index, and Destination Index, respectively. The first two registers are called pointers because they store 32-bit addresses, which essentially point to that location in memory. These registers are fairly important to program execution and memory management; we will discuss them more later. The la st two registers are also technically pointers, which are commonly used to point to the source and dest ination when data needs to be read from or written to. The EIP register is the Instruction Pointer register, which points to the current instruction the processor is reading. The remaining EFLAGS register actually consists of several bit flags that are used for comparisons and memory segmentations. |