Solaris
Local
External
Linking
Command line tools
| Command | Description |
dump -Lvp {filename} Where {filename} is either library or exe | |
| nm {filename} | Shows Symbols of a library or exe named {filename} |
| nm -C {filename} | Shows unmangeled Symbols of a library or exe named {filename} |
| ldd {filename} |
LD_DEBUG LD_DEBUG_OUTPUT
|
These are environment variables that if set cause diagnositic
output to be displayed. See below for more info.
|
Linker options
# sample link line:
cc -o prog.exe main.o file1.c -Bstatic -lfoo -Bdynamic -lbar
| -Bdirect |
If symbols found in the '-l' items after this (i.e. '-lfoo')
satisfy a symbol need, then at run time, when that same symbol
needs resolving, it will get it from the library that was
being looked at at link time, even if another library supplies
an identical symbol.
When multiple libraries supply symbols with different implementations,
this allows the correct library to be called.
|
| -Bdynamic |
the '-l' items (i.e. '-lfoo') found after this are first searched for a match to
a dynamic library (like libfoo.so) and if that is not found, then it looks for an archive
(like foo.a)
|
| -Bstatic |
the '-l' items (i.e. '-lfoo') found after this are seached for via a match to
an archive (like foo.a), this NEVER looks for a match in a dynamic library.
|
| -z defs | Makes linker fail if any symbols are undefined |
LD_DEBUG info
In raw format
LD_DEBUG=
files
init
help
bindings
libs
symbols
LD_DEBUG=bindings,detail,additional
LD_DEBUG_OUTPUT={filenamePrefix}
i.e.
LD_DEBUG_OUTPUT=dbg
LD_DEBUG_OUTPUT=debug.files LD_DEBUG=files UnitTest2.exe
LD_DEBUG_OUTPUT=debug.init LD_DEBUG=init UnitTest2.exe
LD_DEBUG_OUTPUT=debug.help LD_DEBUG=help UnitTest2.exe
# get the following help from ksh via:
$ LD_DEBUG_OUTPUT=debug.help LD_DEBUG=help UnitTest2.exe
# or get it via:
> ld -Dhelp
00000:
00000: For debugging the runtime linking of an application:
00000: LD_DEBUG=token1,token2 prog
00000: enables diagnostics to the stderr. The additional option:
00000: LD_DEBUG_OUTPUT=file
00000: redirects the diagnostics to an output file created using
00000: the specified name and the process id as a suffix. All
00000: diagnostics are prepended with the process id.
00000:
00000: For debugging the link-editing of an application:
00000: LD_OPTIONS=-Dtoken1,token2 cc -o prog ...
00000: or,
00000: ld -Dtoken1,token2 -o prog ...
00000: where placement of -D on the command line is significant,
00000: and options can be switched off by prepending with `!'. All
00000: diagnostics are prepended with the string `debug', and
00000: optionally with the output file basename or fullname, and
00000: its class, if the `name' or `fullname', and `class' tokens
00000: are specified respectively.
00000:
00000:
00000: args display input argument processing (ld only)
00000: audit display runtime link-audit processing (ld.so.1 only)
00000: basic provide basic trace information/warnings
00000: bindings display symbol binding; detail flag shows absolute:relative
00000: addresses (ld.so.1 only)
00000: cap display hardware/software capability processing
00000: detail provide more information in conjunction with other options
00000: entry display entrance criteria descriptors (ld only)
00000: files display input file processing (files and libraries)
00000: got display GOT symbol information (ld only)
00000: help display this help message
00000: init display init and fini processing (ld.so.1 only)
00000: libs display library search paths; detail flag shows actual
00000: library lookup (-l) processing
00000: long display long object names without truncation
00000: map display map file processing (ld only)
00000: move display move section processing
00000: reloc display relocation processing
00000: sections display input section processing (ld only)
00000: segments display available output segments and address/offset
00000: processing; detail flag shows associated sections (ld only)
00000: statistics display processing statistics (ld only)
00000: strtab display information about string table compression; detail
00000: shows layout of string tables (ld only)
00000: support display support library processing (ld only)
00000: symbols display symbol table processing; detail flag shows internal
00000: symbol table addition and resolution (ld only)
00000: tls display TLS processing info
00000: unused display unused/unreferenced files; detail flag shows unused
00000: sections (ld only)
00000: versions display version processing
?? this fails for us:
LD_DEBUG_OUTPUT=debug.args LD_DEBUG=args UnitTest2.exe
?? fails:
LD_DEBUG_OUTPUT=debug.audit LD_DEBUG=audit UnitTest2.exe
?? fails:
LD_DEBUG_OUTPUT=debug.basic LD_DEBUG=basic UnitTest2.exe
# Shows what symbols come from what files, and shows what symbols from one library have another libraries version be used.
LD_DEBUG_OUTPUT=debug.bindings LD_DEBUG=bindings UnitTest2.exe
LD_DEBUG_OUTPUT=debug.bindings LD_DEBUG=bindings ls
LD_DEBUG_OUTPUT=debug.args LD_DEBUG=args UnitTest2.exe
LD_DEBUG_OUTPUT=debug.args LD_DEBUG=args UnitTest2.exe
LD_DEBUG_OUTPUT=debug.args LD_DEBUG=args UnitTest2.exe
LD_DEBUG_OUTPUT=debug.args LD_DEBUG=args UnitTest2.exe
LD_DEBUG_OUTPUT=debug.args LD_DEBUG=args UnitTest2.exe
LD_DEBUG_OUTPUT=debug.args LD_DEBUG=args UnitTest2.exe
Debugging
Use dbx or sunstudio
| command | desc |
examine {addr1} [ / {numbytes} ] [ {format} ]
(alias:) x
|
Does memory display.
|
| module -v |
Shows where the executing code comes from, such as from what
shared library
|
| whatis {varibalename} | Shows the type of the variable named variablename. |
| whatis -t {typename} | Shows what type the type named by typename is. |
Autologout of a shell
# to disable:
unset autologout
# put it in .cshrc or .tcshrc to make it always disabled
Information about the system
uname --help
uname -X
uname -a
uname
Which version of Solaris am I running on
showrev