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

1

7

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?

Weevil answered 5/10, 2010 at 13:32 Comment(2)
dumpbin should IMHO show you big global/statics.Tomaso
@Tomaso any details on how to do it? I've explored a bit and couldn't seem to figure it out.Weevil
D
5

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.

Discontinue answered 10/10, 2010 at 8:17 Comment(2)
This is absolutely fantastic! They have this stupid 24 hour policy for bounty :PWeevil
Just took a look at nm -S. What a simple problem that is so obscure to solve on Windows :PWeevil

© 2022 - 2024 — McMap. All rights reserved.