14 Jun 2005
From Binaries to the Source

This is perhaps the most common question if you are new to Solaris code:
Where do I find the sources for a given binary (say /usr/bin/pargs)?
There are several ways you can reach the source using
OpenSolaris' new
source search page.
- Often you can just search for binary name in path field of OpenSolaris source search page.
For eg. path:pargs
- Otherwise search for binary name only in Makefiles.
For eg., to find ypbind sources, put ypbind in full-text field,
Makefile in path field or just use the search syntax ypbind path:Makefile. Note that, not all Makefiles reside in the same directory as their source files.
- If the symbol table wan't removed from the binary, FILE rows in *nm* output give a clue about source file(s) used for generating that binary.
$ nm /usr/lib/libmtmalloc.so.1 |grep FILE
[32] | 0| 0|FILE |LOCL |0 |ABS |crti.s
[65] | 0| 0|FILE |LOCL |0 |ABS |crtn.s
[1] | 0| 0|FILE |LOCL |0 |ABS |libmtmalloc.so.1
[34] | 0| 0|FILE |LOCL |0 |ABS |mtmalloc.c
[33] | 0| 0|FILE |LOCL |0 |ABS |values-Xa.c
Now searching for path:mtmalloc.c hits that file.
- Another way, might be to run *strings* on the binary and pick out
a phrase that looks unique and do a phrase search (within double quotes):
$ strings /usr/lib/netsvc/yp/ypbind
...
usage: ypbind [-broadcast] [-ypset] [-ypsetme]
...
Now put the phrase in quotes in full-text search box:
"usage: ypbind [-broadcast] [-ypset] [-ypsetme]".
You directly hit the source line having that string!
Trick is to find something in binary, that is likely to be uniquely
common between both
the binary its source file(s) and then search for it.
Technorati Tag:
OpenSolaris
Technorati Tag:
Solaris
Link |