Archive for 'Solaris Linker'

Viewing the files the runtime linker is operating on

I picked up a neat trick on the Solaris linker mailing list this week. If you want to see the complete set of input files that are processed by the runtime linker, you can use the “-Dfiles” LD_OPTION: $ LD_OPTIONS=-Dfiles /usr/sfw/bin/gcc -o foo foo.c debug: debug: file=/usr/lib/crt1.o [ ET_REL ] debug: debug: file=/usr/lib/crti.o [ ET_REL […]

Viewing dynamic executable dependencies

Large dynamically linked executables can have a LOT of dependencies, which are resolved by the runtime linker when a program is executed. To see which libraries an executable and the executable’s shared dependencies depend on, the ldd utility can be used: $ ldd /usr/sbin/metastat => /lib/ => /lib/ => /lib/ => […]

Linker search paths

As part of my job as a systems administrator, I occassionally need to develop scripts to start applications at system bootstrap. Periodically while developing these scripts I will encounter an application that relies on libraries in obscure locations. To allow my scripts to work with these applications, I typically need to set LD_LIBRARY_PATH so the […]

Viewing shared library search order

When debugging library search path problems, it is often useful to see which libraries are used, and the order in which they are accessed. This is easily accomplished with the Solaris ldd(1m) utilities “-s” option: $ ldd -ss /usr/sfw/bin/wget |more find; required by /usr/sfw/bin/wget search path=/usr/local/lib (LD_LIBRARY_PATH) trying path=/usr/local/lib/ search path=/usr/lib (default) trying path=/usr/lib/ […]

Printing the contents of a static library

While debugging a static linking problem this weekend, I needed to see which files were included in a static library. This can be accomplished with the ar(1) utilities “-t” (print table of contents) option: $ ar -vt /usr/lib/libnsl.a | head 5 rw-rw-r– 0/ 1 1752 Aug 13 10:16 2004 common.o rw-rw-r– 0/ 1 4868 Aug […]

C pre processor

I am knee deep in debugging another SEGFAULT issue, and was given a cool tip by my friend Clay this weekend. When you see lots of #ifdef, #ifndef, and #endif’s in a source file, you can see what the C pre-processor will produce by running the source through the C pre-processor command (cpp): $ cat […]