Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (gdb) disassemble main
- Dump of assembler code for function main:
- 0x0000000000000682 <+0>: push %rbp //Push rbp onto the stack
- 0x0000000000000683 <+1>: mov %rsp,%rbp //Move the value of rsp to the address of rbp
- 0x0000000000000686 <+4>: sub $0x10,%rsp //Subtract rsp value from 16
- 0x000000000000068a <+8>: mov %edi,-0x4(%rbp) //Move the value in the address of rbp minus 4 to edi
- 0x000000000000068d <+11>: mov %rsi,-0x10(%rbp) //Move the value in the address of rbp minus 10 to rsi
- 0x0000000000000691 <+15>: lea 0xae(%rip),%rdi //Load effective address of rdi to 0xae(rip)
- 0x0000000000000698 <+22>: callq 0x64a <foo> //Store the 0x64a location on the stack and then jump to foo and return back to location
- 0x000000000000069d <+27>: mov $0x0,%eax //Move value of eax to 0x0
- 0x00000000000006a2 <+32>: leaveq //Set %rsp to %rbp and pop top of the stack into %rbp
- 0x00000000000006a3 <+33>: retq //Pop return address from stack and jump to it
- End of assembler dump.
- Dump of assembler code for function foo:
- 0x000000000000064a <+0>: push %rbp // push rbp onto the stack
- 0x000000000000064b <+1>: mov %rsp,%rbp //Move the value of rbp to thea ddress of rsp
- 0x000000000000064e <+4>: sub $0x10,%rsp //Subtract the value of rsp from the value of 16
- 0x0000000000000652 <+8>: mov %rdi,-0x8(%rbp) //Move the value in address of rbp minus 8 to rdi
- 0x0000000000000656 <+12>: lea 0xd7(%rip),%rdi //Load effective address of rdi to 0xd7
- 0x000000000000065d <+19>: mov $0x0,%eax //Move the value of eax to 0x0
- 0x0000000000000662 <+24>: callq 0x520 <printf@plt> //Store the location on the stack and then jump to printf and return back to location
- 0x0000000000000667 <+29>: nop
- 0x0000000000000668 <+30>: leaveq //Set %rsp to %rbp and pop top of the stack into %rbp
- 0x0000000000000669 <+31>: retq //Pop return address from stack and jump to it
- End of assembler dump.
- #include <stdio.h>
- #include <string.h>
- void foo(const char* input)
- {
- char buf[8] = "hello123";
- strcpy(buf, input);
- }
- void bar(void)
- {
- printf("In bar()");
- }
- int main(int argc, char* argv[])
- {
- foo("12345678901234567890");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement