I'm currently attempting to write my own program that mirrors the pmap command, specifically on Solaris 9. I'm having trouble resolving the names and paths of the libraries. Output of the Solaris command looks something like this, from a bash shell:
bash-2.05# pmap $$
2427: bash
00010000 496K r-x-- /usr/bin/bash
0009A000 80K rwx-- /usr/bin/bash
000AE000 120K rwx-- [ heap ]
FF100000 688K r-x-- /usr/lib/libc.so.1
FF1BC000 24K rwx-- /usr/lib/libc.so.1
FF1C2000 8K rwx-- /usr/lib/libc.so.1
FF200000 568K r-x-- /usr/lib/libnsl.so.1
FF29E000 32K rwx-- /usr/lib/libnsl.so.1
FF2A6000 32K rwx-- /usr/lib/libnsl.so.1
FF2F0000 8K rwx-- [ anon ]
FF300000 16K r-x-- /usr/lib/libmp.so.2
FF314000 8K rwx-- /usr/lib/libmp.so.2
FF320000 8K r-x-- /usr/platform/sun4u-us3/lib/libc_psr.so.1
FF330000 40K r-x-- /usr/lib/libsocket.so.1
FF34A000 8K rwx-- /usr/lib/libsocket.so.1
FF350000 168K r-x-- /usr/lib/libcurses.so.1
FF38A000 32K rwx-- /usr/lib/libcurses.so.1
FF392000 8K rwx-- /usr/lib/libcurses.so.1
FF3A0000 8K r-x-- /usr/lib/libdl.so.1
FF3B0000 8K rwx-- [ anon ]
FF3C0000 152K r-x-- /usr/lib/ld.so.1
FF3F6000 8K rwx-- /usr/lib/ld.so.1
FFBFC000 16K rw--- [ stack ]
total 2536K
I can mostly duplicate the program's basic features by reading /proc/$$/map, but what remains is figuring out how to resolve the library names, shown on the right. /proc/$$/map only gives the names of the files in /proc/$$/object, which are just generic names. On Solaris 10 (a box I have), I seem to be able to use /proc/$$/path, which contains symbolic links, but the box I'm working on doesn't have these. Does anyone have any straightforward ideas on how to get these library names? When I truss the program, it seems to open up /proc/$$/as and look through the memory and somehow find them, but I haven't been able to figure out where it's looking or why quite yet.