Guest User

Untitled

a guest
May 25th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. void func2(int a, int b, int c){
  4. printf("%d %d %d\n", a, b, c);
  5. }
  6.  
  7. void func1(int c){
  8. func2(1,2,c);
  9. }
  10.  
  11. int main(void){
  12. func1(3);
  13.  
  14. return 0;
  15. }
  16.  
  17. -----------
  18.  
  19. func1 replaced with the following assembly
  20.  
  21. _func1:
  22. # use ecx as the base pointer
  23. movl %esp, %ecx
  24. # allocate more stack in 16 byte increments
  25. subl $16, %esp
  26. # copy the return address to top of the stack
  27. movl (%ecx), %eax
  28. movl %eax, (%esp)
  29. # copy the old parameter
  30. movl 4(%ecx), %eax
  31. movl %eax, 12(%esp)
  32. # add the two new ones
  33. movl $2, 8(%esp)
  34. movl $1, 4(%esp)
  35. jmp _func2
Add Comment
Please, Sign In to add comment