My code is in test.c:
int main(){
return 0;
}
The dynamically shared libraries the executable compiled from it depends on are:
$ gcc -o test test.c
$ ldd test
linux-gate.so.1 => (0x00783000)
libc.so.6 => /lib/libc.so.6 (0x00935000)
/lib/ld-linux.so.2 (0x00ea5000)
- I was wondering what roles the three libraries are playing?
- Which library does the function
mainbelong to? /lib/libc.so.6? - Which library does
returnbelong to? /lib/libc.so.6? - Are the three libraries all that are dynamically linked by default by gcc?
- How can I find out static libraries that gcc links to by default?
Thanks!
linux-gate.soisn’t really a shared lib, but a part of the kernel that acts like one and makes fast system calls possible.ld-linux.sois a piece of code that makes loading other shared libraries possible.libc.sois the C library, containing standard functions likeprintfandstrcpy.maindoesn’t belong to any library. It belongs to your program, in the sense that its assembled version is stored entirely in thetestbinary file.returnis not a function but a C language construct.libgcc, which is apparently not a shared library on your system (or it would show up) and some startup code.g++would additionally link inlibstdc++.so(the C++ standard library) andlibm.so(the math part of the C standard library).