In Linux, you can use nm
to show all symbols in the executable and to sort them in reverse order by size:
$ nm -CSr --size-sort <exe>
Options:
-C
demangles C++ names.
-S
shows size of symbols.
--size-sort
sorts symbols by size.
-r
reverses the sort.
If you want to get the results per namespace or per class, you can just grep
the output for 'namespace::
', 'namespace::class_name::
', etc..
If you only want to see symbols that are defined in the executable (not ones defined elsewhere, like in libraries) then add --defined-only
. Sorting by size should take care of this, though, since undefined symbols aren't going to have a size.
For Windows, you should still be able to use nm
on your binary files, since nm
supports COFF binaries. You can install nm
via cygwin, or you could copy your windows executable to a linux box and run nm
on it there.
You could also try dumpbin
, which dumps info about a binary on Windows. You can get info on symbols with the /SYMBOLS
switch, but it doesn't look like it directly provides information about their size.