From the book Hacking the art of exploitation
, the author shows the following results -
$ cat test1.c
#include<stdio.h>
#include<string.h>
int main()
{
char str_a[20];
strcpy(str_a, "Hello, World!\n");
printf("%s",str_a);
}
$ gcc -g -o test1 test1.c
$ gdb -q ./test1
Reading symbols from ./test1...done.
(gdb) break strcpy
Function "strcpy" not defined.
Make breakpoint pending on future shared library load? (y or [n])
But when I do:
(gdb) break printf
Breakpoint 1 at 0x580
There is no warning message from gdb as such, since the compiler placed printf to a specified location (stdio.h but not string.h?). Why is there a difference in behavior of printf and strcpy?
Further to elaborate my understanding.
$ objdump -D test1 | grep printf
0000000000000580 <printf@plt>:
580: ff 25 4a 0a 20 00 jmpq *0x200a4a(%rip) # 200fd0 <printf@GLIBC_2.2.5>
6f6: e8 85 fe ff ff callq 580 <printf@plt>
$ objdump -D test1 | grep strcpy
$
Am I missing something, why isn't strcpy from string.h loaded during compile time?