I'm writing small C programs to teach myself how to use GDB to disassemble code. The C in question is:
void function( char **pointer )
{
*pointer = malloc(100);
strcpy(*pointer,"This is text");
}
The disassembly is:
0x400620: push %rbp
0x400621: mov %rsp,%rbp
0x400624: sub $0x10,%rsp
0x400628: mov %rdi,-0x8(%rbp)
0x40062c: mov $0x64,%edi
0x400631: callq 0x4004f0 <malloc@plt>
0x400636: mov %rax,%rdx
0x400639: mov -0x8(%rbp),%rax
0x40063d: mov %rdx,(%rax)
0x400640: mov -0x8(%rbp),%rax
0x400644: mov (%rax),%rax
0x400647: movabs $0x2073692073696854,%rcx
0x400651: mov %rcx,(%rax)
0x400654: movl $0x74786574,0x8(%rax)
0x40065b: movb $0x0,0xc(%rax)
0x40065f: leaveq
0x400660: retq
I understand the prologue: 0x400620
-0x400624
. I also understand that the pointer is being initialized to 100 char here: 0x400628
-0x40063d
.
I cannot seem to figure out what strcpy
is doing and I do not understand how to examine the contents of the addresses listed in 0x400647
and 0x400654
.
Can someone help me work through this?