Library usage
Published: Wednesday, Dec 26, 2007 Last modified: Monday, Dec 9, 2024
So what does a binary depend on? Use ldd:
bilbo$ ldd /bin/ls
librt.so.1 => /lib/tls/librt.so.1 (0x4001f000)
libacl.so.1 => /lib/libacl.so.1 (0x40025000)
libc.so.6 => /lib/tls/libc.so.6 (0x4002d000)
libpthread.so.0 => /lib/tls/libpthread.so.0 (0x40168000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
libattr.so.1 => /lib/libattr.so.1 (0x40177000)
So how are they used? Use ltrace (not base):
bilbo$ ltrace /bin/ls __libc_start_main(0x8049ea0, 1, 0xbffff554, 0x80561a0, 0x8056200setlocale(6, "") = "en_GB.UTF-8" bindtextdomain("coreutils", "/usr/share/locale") = "/usr/share/locale" textdomain("coreutils") = "coreutils" __cxa_atexit(0x8052200, 0, 0, 0x8056540, 0xbffff4c8) = 0 isatty(1) = 1 getenv("QUOTING_STYLE") = NULL getenv("LS_BLOCK_SIZE") = NULL getenv("BLOCK_SIZE") = NULL getenv("POSIXLY_CORRECT") = NULL getenv("BLOCK_SIZE") = NULL getenv("COLUMNS") = NULL ioctl(1, 21523, 0xbffff2b8) = 0 getenv("POSIXLY_CORRECT") = NULL getenv("TABSIZE") = NULL getopt_long(1, 0xbffff554, "abcdfghiklmnopqrstuvw:xABCDFGHI:"..., 0x8056860, NULL) = -1 __errno_location() = 0x4017b060 malloc(36) = 0x805b858 __errno_location() = 0x4017b060 malloc(36) = 0x805b880 malloc(12000) = 0x805b8a8 malloc(12) = 0x805e790 strlen(".") = 1 malloc(2) = 0x805e7a0 memcpy(0x805e7a0, ".", 2) = 0x805e7a0 __errno_location() = 0x4017b060 opendir(".") = 0x805e7b0 __errno_location() = 0x4017b060 readdir64(0x805e7b0) = 0x805e7cc readdir64(0x805e7b0) = 0x805e7e4 readdir64(0x805e7b0) = NULL closedir(0x805e7b0) = 0 _setjmp(0x805a5c0, 0x400a12b0, 0x40165800, 0x805e7b0, 0x40164e8c) = 0 qsort(0x805b8a8, 0, 120, 0x804ce00) = free(0x805e7a0) = free(0x805e790) = exit(0 __fpending(0x4015dd40, 0x805a3a0, 0x400a23d8, 0x8048c10, 0x40165800) = 0 +++ exited (status 0) +++