Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. (gdb) disassemble main
  2. Dump of assembler code for function main:
  3. 0x0000000000000682 <+0>: push %rbp //Push rbp onto the stack
  4. 0x0000000000000683 <+1>: mov %rsp,%rbp //Move the value of rsp to the address of rbp
  5. 0x0000000000000686 <+4>: sub $0x10,%rsp //Subtract rsp value from 16
  6. 0x000000000000068a <+8>: mov %edi,-0x4(%rbp) //Move the value in the address of rbp minus 4 to edi
  7. 0x000000000000068d <+11>: mov %rsi,-0x10(%rbp) //Move the value in the address of rbp minus 10 to rsi
  8. 0x0000000000000691 <+15>: lea 0xae(%rip),%rdi //Load effective address of rdi to 0xae(rip)
  9. 0x0000000000000698 <+22>: callq 0x64a <foo> //Store the 0x64a location on the stack and then jump to foo and return back to location
  10. 0x000000000000069d <+27>: mov $0x0,%eax //Move value of eax to 0x0
  11. 0x00000000000006a2 <+32>: leaveq //Set %rsp to %rbp and pop top of the stack into %rbp
  12. 0x00000000000006a3 <+33>: retq //Pop return address from stack and jump to it
  13. End of assembler dump.
  14.  
  15.  
  16. Dump of assembler code for function foo:
  17. 0x000000000000064a <+0>: push %rbp // push rbp onto the stack
  18. 0x000000000000064b <+1>: mov %rsp,%rbp //Move the value of rbp to thea ddress of rsp
  19. 0x000000000000064e <+4>: sub $0x10,%rsp //Subtract the value of rsp from the value of 16
  20. 0x0000000000000652 <+8>: mov %rdi,-0x8(%rbp) //Move the value in address of rbp minus 8 to rdi
  21. 0x0000000000000656 <+12>: lea 0xd7(%rip),%rdi //Load effective address of rdi to 0xd7
  22. 0x000000000000065d <+19>: mov $0x0,%eax //Move the value of eax to 0x0
  23. 0x0000000000000662 <+24>: callq 0x520 <printf@plt> //Store the location on the stack and then jump to printf and return back to location
  24. 0x0000000000000667 <+29>: nop
  25. 0x0000000000000668 <+30>: leaveq //Set %rsp to %rbp and pop top of the stack into %rbp
  26. 0x0000000000000669 <+31>: retq //Pop return address from stack and jump to it
  27. End of assembler dump.
  28.  
  29. #include <stdio.h>
  30. #include <string.h>
  31.  
  32. void foo(const char* input)
  33. {
  34. char buf[8] = "hello123";
  35. strcpy(buf, input);
  36. }
  37.  
  38.  
  39. void bar(void)
  40. {
  41. printf("In bar()");
  42. }
  43.  
  44.  
  45. int main(int argc, char* argv[])
  46. {
  47. foo("12345678901234567890");
  48.  
  49. return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement