Operating System - HP-UX
1754020 Members
8043 Online
108811 Solutions
New Discussion юеВ

Re: excessively large executables

 
Michael Murphy_2
Frequent Advisor

excessively large executables

Hello,

I have a machine that has executables created by developers that are very large (>50meg and some libs >200 meg). I suspect that they are linking in some large libraries that may not be needed. Any tools available to investigate what is contained in a c++ exec, and whether libs linked in are in fact used?

Thanks...
2 REPLIES 2
A. Clay Stephenson
Acclaimed Contributor

Re: excessively large executables

I'm willing to bet that these are statically linked executables. That can be good from the standpoint that the developer knows that they will run on any system but it does produce large, memory-wasteful executables.

Do a chatr filename. If you see no shared libraries listed then you are statically linked. Ldd can also be used. It will either report the shared libraries utilized or it will report ' "myfile" is not a shared executable' -- indicating that "myfile" is statically linked.

Man chatr, ldd for details.
If it ain't broke, I can fix that.
Gregory Fruth
Esteemed Contributor

Re: excessively large executables

Use "ldd" or "chatr" to see what shared
libraries are in an executable. If the
library was an archive library, I don't
know of a tool that can get the library
name. But you can use "nm" to snoop around
to see what objects are in the executable.

However, I don't think the linker will link
in library code that's not used (either
archive or shared). One thing that can
bloat executables is having a lot of
initialized arrays:

double a[100000] = {0, 1, ...};

The compiler will make space in the
executable for the entire array.
Unitialized arrays (the same as above,
minus the = {0, 1, ...} part) are set up
at run time.

Use the "size -v" commmand to see how
much space is being used in an executable
for each type of data. In the "size -v"
output, $CODE is the program's executable
code, $BSS contains the unitialized arrays
and variables, and $DATA is the initialized
arrays and variables.

HTH