Penguin

Differences between current version and previous revision of LD_DEBUG.

Other diffs: Previous Major Revision, Previous Author, or view the Annotated Edit History

Newer page: version 3 Last edited on Monday, August 29, 2005 12:24:49 pm by JohnMcPherson
Older page: version 2 Last edited on Friday, June 13, 2003 8:50:13 pm by JohnMcPherson Revert
@@ -3,13 +3,17 @@
 to show how symbols (variables and functions, for example) are resolved for a dynamic executable. This can sometimes help resolve obscure bugs where your application isn't doing what you expect (assuming it is caused by symbols being resolved differently to what you were expecting). 
  
 This is very useful if you get segmentation violations or aborts for a program - this can sometimes be caused by linking against the wrong version of a library. This is also a really good way to understand what happens when you run any program! 
 It has some self-documentation - for the impatient, you can do 
+<verbatim>  
  $ LD_DEBUG=help /path/to/some/dynamic/executable 
-  
+</verbatim>  
 eg 
- $LD_DEBUG=help ls 
+<verbatim>  
+ $ LD_DEBUG=help ls  
+</verbatim>  
 prints out: 
+<verbatim>  
  Valid options for the LD_DEBUG environment variable are: 
  
  libs display library search paths 
  reloc display relocation processing 
@@ -22,10 +26,11 @@
  help display this help message and exit 
  
  To direct the debugging output into a file instead of standard output a 
  filename can be specified using the LD_DEBUG_OUTPUT environment variable. 
-  
+</verbatim>  
 As a quick example of what it does: 
+<verbatim>  
  $ LD_DEBUG=all ls 2>&1 > /dev/null | less 
  
  13442: 
  13442: file=librt.so.1; needed by ls 
@@ -65,17 +70,17 @@
  13442: symbol=_h_errno; lookup in file=/lib/libpthread.so.0 
  13442: symbol=_h_errno; lookup in file=/lib/ld-linux.so.2 
  13442: binding file /lib/libpthread.so.0 to /lib/libc.so.6: normal symbol `_h_errno' [GLIBC_2.0] 
  ... 
-  
+</verbatim>  
 In other words, every single function and external variable in the standard library that ls(1) uses must be located each time it is run (kind of obvious, really). 
-  
+<verbatim>  
  $ ldd /bin/ls 
  librt.so.1 => /lib/librt.so.1 (0x40020000) 
  libc.so.6 => /lib/libc.so.6 (0x40031000) 
  libpthread.so.0 => /lib/libpthread.so.0 (0x4014c000) 
  /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000) 
-  
+</verbatim>  
  
 see ld.so(8) for environment variables. 
 ---- 
 See also AdvancedUserTips, CommonProgrammingBugs