I’m trying to understand the dependencies of a C program, and I’m slowly realizing that gcc main.c -o main
is hiding a lot of details.
Here’s my experiment (ubuntu-wsl-x64):
As you can see, my program is linked to
- The GNU libc (through a symbolic link
libc.so.6
) - The GNU linker (
ld-linux-x86-64.so.2
) - A weird dynamic library (
linux-vdso.so.1
)
To my understanding, the linux-vdso.so.1
will implement certain libc API to improve the speed of certain system calls.
Questions:
- Why is
linux-vdso.so.1
is not already included in libc? - Why is
ld
dynamically linked to my executable? Is it used at runtime? - To my understanding, my program also should depend on
libgcc
andcrt0
are they linked statically? - There must be a
-I
hidden so the program can see the libc header file. Am I correct? I so, where are they? - Am I missing something else?
Thanks, kind strangers.