Operating System - HP-UX
1752793 Members
6234 Online
108789 Solutions
New Discussion юеВ

finding which shared libraries aren't used by a binary

 
SOLVED
Go to solution
Stefan Puiu
Advisor

finding which shared libraries aren't used by a binary

Hello,

We have a very old software project that also runs on HP-UX and that has been maintained and developed for some time by people not very familiar with UNIX. Lots of the Makefiles were just copied from one place to another and edited when a new subproject was added. Thus, lots of the linked libraries don't seem necessary.

We had this problem when building on Solaris, which is another platform we support; we had a problem with a library that we found out we didn't actually need. On Solaris you can give a command line option to the linker and it won't dynamically link any library from those specified with -l if it isn't actually used. Is there something similar for the HP-UX linker? We have aCC A.03.55 on HP-UX 11i (PA-RISC). Or something to tell which shared libraries are actually used?
3 REPLIES 3
RAC_1
Honored Contributor

Re: finding which shared libraries aren't used by a binary

ldd "executable"

chatr "executable"
There is no substitute to HARDWORK
Stefan Puiu
Advisor

Re: finding which shared libraries aren't used by a binary

Thanks for replying,

So am I to understand that the libraries in the ldd output that don't show up in the list printed by chatr aren't actually used?
ranganath ramachandra
Esteemed Contributor
Solution

Re: finding which shared libraries aren't used by a binary

there is no equivalent option as yet with the hpux linker. the loader loads all libraries that were specified in the link line.

you can use ldd with options such as -y, -d and -r to see what symbols are being resolved from what libraries, then grep through the listing to weed out the ones that arent really being used. e.g.
ldd -y a.out | grep "found in .*/libsuspect.sl"

you can get similar information at link time using the linker's -v option.

you can also look at the the lazy load feature (look for +lazyload in the ld(1) manpage). this will make the loader load each library only as and when it is needed, instead of at startup.
 
--
ranga
[i work for hpe]

Accept or Kudo