Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MAP file analysis - where's my code size comes from?

I am looking for a tool to simplify analysing a linker map file for a large C++ project (VC6).

During maintenance, the binaries grow steadily and I want to figure out where it comes from. I suspect some overzealeous template expansion in a library shared between different DLL's, but jsut browsign the map file doesn't give good clues.

Any suggestions?

like image 285
peterchen Avatar asked Feb 23 '09 11:02

peterchen


People also ask

What does map file contains?

A mapfile is a text file that contains the following information about the program being linked: The module name, which is the base name of the file. The timestamp from the program file header (not from the file system)

What is the use of .map file?

More generically, the . MAP extension can be used to denote any file type that indicates relative offsets from a starting point. MAP file types are used in this way, for example, when variables in software are expected to be "mapped" to a specific spot in memory.

What is map file linker?

A linker map is a file produced by the linker. The file shows the symbols and sections contained in a binary. The linker also provides the memory address and size for each symbol.

What is map file in embedded system?

The map file is generated by the linker and the format of the file will be different for each linker. Your best bet is the documentation for the linker itself - there is unlikely to be a "general" tutorial. However for the most part a map file is simply a table of symbols, their location and their size.


2 Answers

This is a wonderful compiler generated map file analysis/explorer/viewer tool. Check if you can explore gcc generated map file.

amap : A tool to analyze .MAP files produced by 32-bit Visual Studio compiler and report the amount of memory being used by data and code. This app can also read and analyze MAP files produced by the Xbox360, Wii, and PS3 compilers.

like image 174
prashant Avatar answered Sep 28 '22 07:09

prashant


The map file should have the size of each section, you can write a quick tool to sort symbols by this size. There's also a command line tool that comes with MSVC (undname.exe) which you can use to demangle the symbols.

Once you have the symbols sorted by size, you can generate this weekly or daily as you like and compare how the size of each symbol has changed over time.

The map file alone from any single build may not tell much, but a historical report of compiled map files can tell you quite a bit.

like image 32
Dan Olson Avatar answered Sep 28 '22 09:09

Dan Olson