If you compile it with dinamyc linking (default) no external functions are included at all in the final executable. They will be loaded at run time from external libraries. You can see which symbols are included (and will be loaded) with
objdump -T file
Example:
#include <string.h>
#include <stdio.h>
int main (int argc, char *argv[])
{
if (argv[1])
if (!strcmp (argv[1], "foo"))
printf ("bar\n");
return 0;
}
[ca0s@st4ck-3rr0r Tests]$ objdump -T strcmp
strcmp: file format elf64-x86-64
DYNAMIC SYMBOL TABLE:
0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 puts
0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 __libc_start_main
0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 strcmp
0000000000000000 w D *UND* 0000000000000000 __gmon_start__
Linker will load the library in memory and resolve function's address.
If you link it statically, it seems every function of the library is linked:
[ca0s@st4ck-3rr0r Tests]$ gcc -static -o strstatic strcmp.c
[ca0s@st4ck-3rr0r Tests]$ objdump -t strstatic | grep strrchr #this one, for example
0000000000434a40 g F .text 000000000000009f strrchr
I have searched how to do it, but no method has worked.