Chandan chandanlog(3C)
or sayings of an hearer
or A Blog of a Security Engineer
or The Official Online Journal of Chief Executive Prankster, Sun Microsystems Inc.,

All (Archive) | General | Solaris | Security | Art | About | |
General Solaris Security Art

« OpenSolaris Source... | Main | Spiders get to OpenS... »
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.
  1. Often you can just search for binary name in path field of OpenSolaris source search page. For eg. path:pargs
  2. 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.
  3. 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.
  4. 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 |

Comments:

Post a Comment:

Comments are closed for this entry.

« OpenSolaris Source... | Main | Spiders get to OpenS... »

Copyright (cc) 2004-2006 by Chandan chandanlog(3C): From Binaries to the Source