2. Register Use in the Stack Frame for Intel
x86
• ESP - Stack Pointer
• 存放 stack最top的位置
• EBP - Base Pointer
• 在目前stack frame中,可透過EBP的加減來得到函數的參數和區域變數
• EIP - Instruction Pointer
• 當執行call 和 jump時, EIP值會改變. 而其意義為紀錄跳躍時下一個指令的
位置
• 在x86_64中,這些register為16 bytes
3. Calling a __cdecl Function
• push parameters of the function由右至左進堆疊
• 在call the function時,把EIP push至堆疊中
• 在跳入function中, save 和 update the ebp
• push ebp
• mov ebp,esp // ebp <= esp
• push local variable of the function
• 如果此function有使用到某register必須先把此register push進stack
• 開始執行function
• Restore saved registers
• Release local storage
• Restore the old base pointer
• Return from the function
• Clean up pushed parameters
23. Linux Command
• nm - list symbols from object files
• cut - remove or "cut out" sections of each line of a file or
files
• xxd - make a hexdump or do the reverse
• sed - stream editor for filtering and transforming text
• objdump - display information from object files