cse 351 section 4
play

CSE 351 Section 4 Program Stack & Procedure Calls Bomb Lab! - PowerPoint PPT Presentation

CSE 351 Section 4 Program Stack & Procedure Calls Bomb Lab! How is it going? Bomb-defusing tips If you have trouble figuring out what a phase is doing, try working backwards Write out everything that happens, and you might be


  1. CSE 351 Section 4 Program Stack & Procedure Calls

  2. Bomb Lab! ● How is it going?

  3. Bomb-defusing tips ● If you have trouble figuring out what a phase is doing, try working backwards ● Write out everything that happens, and you might be able to look back and see a pattern ● Try to understand what the phase is doing based on assembly code, then predict variable values and check your understanding in gdb

  4. Memory Layout

  5. Program Memory Layout HIGHER STACK ADDRESSES HEAP STATIC DATA STRINGS INSTRUCTIONS LOWER ADDRESSES

  6. Program Memory Layout Writeable; not STACK executable Writeable; not HEAP executable Writeable; not STATIC DATA executable Read-only; not STRINGS executable Read-only; INSTRUCTIONS executable

  7. IA32/Linux Register Usage %eax %edx Caller Save %ecx %ebx %edi Callee Save %esi %ebp Special %esp

  8. x86-64 Register Usage %rax Return Value %r8 Argument #5 %rbx Callee Saved %r9 Argument #6 %rcx Argument #4 %r10 Caller Saved %rdx Argument #3 %r11 Caller Saved %rsi Argument #2 %r12 Callee Saved %rdi Argument #1 %r13 Callee Saved %rsp Stack Pointer %r14 Callee Saved %rbp Callee Saved %r15 Callee Saved

  9. Demos

  10. Download these demos Multiple parameters demo http://www.cs.washington.edu/education/courses/cse351/12au/section-slides/multi-param.c wget http://www.cs.washington.edu/education/courses/cse351/12au/section-slides/multi-param.c Recursive stack frame demo http://www.cs.washington.edu/education/courses/cse351/12au/section-slides/fact_check.c wget http://www.cs.washington.edu/education/courses/cse351/12au/section-slides/fact_check.c

  11. Multiple Parameters Demo Demo commands: gcc -g -m64 multi-param.c -o multi-param64 gcc -g -m32 multi-param.c -o multi-param32 objdump -d multi-param64 | less objdump -d multi-param32 | less gdb multi-param64 GDB commands: break addEight, run, disas, info registers

  12. Recursive Stack Frame Demo Demo commands: gcc -g fact_check.c -o fact_check objdump -d fact_check.c | less gdb fact_check GDB commands: break factorial, run, disas, info frame, x /20x $esp

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend