The Runtime Environment CSE 340 – Principles of Programming Languages Fall 2015 Adam Doupé Arizona State University
Adam Doupé, Principles of Programming Languages Locations and Names What is the semantic distinction between locations and names? How does the compiler actually implement locations and names? –How does the compiler map names to memory locations? We are going to look into this process –Assuming static scoping 2
Adam Doupé, Principles of Programming Languages Global Variables Where can the compiler put variables? –Memory –Registers –Disk –"Cloud" What are the constraints on those variables? –Who can access them? –Who can't? 3
Adam Doupé, Principles of Programming Languages int a; int b; float c; int main() { a = 10; b = 100; c = 10.45; a = a + b; return 0; } 4 0x x x804963c movl $0xa,0x movl $0x64,0x mov $0x ,%eax mov %eax,0x804963c mov 0x ,%edx mov 0x ,%eax lea (%edx,%eax,1),%eax mov %eax,0x A B C mem[A] = 10 mem[B] = 100 mem[C] = mem[A] = mem[A] + mem[B]
Adam Doupé, Principles of Programming Languages Local Variables What are the constraints on local variables? Where can the compiler place local variables? –Global Memory (one for each function) 5
Adam Doupé, Principles of Programming Languages int fact(int n) { if (n == 0) { return 1; } else { return fact(n-1) * n; } } 6
Adam Doupé, Principles of Programming Languages Local Variables What are the constraints on local variables? Where can the compiler place local variables? –Global Memory (one for each function) –"Scratch memory" for each function 7
Adam Doupé, Principles of Programming Languages The Stack Stack is essentially scratch memory for functions –Used in MIPS, ARM, x86, and x86-64 processors Starts at high memory addresses, and grows down Functions are free to push registers or values onto the stack, or pop values from the stack into registers The assembly language supports this on x86 – %esp holds the address of the top of the stack – push %eax decrements the stack pointer ( %esp ) then stores the value in %eax to the location pointed to by the stack pointer – pop %eax stores the value at the location pointed to by the stack pointer into %eax, then increments the stack pointer ( %esp ) 8
Adam Doupé, Principles of Programming Languages Stack Example … … Garbage 9 0xFFFFFFFF 0x x10000 %eax0xa %ebx0x0 %esp0x10000 push %eax pop %ebx
Adam Doupé, Principles of Programming Languages Stack Example … … Garbage 10 0xFFFFFFFF 0x x10000 %eax0xa %ebx0x0 %esp0x10000 push %eax pop %ebx
Adam Doupé, Principles of Programming Languages Stack Example … … Garbage 11 0xFFFFFFFF 0x x10000 %eax0xa %ebx0x0 %esp0x10000 push %eax pop %ebx
Adam Doupé, Principles of Programming Languages Stack Example … 0xa … Garbage 12 0xFFFFFFFF 0x x10000 %eax0xa %ebx0x0 %esp0xFFFC push %eax pop %ebx
Adam Doupé, Principles of Programming Languages Stack Example … 0xa … Garbage 13 0xFFFFFFFF 0x x10000 %eax0xa %ebx0x0 %esp0xFFFC push %eax pop %ebx
Adam Doupé, Principles of Programming Languages Stack Example … 0xa … Garbage 14 0xFFFFFFFF 0x x10000 %eax0xa %ebx0xa %esp0xFFFC push %eax pop %ebx
Adam Doupé, Principles of Programming Languages Stack Example … 0xa … Garbage 15 0xFFFFFFFF 0x x10000 %eax0xa %ebx0xa %esp0x10000 push %eax pop %ebx
Adam Doupé, Principles of Programming Languages Function Frame Functions would like to use the stack to allocate space for their local variables Can we use the stack pointer for this? –Yes, however stack pointer can change throughout program execution Frame pointer points to the start of the function's frame on the stack –Each local variable will be (different) offsets of the frame pointer –In x86, frame pointer is called the base pointer, and is stored in %ebp 16
Adam Doupé, Principles of Programming Languages int main() { int a; int b; float c; a = 10; b = 100; c = 10.45; a = a + b; return 0; } 17 %ebp – 0xc %ebp – 0x8 %ebp – 0x4 mov %esp,%ebp sub $0x10,%esp movl $0xa,-0xc(%ebp) movl $0x64,-0x8(%ebp) mov $0x ,%eax mov %eax,-0x4(%ebp) mov -0x8(%ebp),%eax add %eax,-0xc(%ebp) %ebp + A %ebp + B %ebp + C mem[%ebp+A] = 10 mem[%ebp+B] = 100 mem[%ebp+C] = mem[%ebp+A] = mem[%ebp+A] + mem[%ebp+B]
Adam Doupé, Principles of Programming Languages Function Frame … 18 0xFFFFFFFF 0x x10000 %eax %esp0x10000 %ebp0x10000 mov %esp,%ebp sub $0x10,%esp movl $0xa,-0xc(%ebp) movl $0x64,-0x8(%ebp) mov $0x ,%eax mov %eax,-0x4(%ebp) mov -0x8(%ebp),%eax add %eax,-0xc(%ebp)
Adam Doupé, Principles of Programming Languages Function Frame … 19 0xFFFFFFFF 0x x10000 %eax %esp0x10000 %ebp0x10000 mov %esp,%ebp sub $0x10,%esp movl $0xa,-0xc(%ebp) movl $0x64,-0x8(%ebp) mov $0x ,%eax mov %eax,-0x4(%ebp) mov -0x8(%ebp),%eax add %eax,-0xc(%ebp)
Adam Doupé, Principles of Programming Languages Function Frame … 20 0xFFFFFFFF 0x x10000 %eax %esp0xFFF0 %ebp0x10000 mov %esp,%ebp sub $0x10,%esp movl $0xa,-0xc(%ebp) movl $0x64,-0x8(%ebp) mov $0x ,%eax mov %eax,-0x4(%ebp) mov -0x8(%ebp),%eax add %eax,-0xc(%ebp)
Adam Doupé, Principles of Programming Languages Function Frame … 21 0xFFFFFFFF 0x x10000 %eax %esp0xFFF0 %ebp0x10000 mov %esp,%ebp sub $0x10,%esp movl $0xa,-0xc(%ebp) movl $0x64,-0x8(%ebp) mov $0x ,%eax mov %eax,-0x4(%ebp) mov -0x8(%ebp),%eax add %eax,-0xc(%ebp) 0xFFFC 0xFFF8 0xFFF4 0xFFF0
Adam Doupé, Principles of Programming Languages Function Frame … 0xa 22 0xFFFFFFFF 0x x10000 %eax %esp0xFFF0 %ebp0x10000 mov %esp,%ebp sub $0x10,%esp movl $0xa,-0xc(%ebp) movl $0x64,-0x8(%ebp) mov $0x ,%eax mov %eax,-0x4(%ebp) mov -0x8(%ebp),%eax add %eax,-0xc(%ebp) 0xFFFC 0xFFF8 0xFFF4 0xFFF0
Adam Doupé, Principles of Programming Languages Function Frame … 0xa 23 0xFFFFFFFF 0x x10000 %eax %esp0xFFF0 %ebp0x10000 mov %esp,%ebp sub $0x10,%esp movl $0xa,-0xc(%ebp) movl $0x64,-0x8(%ebp) mov $0x ,%eax mov %eax,-0x4(%ebp) mov -0x8(%ebp),%eax add %eax,-0xc(%ebp) 0xFFFC 0xFFF8 0xFFF4 0xFFF0
Adam Doupé, Principles of Programming Languages Function Frame … 0x64 0xa 24 0xFFFFFFFF 0x x10000 %eax %esp0xFFF0 %ebp0x10000 mov %esp,%ebp sub $0x10,%esp movl $0xa,-0xc(%ebp) movl $0x64,-0x8(%ebp) mov $0x ,%eax mov %eax,-0x4(%ebp) mov -0x8(%ebp),%eax add %eax,-0xc(%ebp) 0xFFFC 0xFFF8 0xFFF4 0xFFF0
Adam Doupé, Principles of Programming Languages Function Frame … 0x64 0xa 25 0xFFFFFFFF 0x x10000 %eax %esp0xFFF0 %ebp0x10000 mov %esp,%ebp sub $0x10,%esp movl $0xa,-0xc(%ebp) movl $0x64,-0x8(%ebp) mov $0x ,%eax mov %eax,-0x4(%ebp) mov -0x8(%ebp),%eax add %eax,-0xc(%ebp) 0xFFFC 0xFFF8 0xFFF4 0xFFF0
Adam Doupé, Principles of Programming Languages Function Frame … 0x64 0xa 26 0xFFFFFFFF 0x x10000 %eax0x %esp0xFFF0 %ebp0x10000 mov %esp,%ebp sub $0x10,%esp movl $0xa,-0xc(%ebp) movl $0x64,-0x8(%ebp) mov $0x ,%eax mov %eax,-0x4(%ebp) mov -0x8(%ebp),%eax add %eax,-0xc(%ebp) 0xFFFC 0xFFF8 0xFFF4 0xFFF0
Adam Doupé, Principles of Programming Languages Function Frame … 0x64 0xa 27 0xFFFFFFFF 0x x10000 %eax0x %esp0xFFF0 %ebp0x10000 mov %esp,%ebp sub $0x10,%esp movl $0xa,-0xc(%ebp) movl $0x64,-0x8(%ebp) mov $0x ,%eax mov %eax,-0x4(%ebp) mov -0x8(%ebp),%eax add %eax,-0xc(%ebp) 0xFFFC 0xFFF8 0xFFF4 0xFFF0
Adam Doupé, Principles of Programming Languages Function Frame … 0x x64 0xa 28 0xFFFFFFFF 0x x10000 %eax0x %esp0xFFF0 %ebp0x10000 mov %esp,%ebp sub $0x10,%esp movl $0xa,-0xc(%ebp) movl $0x64,-0x8(%ebp) mov $0x ,%eax mov %eax,-0x4(%ebp) mov -0x8(%ebp),%eax add %eax,-0xc(%ebp) 0xFFFC 0xFFF8 0xFFF4 0xFFF0
Adam Doupé, Principles of Programming Languages Function Frame … 0x x64 0xa 29 0xFFFFFFFF 0x x10000 %eax0x %esp0xFFF0 %ebp0x10000 mov %esp,%ebp sub $0x10,%esp movl $0xa,-0xc(%ebp) movl $0x64,-0x8(%ebp) mov $0x ,%eax mov %eax,-0x4(%ebp) mov -0x8(%ebp),%eax add %eax,-0xc(%ebp) 0xFFFC 0xFFF8 0xFFF4 0xFFF0 c b a
Adam Doupé, Principles of Programming Languages Function Frame … 0x x64 0xa 30 0xFFFFFFFF 0x x10000 %eax0x64 %esp0xFFF0 %ebp0x10000 mov %esp,%ebp sub $0x10,%esp movl $0xa,-0xc(%ebp) movl $0x64,-0x8(%ebp) mov $0x ,%eax mov %eax,-0x4(%ebp) mov -0x8(%ebp),%eax add %eax,-0xc(%ebp) 0xFFFC 0xFFF8 0xFFF4 0xFFF0 c b a
Adam Doupé, Principles of Programming Languages Function Frame … 0x x64 0xa 31 0xFFFFFFFF 0x x10000 %eax0x64 %esp0xFFF0 %ebp0x10000 mov %esp,%ebp sub $0x10,%esp movl $0xa,-0xc(%ebp) movl $0x64,-0x8(%ebp) mov $0x ,%eax mov %eax,-0x4(%ebp) mov -0x8(%ebp),%eax add %eax,-0xc(%ebp) 0xFFFC 0xFFF8 0xFFF4 0xFFF0 c b a
Adam Doupé, Principles of Programming Languages Function Frame … 0x x64 0x6E 32 0xFFFFFFFF 0x x10000 %eax0x64 %esp0xFFF0 %ebp0x10000 mov %esp,%ebp sub $0x10,%esp movl $0xa,-0xc(%ebp) movl $0x64,-0x8(%ebp) mov $0x ,%eax mov %eax,-0x4(%ebp) mov -0x8(%ebp),%eax add %eax,-0xc(%ebp) 0xFFFC 0xFFF8 0xFFF4 0xFFF0 c b a
Adam Doupé, Principles of Programming Languages Function Frame … 0x x64 0x6E 33 0xFFFFFFFF 0x x10000 %eax0x64 %esp0xFFF0 %ebp0x10000 mov %esp,%ebp sub $0x10,%esp movl $0xa,-0xc(%ebp) movl $0x64,-0x8(%ebp) mov $0x ,%eax mov %eax,-0x4(%ebp) mov -0x8(%ebp),%eax add %eax,-0xc(%ebp) 0xFFFC 0xFFF8 0xFFF4 0xFFF0 c b a
Adam Doupé, Principles of Programming Languages Functions Declarations –Function name –Formal parameters (names and types) –Return type Invocation –f(x 1,x 2,…,x k ) –x 1,x 2,...,x k are expressions –x 1,x 2,...x k are called the actual parameters –Invoking function must create the frame on the stack with enough space to hold the actual parameters 34
Adam Doupé, Principles of Programming Languages Function Frames Allows us to allocate memory for the function's local variables However, when considering calling a function, what other information do we need? –Return value –Parameters –Our frame pointer –Return address (where to start program execution when function returns) –Local variables –Temporary variables 35
Adam Doupé, Principles of Programming Languages Calling Convention All of the previous information must be stored on the stack in order to call the function Who should store that information? –Caller? –Callee? Thus, we need to define a convention of who pushes/stores what values on the stack to call a function –Varies based on processor, operating system, compiler, or type of call 36
Adam Doupé, Principles of Programming Languages x86 Linux Calling Convention (cdecl) Caller (in this order) –Pushes arguments onto the stack (in right to left order) –Pushes address of instruction after call Callee –Pushes previous frame pointer onto stack –Creates space on stack for local variables –Ensures that stack is consistant on return –Return value in %eax register 37
Adam Doupé, Principles of Programming Languages int callee(int a, int b) { return a + b + 1; } int main() { int a; a = callee(10, 40); return a; } 38 callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call callee mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret prologue epilogue prologue epilogue
Adam Doupé, Principles of Programming Languages 39 0xFFFFFFFF 0x xfd2d4 %eax %edx %esp0xfd2d4 %ebp0xfd2c0 %eip0x80483a5 callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6
Adam Doupé, Principles of Programming Languages 40 0xFFFFFFFF 0x %eax %edx %esp0xfd2d0 %ebp0xfd2c0 %eip0x80483a5 callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4
Adam Doupé, Principles of Programming Languages 0xfd2c0 41 0xFFFFFFFF 0x %eax %edx %esp0xfd2d0 %ebp0xfd2c0 %eip0x80483a5 callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4
Adam Doupé, Principles of Programming Languages 0xfd2c0 42 0xFFFFFFFF 0x %eax %edx %esp0xfd2d0 %ebp0xfd2c0 %eip0x80483a5 callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4
Adam Doupé, Principles of Programming Languages 0xfd2c0 43 0xFFFFFFFF 0x %eax %edx %esp0xfd2d0 %ebp0xfd2c0 %eip0x80483a6 callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4
Adam Doupé, Principles of Programming Languages 0xfd2c0 44 0xFFFFFFFF 0x %eax %edx %esp0xfd2d0 %ebp0xfd2d0 %eip0x80483a6 callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4
Adam Doupé, Principles of Programming Languages 0xfd2c0 45 0xFFFFFFFF 0x %eax %edx %esp0xfd2d0 %ebp0xfd2d0 %eip0x80483a8 callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4
Adam Doupé, Principles of Programming Languages 0xfd2c0 46 0xFFFFFFFF 0x %eax %edx %esp0xfd2b8 %ebp0xfd2d0 %eip0x80483a8 callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8
Adam Doupé, Principles of Programming Languages 0xfd2c0 47 0xFFFFFFFF 0x %eax %edx %esp0xfd2b8 %ebp0xfd2d0 %eip0x80483ab callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x xFFFFFFFF 0x %eax %edx %esp0xfd2b8 %ebp0xfd2d0 %eip0x80483ab callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x xFFFFFFFF 0x %eax %edx %esp0xfd2b8 %ebp0xfd2d0 %eip0x80483b3 callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x28 0xa 50 0xFFFFFFFF 0x %eax %edx %esp0xfd2b8 %ebp0xfd2d0 %eip0x80483b3 callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x28 0xa 51 0xFFFFFFFF 0x %eax %edx %esp0xfd2b8 %ebp0xfd2d0 %eip0x80483ba callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x28 0xa 52 0xFFFFFFFF 0x %eax %edx %esp0xfd2b4 %ebp0xfd2d0 %eip0x80483ba callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x28 0xa 0x80483bf 53 0xFFFFFFFF 0x %eax %edx %esp0xfd2b4 %ebp0xfd2d0 %eip0x callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc 0xfd2b4
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x28 0xa 0x80483bf 54 0xFFFFFFFF 0x %eax %edx %esp0xfd2b4 %ebp0xfd2d0 %eip0x callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc 0xfd2b4
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x28 0xa 0x80483bf 55 0xFFFFFFFF 0x %eax %edx %esp0xfd2b0 %ebp0xfd2d0 %eip0x callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc 0xfd2b4 0xfd2b0
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x28 0xa 0x80483bf 56 0xFFFFFFFF 0x %eax %edx %esp0xfd2b0 %ebp0xfd2d0 %eip0x callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc 0xfd2b4 0xfd2b0
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x28 0xa 0x80483bf 0xfd2d0 57 0xFFFFFFFF 0x %eax %edx %esp0xfd2b0 %ebp0xfd2d0 %eip0x callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc 0xfd2b4 0xfd2b0
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x28 0xa 0x80483bf 0xfd2d0 58 0xFFFFFFFF 0x %eax %edx %esp0xfd2b0 %ebp0xfd2d0 %eip0x callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc 0xfd2b4 0xfd2b0
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x28 0xa 0x80483bf 0xfd2d0 59 0xFFFFFFFF 0x %eax %edx %esp0xfd2b0 %ebp0xfd2b0 %eip0x callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc 0xfd2b4 0xfd2b0
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x28 0xa 0x80483bf 0xfd2d0 60 0xFFFFFFFF 0x %eax %edx %esp0xfd2b0 %ebp0xfd2b0 %eip0x callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc 0xfd2b4 0xfd2b0
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x28 0xa 0x80483bf 0xfd2d0 61 0xFFFFFFFF 0x %eax %edx %esp0xfd2b0 %ebp0xfd2b0 %eip0x callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc 0xfd2b4 0xfd2b0 maincallee
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x28 0xa 0x80483bf 0xfd2d0 62 0xFFFFFFFF 0x %eax0x28 %edx %esp0xfd2b0 %ebp0xfd2b0 %eip0x callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc 0xfd2b4 0xfd2b0
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x28 0xa 0x80483bf 0xfd2d0 63 0xFFFFFFFF 0x %eax0x28 %edx %esp0xfd2b0 %ebp0xfd2b0 %eip0x804839a callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc 0xfd2b4 0xfd2b0
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x28 0xa 0x80483bf 0xfd2d0 64 0xFFFFFFFF 0x %eax0x28 %edx0xa %esp0xfd2b0 %ebp0xfd2b0 %eip0x804839a callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc 0xfd2b4 0xfd2b0
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x28 0xa 0x80483bf 0xfd2d0 65 0xFFFFFFFF 0x %eax0x28 %edx0xa %esp0xfd2b0 %ebp0xfd2b0 %eip0x804839d callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc 0xfd2b4 0xfd2b0
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x28 0xa 0x80483bf 0xfd2d0 66 0xFFFFFFFF 0x %eax0x32 %edx0xa %esp0xfd2b0 %ebp0xfd2b0 %eip0x804839d callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc 0xfd2b4 0xfd2b0
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x28 0xa 0x80483bf 0xfd2d0 67 0xFFFFFFFF 0x %eax0x32 %edx0xa %esp0xfd2b0 %ebp0xfd2b0 %eip0x80483a0 callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc 0xfd2b4 0xfd2b0
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x28 0xa 0x80483bf 0xfd2d0 68 0xFFFFFFFF 0x %eax0x33 %edx0xa %esp0xfd2b0 %ebp0xfd2b0 %eip0x80483a0 callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc 0xfd2b4 0xfd2b0
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x28 0xa 0x80483bf 0xfd2d0 69 0xFFFFFFFF 0x %eax0x33 %edx0xa %esp0xfd2b0 %ebp0xfd2b0 %eip0x80483a3 callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc 0xfd2b4 0xfd2b0
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x28 0xa 0x80483bf 0xfd2d0 70 0xFFFFFFFF 0x %eax0x33 %edx0xa %esp0xfd2b0 %ebp0xfd2d0 %eip0x80483a3 callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc 0xfd2b4 0xfd2b0
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x28 0xa 0x80483bf 0xfd2d0 71 0xFFFFFFFF 0x %eax0x33 %edx0xa %esp0xfd2b4 %ebp0xfd2d0 %eip0x80483a3 callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc 0xfd2b4 0xfd2b0
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x28 0xa 0x80483bf 0xfd2d0 72 0xFFFFFFFF 0x %eax0x33 %edx0xa %esp0xfd2b4 %ebp0xfd2d0 %eip0x80483a3 callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc 0xfd2b4 0xfd2b0
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x28 0xa 0x80483bf 0xfd2d0 73 0xFFFFFFFF 0x %eax0x33 %edx0xa %esp0xfd2b4 %ebp0xfd2d0 %eip0x80483a4 callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc 0xfd2b4 0xfd2b0
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x28 0xa 0x80483bf 0xfd2d0 74 0xFFFFFFFF 0x %eax0x33 %edx0xa %esp0xfd2b4 %ebp0xfd2d0 %eip0x80483bf callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc 0xfd2b4 0xfd2b0
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x28 0xa 0x80483bf 0xfd2d0 75 0xFFFFFFFF 0x %eax0x33 %edx0xa %esp0xfd2b8 %ebp0xfd2d0 %eip0x80483bf callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc 0xfd2b4 0xfd2b0
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x28 0xa 0x80483bf 0xfd2d0 76 0xFFFFFFFF 0x %eax0x33 %edx0xa %esp0xfd2b8 %ebp0xfd2d0 %eip0x80483bf callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc 0xfd2b4 0xfd2b0
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x28 0xa 0x80483bf 0xfd2d0 77 0xFFFFFFFF 0x %eax0x33 %edx0xa %esp0xfd2b8 %ebp0xfd2d0 %eip0x80483bf callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc 0xfd2b4 0xfd2b0
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x33 0x28 0xa 0x80483bf 0xfd2d0 78 0xFFFFFFFF 0x %eax0x33 %edx0xa %esp0xfd2b8 %ebp0xfd2d0 %eip0x80483bf callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc 0xfd2b4 0xfd2b0 0xfd2cc
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x33 0x28 0xa 0x80483bf 0xfd2d0 79 0xFFFFFFFF 0x %eax0x33 %edx0xa %esp0xfd2b8 %ebp0xfd2d0 %eip0x80483c2 callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc 0xfd2b4 0xfd2b0 0xfd2cc
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x33 0x28 0xa 0x80483bf 0xfd2d0 80 0xFFFFFFFF 0x %eax0x33 %edx0xa %esp0xfd2b8 %ebp0xfd2d0 %eip0x80483c2 callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc 0xfd2b4 0xfd2b0 0xfd2cc
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x33 0x28 0xa 0x80483bf 0xfd2d0 81 0xFFFFFFFF 0x %eax0x33 %edx0xa %esp0xfd2b8 %ebp0xfd2d0 %eip0x80483c5 callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc 0xfd2b4 0xfd2b0 0xfd2cc
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x33 0x28 0xa 0x80483bf 0xfd2d0 82 0xFFFFFFFF 0x %eax0x33 %edx0xa %esp0xfd2d0 %ebp0xfd2d0 %eip0x80483c5 callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc 0xfd2b4 0xfd2b0 0xfd2cc
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x33 0x28 0xa 0x80483bf 0xfd2d0 83 0xFFFFFFFF 0x %eax0x33 %edx0xa %esp0xfd2d0 %ebp0xfd2c0 %eip0x80483c5 callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc 0xfd2b4 0xfd2b0 0xfd2cc
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x33 0x28 0xa 0x80483bf 0xfd2d0 84 0xFFFFFFFF 0x %eax0x33 %edx0xa %esp0xfd2d4 %ebp0xfd2c0 %eip0x80483c5 callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc 0xfd2b4 0xfd2b0 0xfd2cc
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x33 0x28 0xa 0x80483bf 0xfd2d0 85 0xFFFFFFFF 0x %eax0x33 %edx0xa %esp0xfd2d4 %ebp0xfd2c0 %eip0x80483c5 callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc 0xfd2b4 0xfd2b0 0xfd2cc
Adam Doupé, Principles of Programming Languages 0xfd2c0 0x33 0x28 0xa 0x80483bf 0xfd2d0 86 0xFFFFFFFF 0x %eax0x33 %edx0xa %esp0xfd2d4 %ebp0xfd2c0 %eip0x80483c6 callee: push %ebp mov %esp,%ebp mov 0xc(%ebp),%eax mov 0x8(%ebp),%edx lea (%edx,%eax,1),%eax add $0x1,%eax pop %ebp ret main: push %ebp mov %esp,%ebp sub $0x18,%esp movl $0x28,0x4(%esp) movl $0xa,(%esp) call 0x mov %eax,-0x4(%ebp) mov -0x4(%ebp),%eax leave ret 0x x x x804839a 0x804839d 0x80483a0 0x80483a3 0x80483a4 0x80483a5 0x80483a6 0x80483a8 0x80483ab 0x80483b3 0x80483ba 0x80483bf 0x80483c2 0x80483c5 0x80483c6 0xfd2d4 0xfd2d0 0xfd2b8 0xfd2bc 0xfd2b4 0xfd2b0 0xfd2cc
Adam Doupé, Principles of Programming Languages Function Parameter Passing How did the previous example pass parameters to the function callee? –Pushed the values onto the stack What are the semantics of passing parameters to a function? Multiple approaches –Pass by value –Pass by reference –Pass by name 87
Adam Doupé, Principles of Programming Languages Pass by Value Values of the actual parameters at function invocation are calculated and then copied to the function –We have seen how this is done for C, a copy of the values are placed on the stack 88
Adam Doupé, Principles of Programming Languages #include int x; void test(int x) { x = x + 5; printf("%d\n", x); } int main() { int y = 4; test(y); printf("%d\n", y); return y; } 89 gcc –Wall pass_by_value.c 9 4 y 4 x 4 9
Adam Doupé, Principles of Programming Languages Pass by Reference The formal parameters are bound to the locations associated with the actual parameters –Thus, the actual parameters must be l-values 90
Adam Doupé, Principles of Programming Languages #include int x; void test(int& x) { x = x + 5; printf("%d\n", x); } int main() { int y = 4; test(y); printf("%d\n", y); return y; } 91 g++ –Wall pass_by_value.c 9 9 x y 49
Adam Doupé, Principles of Programming Languages Pass by name The formal parameters are replaced by the text of the actual parameters everywhere in the fucntion that the formal parameters occur 92
Adam Doupé, Principles of Programming Languages #include int x; void test(int x) { x = x + 5; printf("%d\n", x); } int main() { int y = 4; test(y); printf("%d\n", y); return y; } void test(int y) { y = y + 5; printf("%d\n", y); } 93 gcc –Wall pass_by_name_1.c 9 9
Adam Doupé, Principles of Programming Languages #include int i; int a[10]; void inc(int x) { i++; x++; } int main() { i = 1; a[1] = 1; a[2] = 2; inc(a[i]); printf("%d\n%d\n%d\n", i, a[1], a[2]); return 0; } void inc(int a[i]) { i++; a[i]++; } 94 gcc –Wall pass_by_name_2.c 2 1 3
Adam Doupé, Principles of Programming Languages #include int i; int p(int y) { int j = y; i++; return j + y; } void q() { int j = 2; i = 0; printf("%d\n", p(i+j)); } int main() { q(); return 0; } int p(int (i+j)) { int j = (i+j); i++; return j + (i+j); } 95 gcc –Wall pass_by_name_3.c 5
Adam Doupé, Principles of Programming Languages #include int foo(int test) { return 10; } int main() { int a = 0; int b = foo(a++); printf("%d\n%d\n", a, b); return 0; } int foo(int a++) { return 10; } 96 gcc –Wall pass_by_name_4.c 0 10
Adam Doupé, Principles of Programming Languages #include int i; int p(int y) { int j = y; i++; return j + y; } void q() { int j = 2; i = 0; printf("%d\n", p(i+j)); } int main() { q(); return 0; } #include int i, j; int i_plus_j() { return i+j; } int p(int (*y)(void)) { int j = y(); i++; return j + y(); } void q() { j = 2; i = 0; printf("%d\n", p(i_plus_j)); } int main() { q(); return 0; } 97 gcc –Wall pass_by_name_simulation.c 5
Adam Doupé, Principles of Programming Languages Java What is the parameter passing semantics of Java? –Pass by value? –Pass by reference? –Pass by name? 98
Adam Doupé, Principles of Programming Languages class Testing { int foo; } public class ParameterPassing { public static void main(String [] args) { Testing bar = new Testing(); Testing snap = new Testing(); bar.foo = 0; snap.foo = 10; PassByQuestionMark(bar, snap); System.out.println(bar.foo + "\n" + snap.foo); } public static void PassByQuestionMark(Testing a, Testing b) { b = new Testing(); b.foo = 100; a.foo = 42; } } 99
Adam Doupé, Principles of Programming Languages Java Essentially pass by value and assignment share semantics Note that this is not standard terminology How is it implemented under-the-hood? 100
Adam Doupé, Principles of Programming Languages Implications of Cdecl Saved EBP and saved EIP are stored on the stack What prevents a program/function from writing/changing those values? –What would happen if they did? 101
Adam Doupé, Principles of Programming Languages #include void mycpy(char* str) { char foo[4]; strcpy(foo, str); } int main() { callee("asu cse 340 fall 2015 rocks!"); printf("After"); return 0; } 102 mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret
Adam Doupé, Principles of Programming Languages 103 0xFFFFFFFF 0x xfd2d4 %eax %esp0xfd2d4 %ebp0xfd2e0 %eip0x804840e mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret 0x80483f4 0x80483f5 0x80483f7 0x80483fa 0x80483fd 0x x x x804840c 0x804840d 0x804840e 0x804840f 0x x x804841e 0x x x804842b 0x x x
Adam Doupé, Principles of Programming Languages 0xfd2e xFFFFFFFF 0x xfd2d4 %eax %esp0xfd2d0 %ebp0xfd2e0 %eip0x804840e mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret 0x80483f4 0x80483f5 0x80483f7 0x80483fa 0x80483fd 0x x x x804840c 0x804840d 0x804840e 0x804840f 0x x x804841e 0x x x804842b 0x x x
Adam Doupé, Principles of Programming Languages 0xfd2e xFFFFFFFF 0x xfd2d4 %eax %esp0xfd2d0 %ebp0xfd2e0 %eip0x804840f mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret 0x80483f4 0x80483f5 0x80483f7 0x80483fa 0x80483fd 0x x x x804840c 0x804840d 0x804840e 0x804840f 0x x x804841e 0x x x804842b 0x x x
Adam Doupé, Principles of Programming Languages 0xfd2e xFFFFFFFF 0x xfd2d4 %eax %esp0xfd2d0 %ebp0xfd2d0 %eip0x804840f mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret 0x80483f4 0x80483f5 0x80483f7 0x80483fa 0x80483fd 0x x x x804840c 0x804840d 0x804840e 0x804840f 0x x x804841e 0x x x804842b 0x x x
Adam Doupé, Principles of Programming Languages 0xfd2e xFFFFFFFF 0x xfd2d4 %eax %esp0xfd2d0 %ebp0xfd2d0 %eip0x mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret 0x80483f4 0x80483f5 0x80483f7 0x80483fa 0x80483fd 0x x x x804840c 0x804840d 0x804840e 0x804840f 0x x x804841e 0x x x804842b 0x x x
Adam Doupé, Principles of Programming Languages 0xfd2e xFFFFFFFF 0x xfd2d4 %eax %esp0xfd2c0 %ebp0xfd2d0 %eip0x mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret 0x80483f4 0x80483f5 0x80483f7 0x80483fa 0x80483fd 0x x x x804840c 0x804840d 0x804840e 0x804840f 0x x x804841e 0x x x804842b 0x x x xfd2c0
Adam Doupé, Principles of Programming Languages 0xfd2e xFFFFFFFF 0x xfd2d4 %eax %esp0xfd2c0 %ebp0xfd2d0 %eip0x mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret 0x80483f4 0x80483f5 0x80483f7 0x80483fa 0x80483fd 0x x x x804840c 0x804840d 0x804840e 0x804840f 0x x x804841e 0x x x804842b 0x x x xfd2c0
Adam Doupé, Principles of Programming Languages 0xfd2e0 0x xFFFFFFFF 0x xfd2d4 %eax %esp0xfd2c0 %ebp0xfd2d0 %eip0x mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret 0x80483f4 0x80483f5 0x80483f7 0x80483fa 0x80483fd 0x x x x804840c 0x804840d 0x804840e 0x804840f 0x x x804841e 0x x x804842b 0x x x xfd2c0
Adam Doupé, Principles of Programming Languages 0xfd2e0 0x xFFFFFFFF 0x xfd2d4 %eax %esp0xfd2c0 %ebp0xfd2d0 %eip0x804841e mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret 0x80483f4 0x80483f5 0x80483f7 0x80483fa 0x80483fd 0x x x x804840c 0x804840d 0x804840e 0x804840f 0x x x804841e 0x x x804842b 0x x x xfd2c0
Adam Doupé, Principles of Programming Languages 0xfd2e0 0x x xFFFFFFFF 0x xfd2d4 %eax %esp0xfd2bc %ebp0xfd2d0 %eip0x80483f4 mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret 0x80483f4 0x80483f5 0x80483f7 0x80483fa 0x80483fd 0x x x x804840c 0x804840d 0x804840e 0x804840f 0x x x804841e 0x x x804842b 0x x x xfd2c0 0xfd2bc
Adam Doupé, Principles of Programming Languages 0xfd2e0 0x x xfd2d xFFFFFFFF 0x xfd2d4 %eax %esp0xfd2b8 %ebp0xfd2d0 %eip0x80483f4 mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret 0x80483f4 0x80483f5 0x80483f7 0x80483fa 0x80483fd 0x x x x804840c 0x804840d 0x804840e 0x804840f 0x x x804841e 0x x x804842b 0x x x xfd2c0 0xfd2bc 0xfd2b8
Adam Doupé, Principles of Programming Languages 0xfd2e0 0x x xfd2d xFFFFFFFF 0x xfd2d4 %eax %esp0xfd2b8 %ebp0xfd2d0 %eip0x80483f5 mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret 0x80483f4 0x80483f5 0x80483f7 0x80483fa 0x80483fd 0x x x x804840c 0x804840d 0x804840e 0x804840f 0x x x804841e 0x x x804842b 0x x x xfd2c0 0xfd2bc 0xfd2b8
Adam Doupé, Principles of Programming Languages 0xfd2e0 0x x xfd2d xFFFFFFFF 0x xfd2d4 %eax %esp0xfd2b8 %ebp0xfd2b8 %eip0x80483f5 mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret 0x80483f4 0x80483f5 0x80483f7 0x80483fa 0x80483fd 0x x x x804840c 0x804840d 0x804840e 0x804840f 0x x x804841e 0x x x804842b 0x x x xfd2c0 0xfd2bc 0xfd2b8
Adam Doupé, Principles of Programming Languages 0xfd2e0 0x x xfd2d xfd2d4 %eax %esp0xfd2b8 %ebp0xfd2b8 %eip0x80483f7 mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret 0x80483f4 0x80483f5 0x80483f7 0x80483fa 0x80483fd 0x x x x804840c 0x804840d 0x804840e 0x804840f 0x x x804841e 0x x x804842b 0x x x xfd2c0 0xfd2bc 0xfd2b8
Adam Doupé, Principles of Programming Languages 0xfd2e0 0x x xfd2d xfd2d4 %eax %esp0xfd290 %ebp0xfd2b8 %eip0x80483f7 mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret 0x80483f4 0x80483f5 0x80483f7 0x80483fa 0x80483fd 0x x x x804840c 0x804840d 0x804840e 0x804840f 0x x x804841e 0x x x804842b 0x x x xfd2c0 0xfd2bc 0xfd2b8 0xfd290
Adam Doupé, Principles of Programming Languages 0xfd2e0 0x x xfd2d xfd2d4 %eax %esp0xfd290 %ebp0xfd2b8 %eip0x80483fa mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret 0x80483f4 0x80483f5 0x80483f7 0x80483fa 0x80483fd 0x x x x804840c 0x804840d 0x804840e 0x804840f 0x x x804841e 0x x x804842b 0x x x xfd2c0 0xfd2bc 0xfd2b8 0xfd290
Adam Doupé, Principles of Programming Languages 0xfd2e0 0x x xfd2d xfd2d4 %eax0x %esp0xfd290 %ebp0xfd2b8 %eip0x80483fa mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret 0x80483f4 0x80483f5 0x80483f7 0x80483fa 0x80483fd 0x x x x804840c 0x804840d 0x804840e 0x804840f 0x x x804841e 0x x x804842b 0x x x xfd2c0 0xfd2bc 0xfd2b8 0xfd290
Adam Doupé, Principles of Programming Languages 0xfd2e0 0x x xfd2d xfd2d4 %eax0x %esp0xfd290 %ebp0xfd2b8 %eip0x80483fd mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret 0x80483f4 0x80483f5 0x80483f7 0x80483fa 0x80483fd 0x x x x804840c 0x804840d 0x804840e 0x804840f 0x x x804841e 0x x x804842b 0x x x xfd2c0 0xfd2bc 0xfd2b8 0xfd290
Adam Doupé, Principles of Programming Languages 0xfd2e0 0x x xfd2d0 0x xfd2d4 %eax0x %esp0xfd290 %ebp0xfd2b8 %eip0x80483fd mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret 0x80483f4 0x80483f5 0x80483f7 0x80483fa 0x80483fd 0x x x x804840c 0x804840d 0x804840e 0x804840f 0x x x804841e 0x x x804842b 0x x x xfd2c0 0xfd2bc 0xfd2b8 0xfd290
Adam Doupé, Principles of Programming Languages 0xfd2e0 0x x xfd2d0 0x xfd2d4 %eax0xfd2ac %esp0xfd290 %ebp0xfd2b8 %eip0x mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret 0x80483f4 0x80483f5 0x80483f7 0x80483fa 0x80483fd 0x x x x804840c 0x804840d 0x804840e 0x804840f 0x x x804841e 0x x x804842b 0x x x xfd2c0 0xfd2bc 0xfd2b8 0xfd290 0xfd2ac
Adam Doupé, Principles of Programming Languages 0xfd2e0 0x x xfd2d0 0x xfd2d4 %eax0xfd2ac %esp0xfd290 %ebp0xfd2b8 %eip0x mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret 0x80483f4 0x80483f5 0x80483f7 0x80483fa 0x80483fd 0x x x x804840c 0x804840d 0x804840e 0x804840f 0x x x804841e 0x x x804842b 0x x x xfd2c0 0xfd2bc 0xfd2b8 0xfd290 0xfd2ac
Adam Doupé, Principles of Programming Languages 0xfd2e0 0x x xfd2d0 0x xfd2ac 124 0xfd2d4 %eax0xfd2ac %esp0xfd290 %ebp0xfd2b8 %eip0x mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret 0x80483f4 0x80483f5 0x80483f7 0x80483fa 0x80483fd 0x x x x804840c 0x804840d 0x804840e 0x804840f 0x x x804841e 0x x x804842b 0x x x xfd2c0 0xfd2bc 0xfd2b8 0xfd290 0xfd2ac
Adam Doupé, Principles of Programming Languages 0xfd2e0 0x x xfd2d0 0x xfd2ac 125 0xfd2d4 %eax0xfd2ac %esp0xfd290 %ebp0xfd2b8 %eip0x mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret 0x80483f4 0x80483f5 0x80483f7 0x80483fa 0x80483fd 0x x x x804840c 0x804840d 0x804840e 0x804840f 0x x x804841e 0x x x804842b 0x x x xfd2c0 0xfd2bc 0xfd2b8 0xfd290 0xfd2ac
Adam Doupé, Principles of Programming Languages 0xfd2e0 0x x xfd2d0 0x xfd2ac 126 0xfd2d4 %eax0xfd2ac %esp0xfd290 %ebp0xfd2b8 %eip0x804840c mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret 0x80483f4 0x80483f5 0x80483f7 0x80483fa 0x80483fd 0x x x x804840c 0x804840d 0x804840e 0x804840f 0x x x804841e 0x x x804842b 0x x x xfd2c0 0xfd2bc 0xfd2b8 0xfd290 0xfd2ac
Adam Doupé, Principles of Programming Languages 0xfd2e0 0x x xfd2d0 0x xfd2ac 127 0xfd2d4 %eax0xfd2ac %esp0xfd290 %ebp0xfd2b8 %eip0x804840c mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret 0x80483f4 0x80483f5 0x80483f7 0x80483fa 0x80483fd 0x x x x804840c 0x804840d 0x804840e 0x804840f 0x x x804841e 0x x x804842b 0x x x xfd2c0 0xfd2bc 0xfd2b8 0xfd290 0xfd2ac 0x : "asu cse 340 fall 2015 rocks!"
Adam Doupé, Principles of Programming Languages 0xfd2e0 0x x xfd2d0 asu (0x ) 0x xfd2ac 128 0xfd2d4 %eax0xfd2ac %esp0xfd290 %ebp0xfd2b8 %eip0x804840c mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret 0x80483f4 0x80483f5 0x80483f7 0x80483fa 0x80483fd 0x x x x804840c 0x804840d 0x804840e 0x804840f 0x x x804841e 0x x x804842b 0x x x xfd2c0 0xfd2bc 0xfd2b8 0xfd290 0xfd2ac 0x : "asu cse 340 fall 2015 rocks!"
Adam Doupé, Principles of Programming Languages 0xfd2e0 0x x xfd2d0 cse (0x ) asu (0x ) 0x xfd2ac 129 0xfd2d4 %eax0xfd2ac %esp0xfd290 %ebp0xfd2b8 %eip0x804840c mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret 0x80483f4 0x80483f5 0x80483f7 0x80483fa 0x80483fd 0x x x x804840c 0x804840d 0x804840e 0x804840f 0x x x804841e 0x x x804842b 0x x x xfd2c0 0xfd2bc 0xfd2b8 0xfd290 0xfd2ac 0x : "asu cse 340 fall 2015 rocks!"
Adam Doupé, Principles of Programming Languages 0xfd2e0 0x x xfd2d0 340 (0x ) cse (0x ) asu (0x ) 0x xfd2ac 130 0xfd2d4 %eax0xfd2ac %esp0xfd290 %ebp0xfd2b8 %eip0x804840c mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret 0x80483f4 0x80483f5 0x80483f7 0x80483fa 0x80483fd 0x x x x804840c 0x804840d 0x804840e 0x804840f 0x x x804841e 0x x x804842b 0x x x xfd2c0 0xfd2bc 0xfd2b8 0xfd290 0xfd2ac 0x : "asu cse 340 fall 2015 rocks!"
Adam Doupé, Principles of Programming Languages 0xfd2e0 0x x fall (0x6c6c6166) 340 (0x ) cse (0x ) asu (0x ) 0x xfd2ac 131 0xfd2d4 %eax0xfd2ac %esp0xfd290 %ebp0xfd2b8 %eip0x804840c mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret 0x80483f4 0x80483f5 0x80483f7 0x80483fa 0x80483fd 0x x x x804840c 0x804840d 0x804840e 0x804840f 0x x x804841e 0x x x804842b 0x x x xfd2c0 0xfd2bc 0xfd2b8 0xfd290 0xfd2ac 0x : "asu cse 340 fall 2015 rocks!"
Adam Doupé, Principles of Programming Languages 0xfd2e0 0x (0x ) fall (0x6c6c6166) 340 (0x ) cse (0x ) asu (0x ) 0x xfd2ac 132 0xfd2d4 %eax0xfd2ac %esp0xfd290 %ebp0xfd2b8 %eip0x804840c mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret 0x80483f4 0x80483f5 0x80483f7 0x80483fa 0x80483fd 0x x x x804840c 0x804840d 0x804840e 0x804840f 0x x x804841e 0x x x804842b 0x x x xfd2c0 0xfd2bc 0xfd2b8 0xfd290 0xfd2ac 0x : "asu cse 340 fall 2015 rocks!"
Adam Doupé, Principles of Programming Languages 0xfd2e0 5 ro (0x6f722035) 201 (0x ) fall (0x6c6c6166) 340 (0x ) cse (0x ) asu (0x ) 0x xfd2ac 133 0xfd2d4 %eax0xfd2ac %esp0xfd290 %ebp0xfd2b8 %eip0x804840c mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret 0x80483f4 0x80483f5 0x80483f7 0x80483fa 0x80483fd 0x x x x804840c 0x804840d 0x804840e 0x804840f 0x x x804841e 0x x x804842b 0x x x xfd2c0 0xfd2bc 0xfd2b8 0xfd290 0xfd2ac 0x : "asu cse 340 fall 2015 rocks!"
Adam Doupé, Principles of Programming Languages 0xfd2e0 cks! (0x21736b63) 5 ro (0x6f722035) 201 (0x ) fall (0x6c6c6166) 340 (0x ) cse (0x ) asu (0x ) 0x xfd2ac 134 0xfd2d4 %eax0xfd2ac %esp0xfd290 %ebp0xfd2b8 %eip0x804840c mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret 0x80483f4 0x80483f5 0x80483f7 0x80483fa 0x80483fd 0x x x x804840c 0x804840d 0x804840e 0x804840f 0x x x804841e 0x x x804842b 0x x x xfd2c0 0xfd2bc 0xfd2b8 0xfd290 0xfd2ac 0x : "asu cse 340 fall 2015 rocks!"
Adam Doupé, Principles of Programming Languages 0xfd2e0 cks! (0x21736b63) 5 ro (0x6f722035) 201 (0x ) fall (0x6c6c6166) 340 (0x ) cse (0x ) asu (0x ) 0x xfd2ac 135 0xfd2d4 %eax0xfd2ac %esp0xfd2b8 %ebp0xfd2b8 %eip0x804840c mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret 0x80483f4 0x80483f5 0x80483f7 0x80483fa 0x80483fd 0x x x x804840c 0x804840d 0x804840e 0x804840f 0x x x804841e 0x x x804842b 0x x x xfd2c0 0xfd2bc 0xfd2b8 0xfd290 0xfd2ac 0x : "asu cse 340 fall 2015 rocks!"
Adam Doupé, Principles of Programming Languages 0xfd2e0 cks! (0x21736b63) 5 ro (0x6f722035) 201 (0x ) fall (0x6c6c6166) 340 (0x ) cse (0x ) asu (0x ) 0x xfd2ac 136 0xfd2d4 %eax0xfd2ac %esp0xfd2bc %ebp0x6c6c6166 %eip0x804840c mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret 0x80483f4 0x80483f5 0x80483f7 0x80483fa 0x80483fd 0x x x x804840c 0x804840d 0x804840e 0x804840f 0x x x804841e 0x x x804842b 0x x x xfd2c0 0xfd2bc 0xfd2b8 0xfd290 0xfd2ac 0x : "asu cse 340 fall 2015 rocks!"
Adam Doupé, Principles of Programming Languages 0xfd2e0 cks! (0x21736b63) 5 ro (0x6f722035) 201 (0x ) fall (0x6c6c6166) 340 (0x ) cse (0x ) asu (0x ) 0x xfd2ac 137 0xfd2d4 %eax0xfd2ac %esp0xfd2bc %ebp0x6c6c6166 %eip0x804840d mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret 0x80483f4 0x80483f5 0x80483f7 0x80483fa 0x80483fd 0x x x x804840c 0x804840d 0x804840e 0x804840f 0x x x804841e 0x x x804842b 0x x x xfd2c0 0xfd2bc 0xfd2b8 0xfd290 0xfd2ac 0x : "asu cse 340 fall 2015 rocks!"
Adam Doupé, Principles of Programming Languages 0xfd2e0 cks! (0x21736b63) 5 ro (0x6f722035) 201 (0x ) fall (0x6c6c6166) 340 (0x ) cse (0x ) asu (0x ) 0x xfd2ac 138 0xfd2d4 %eax0xfd2ac %esp0xfd2c0 %ebp0x6c6c6166 %eip0x mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret 0x80483f4 0x80483f5 0x80483f7 0x80483fa 0x80483fd 0x x x x804840c 0x804840d 0x804840e 0x804840f 0x x x804841e 0x x x804842b 0x x x xfd2c0 0xfd2bc 0xfd2b8 0xfd290 0xfd2ac 0x : "asu cse 340 fall 2015 rocks!"
Adam Doupé, Principles of Programming Languages 0xfd2e0 cks! (0x21736b63) 5 ro (0x6f722035) 201 (0x ) fall (0x6c6c6166) 340 (0x ) cse (0x ) asu (0x ) 0x xfd2ac 139 0xfd2d4 %eax0xfd2ac %esp0xfd2c0 %ebp0x6c6c6166 %eip0x mycpy: push %ebp mov %esp,%ebp sub $0x28,%esp mov 0x8(%ebp),%eax mov %eax,0x4(%esp) lea -0xc(%ebp),%eax mov %eax,(%esp) call strcpy leave ret main: push %ebp mov %esp,%ebp sub $0x10,%esp movl $0x ,(%esp) call mycpy mov $0x ,%eax mov %eax,(%esp) call printf mov $0x0,%eax leave ret 0x80483f4 0x80483f5 0x80483f7 0x80483fa 0x80483fd 0x x x x804840c 0x804840d 0x804840e 0x804840f 0x x x804841e 0x x x804842b 0x x x xfd2c0 0xfd2bc 0xfd2b8 0xfd290 0xfd2ac 0x : "asu cse 340 fall 2015 rocks!"
Adam Doupé, Principles of Programming Languages #include void mycpy(char* str) { char foo[4]; strcpy(foo, str); } int main() { callee("asu cse 340 fall 2015 rocks!"); printf("After"); return 0; } 140 examples]$ gcc - Wall -m32 buffer_overflow.c examples]$./a.out Segmentation fault (core dumped) examples]$ gdb./a.out (gdb) r Starting program: a.out Program received signal SIGSEGV, Segmentation fault.0x in ?? () (gdb) info registers eax 0xffffd1fc ecx 0x0 0 edx 0x ebx 0x908ff esp 0xffffd210 0xffffd210 ebp 0x6c6c6166 0x6c6c6166 esi 0x0 0 edi 0x0 0 eip 0x x e...
Adam Doupé, Principles of Programming Languages Buffer Overflow Classic security vulnerability is when an attacker can overwrite the saved EIP value on the stack –The attacker's goal is to change a saved EIP value to point to attacker's data –Where the program will start executing the attacker's data as code One of the most common vulnerabilities in C and C++ programs Why? 141
Adam Doupé, Principles of Programming Languages Local Functions From what we have seen so far, variables are either global or local What if we want a language that allows defining local functions –Functions that are only valid in the containing scope 142
Adam Doupé, Principles of Programming Languages #include void foo() { int x; void bar() { void baz() { x = x + 1; if (x < 10) { bar(); } } baz(); } x = 0; bar(); printf("%d\n", x); } 143 gcc –Wall local_functions.c 10
Adam Doupé, Principles of Programming Languages Local Functions Can the previously discussed cdecl calling convention support support local functions? 144
Adam Doupé, Principles of Programming Languages #include void foo() { int x; void bar() { void baz() { x = x + 1; if (x < 10) { bar(); } baz(); } x = 0; bar(); printf("%d\n", x); } 145 foo
Adam Doupé, Principles of Programming Languages #include void foo() { int x; void bar() { void baz() { x = x + 1; if (x < 10) { bar(); } baz(); } x = 0; bar(); printf("%d\n", x); } 146 foo bar
Adam Doupé, Principles of Programming Languages #include void foo() { int x; void bar() { void baz() { x = x + 1; if (x < 10) { bar(); } baz(); } x = 0; bar(); printf("%d\n", x); } 147 foo bar
Adam Doupé, Principles of Programming Languages #include void foo() { int x; void bar() { void baz() { x = x + 1; if (x < 10) { bar(); } baz(); } x = 0; bar(); printf("%d\n", x); } 148 foo bar baz
Adam Doupé, Principles of Programming Languages #include void foo() { int x; void bar() { void baz() { x = x + 1; if (x < 10) { bar(); } baz(); } x = 0; bar(); printf("%d\n", x); } 149 foo bar baz
Adam Doupé, Principles of Programming Languages #include void foo() { int x; void bar() { void baz() { x = x + 1; if (x < 10) { bar(); } baz(); } x = 0; bar(); printf("%d\n", x); } 150 foo bar baz bar
Adam Doupé, Principles of Programming Languages #include void foo() { int x; void bar() { void baz() { x = x + 1; if (x < 10) { bar(); } baz(); } x = 0; bar(); printf("%d\n", x); } 151 foo bar baz bar baz
Adam Doupé, Principles of Programming Languages #include void foo() { int x; void bar() { void baz() { x = x + 1; if (x < 10) { bar(); } baz(); } x = 0; bar(); printf("%d\n", x); } 152 foo bar baz bar baz
Adam Doupé, Principles of Programming Languages Access Link Saved base pointer (EBP) save the caller's base pointer We want the base pointer of our lexical parent, not our caller's parent Thus, we need to add another element to our calling convention –This is called the "access link" Therefore, a function can follow the access links until the last lexical scope is found 153
Adam Doupé, Principles of Programming Languages #include void foo() { int x; void bar() { void baz() { x = x + 1; if (x < 10) { bar(); } baz(); } x = 0; bar(); printf("%d\n", x); } 154 foo bar baz bar baz
Adam Doupé, Principles of Programming Languages #include void foo() { int x; void bar() { void baz() { x = x + 1; if (x < 10) { bar(); } baz(); } x = 0; bar(); printf("%d\n", x); } 155 foo bar baz bar baz bar baz bar baz
Adam Doupé, Principles of Programming Languages Type of Memory Allocation Global Allocation Stack Allocation Heap Allocation 156
Adam Doupé, Principles of Programming Languages Heap Allocation Programmer must manually ask for memory allocation Programmer must also explicitly release the memory 157
Adam Doupé, Principles of Programming Languages C Heap Allocation Defined in libc (stdlib.h) –malloc –calloc –realloc –free Many possible implementations –In fact, you can write your own! 158
Adam Doupé, Principles of Programming Languages #include int main(int argc, char** argv) { void* test; int i; int size = atoi(argv[1]); for (i = 0; i < 10; i++) { test = malloc(size); printf("%p\n", test); } return 0; } 159 gcc –Wall –m32 malloc_test.c 4 0x804a008 0x804a018 0x804a028 0x804a038 0x804a048 0x804a058 0x804a068 0x804a078 0x804a088 0x804a098
Adam Doupé, Principles of Programming Languages #include int main(int argc, char** argv) { void* test; int i; int size = atoi(argv[1]); for (i = 0; i < 10; i++) { test = malloc(size); printf("%p\n", test); } return 0; } 160 gcc –Wall –m32 malloc_test.c 8 0x804a008 0x804a018 0x804a028 0x804a038 0x804a048 0x804a058 0x804a068 0x804a078 0x804a088 0x804a098
Adam Doupé, Principles of Programming Languages #include int main(int argc, char** argv) { void* test; int i; int size = atoi(argv[1]); for (i = 0; i < 10; i++) { test = malloc(size); printf("%p\n", test); } return 0; } 161 gcc –Wall –m32 malloc_test.c 24 0x804a008 0x804a028 0x804a048 0x804a068 0x804a088 0x804a0a8 0x804a0c8 0x804a0e8 0x804a108 0x804a128
Adam Doupé, Principles of Programming Languages #include int main(int argc, char** argv) { void* test; int i; int size = atoi(argv[1]); for (i = 0; i < 10; i++) { test = malloc(size); printf("%p\n", test); } return 0; } 162 gcc –Wall –m32 malloc_test.c x804a008 0x804b010 0x804c018 0x804d020 0x804e028 0x804f030 0x x x x
Adam Doupé, Principles of Programming Languages #include int main(int argc, char** argv) { void* test; int i; int size = atoi(argv[1]); for (i = 0; i < 10; i++) { test = malloc(size); printf("%p\n", test); } return 0; } 163 gcc –Wall –m32 malloc_test.c xd7fec008 0xb7feb008 0x97fea008 0x77fe9008 0x57fe8008 0x37fe7008 0x17fe6008 (nil)
Adam Doupé, Principles of Programming Languages 164 0xFFFFFFFF 0x Stack Heap
Adam Doupé, Principles of Programming Languages Heap Allocation sbrk is Linux system call to increase the size of the heap –Defined in unistd.h – void* sbrk(intptr_t increment) Thus, malloc does not allocate new heap directly, but instead calls sbrk to ask the OS to increase heap allocation 165
Adam Doupé, Principles of Programming Languages #include int main(int argc, char** argv) { void* test; void* cur_break; int i; int size = atoi(argv[1]); for (i = 0; i < 10; i++) { test = malloc(size); cur_break = sbrk(0); printf("%p %p\n", test, cur_break); } return 0; } 166 gcc –Wall –m32 sbrk_test.c 4 0x804a008 0x806b000 0x804a018 0x806b000 0x804a028 0x806b000 0x804a038 0x806b000 0x804a048 0x806b000 0x804a058 0x806b000 0x804a068 0x806b000 0x804a078 0x806b000 0x804a088 0x806b000 0x804a098 0x806b000
Adam Doupé, Principles of Programming Languages #include int main(int argc, char** argv) { void* test; void* cur_break; int i; int size = atoi(argv[1]); for (i = 0; i < 10; i++) { test = malloc(size); cur_break = sbrk(0); printf("%p %p\n", test, cur_break); } return 0; } 167 gcc –Wall –m32 sbrk_test.c x804a008 0x806b000 0x804a410 0x806b000 0x804a818 0x806b000 0x804ac20 0x806b000 0x804b028 0x806b000 0x804b430 0x806b000 0x804b838 0x806b000 0x804bc40 0x806b000 0x804c048 0x806b000 0x804c450 0x806b000
Adam Doupé, Principles of Programming Languages #include int main(int argc, char** argv) { void* test; void* cur_break; int i; int size = atoi(argv[1]); for (i = 0; i < 10; i++) { test = malloc(size); cur_break = sbrk(0); printf("%p %p\n", test, cur_break); } return 0; } 168 gcc –Wall –m32 sbrk_test.c x804a008 0x806c000 0x804b010 0x806c000 0x804c018 0x806c000 0x804d020 0x806c000 0x804e028 0x806c000 0x804f030 0x806c000 0x x806c000 0x x806c000 0x x806c000 0x x806c000
Adam Doupé, Principles of Programming Languages #include int main(int argc, char** argv) { void* test; void* cur_break; int i; int size = atoi(argv[1]); for (i = 0; i < 10; i++) { test = malloc(size); cur_break = sbrk(0); printf("%p %p\n", test, cur_break); } return 0; } 169 gcc –Wall –m32 sbrk_test.c x804a008 0x807b000 0x805a010 0x807b000 0x806a018 0x807b000 0x807a020 0x80ab000 0x808a028 0x80ab000 0x809a030 0x80ab000 0x80aa038 0x80db000 0x80ba040 0x80db000 0x80ca048 0x80db000 0x80da050 0x810b000
Adam Doupé, Principles of Programming Languages Heap Allocation So malloc is calling sbrk to request more heap memory from the OS How is the memory deallocated when we call free ? 170
Adam Doupé, Principles of Programming Languages #include int main(int argc, char** argv) { void* test; void* cur_break; int i; int size = atoi(argv[1]); for (i = 0; i < 10; i++) { test = malloc(size); cur_break = sbrk(0); printf("%p %p\n", test, cur_break); free(test); } return 0; } 171 gcc –Wall –m32 free_test.c 4 0x804a008 0x806b000
Adam Doupé, Principles of Programming Languages #include int main(int argc, char** argv) { void* test; void* cur_break; int i; int size = atoi(argv[1]); for (i = 0; i < 10; i++) { test = malloc(size); cur_break = sbrk(0); printf("%p %p\n", test, cur_break); free(test); } return 0; } 172 gcc –Wall –m32 free_test.c x804a008 0x806b000
Adam Doupé, Principles of Programming Languages #include int main(int argc, char** argv) { void* test; void* cur_break; int i; int size = atoi(argv[1]); for (i = 0; i < 10; i++) { test = malloc(size); cur_break = sbrk(0); printf("%p %p\n", test, cur_break); if (i % 2 == 0) free(test); } return 0; } 173 gcc –Wall –m32 free_test_2.c 4 0x804a008 0x806b000 0x804a018 0x806b000 0x804a028 0x806b000 0x804a038 0x806b000 0x804a048 0x806b000
Adam Doupé, Principles of Programming Languages free How would you implement malloc and free ? void* malloc(size_t size) void free(void* ptr) malloc must call sbrk to increase heap to size –return the pointer that sbrk returns free –set sbrk to negative allocated size 174
Adam Doupé, Principles of Programming Languages Implementation Reserve more memory than requested Store the malloc'd size in a fixed offset from the pointer to the new memory Then, when someone calls free, access the size from the fixed offset of that pointer 175
Adam Doupé, Principles of Programming Languages struct malloc_chunk { size_t chunk_size; void* buf; }; void* malloc (size_t size) { … struct malloc_chunk* new_mem = sbrk(size + sizeof(struct malloc_chunk); new_mem->chunk_size = size; return (void*)((char*)new_mem + sizeof(size_t)); } void free (void* ptr) { struct malloc_chunk* mem = (struct malloc_chunk*)((char*)ptr – sizeof(size_t)); size_t size_to_free = mem->chunk_size; … } 176
Adam Doupé, Principles of Programming Languages 177 0xFFFFFFFF 0x Stack Heap
Adam Doupé, Principles of Programming Languages 178 0xFFFFFFFF 0x Stack Heap
Adam Doupé, Principles of Programming Languages 179 0xFFFFFFFF 0x Stack Heap
Adam Doupé, Principles of Programming Languages 180 0xFFFFFFFF 0x sbrk(size)
Adam Doupé, Principles of Programming Languages 181 0xFFFFFFFF 0x
Adam Doupé, Principles of Programming Languages 182 0xFFFFFFFF 0x
Adam Doupé, Principles of Programming Languages 183 0xFFFFFFFF 0x
Adam Doupé, Principles of Programming Languages 184 0xFFFFFFFF 0x
Adam Doupé, Principles of Programming Languages 185 0xFFFFFFFF 0x
Adam Doupé, Principles of Programming Languages 186 0xFFFFFFFF 0x
Adam Doupé, Principles of Programming Languages 187 0xFFFFFFFF 0x
Adam Doupé, Principles of Programming Languages Modern malloc Many applications need heap allocation, thus malloc performance very important Different heap workloads –Many small and frequent allocations –Few large allocations –Combination of both Many things affect performance –Finding free memory –Heap fragmentation –Allocation overhead 188