Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Analyze .exe/.dll (Windows PE) files for code bloats

Let's say I have a project with a dozen of different modules which produce one resultant DLL, how can I analyze it so that I can identify the actual file size that each module/functions contribute? I know it might be impossible with a Release build where much information has been stripped, but how about if I have the full source and can do a Debug build?

Also, if there are big static variables defined somewhere, is there a way I can easily locate them?

Bonus question: How about Linux ELF files?

like image 471
kizzx2 Avatar asked Oct 05 '10 13:10

kizzx2


1 Answers

Whenever I've been involved in identifying bloat I generally start with dumpbin on Windows. Usually by writing a tool to examine each object module via dumpbin then analyse the output. It tends to be an iterative process and can take a fair amount of time.

For debug builds with PDB Sizer can produce useful reports.

Adrian has some useful guidance here. Minimizing Code Bloat for Faster Builds and Smaller Executables and a tool called SymbolSort to help. The source in C# is included with SymbolSort so that may be a good place to start if SymbolSort doesn't help.

For ELF the output of nm and objdump are a good starting point.

like image 120
Richard Harrison Avatar answered Sep 28 '22 07:09

Richard Harrison