|
From: Greg C. <chi...@mi...> - 2004-09-21 14:08:02
|
Semmler, Sven wrote:
> Aunt google helped me to find the "-Wl,-Map,testapp.map" option I need
> to generate a map file. What I am trying to accomplish is finding the
> information how much ROM and RAM is used by the individual modules (C
> files) of my program. Therefor it would be helpful to find information
> how to read a map file. This should be described in the GCC manual IMHO,
> but I seem to be to blind to find it. Can anyone post a link or a
> chapter number please?
It's sort of mentioned in the 'ld' documentation:
-M
--print-map
Print a link map to the standard output. A link map provides
information about the link, including the following:
* Where object files and symbols are mapped into memory.
* How common symbols are allocated.
* All archive members included in the link, with a mention of the
symbol which caused the archive member to be brought in.
Here's a piece of a map file I have:
.data 0x004c9000 0x10 C:/MinGW/bin/../lib/gcc-lib/mingw32/3.2.3/../../../crt2.o
0x004c9000 _argc
0x004c9004 _argv
.data 0x004c9010 0x10 C:/local/lib/libmpatrol.a(malloc.o)
The .data section seems to be sorted by address. I think we can
conclude from this map that main()'s arguments start at the
address given, and that _argc probably takes four bytes, and
that _argv takes no more than twelve bytes, though it probably
takes less. I'm guessing that the difference between successive
addresses reflects not just object size but also alignment.
I'm casually assuming that the authors consider the map layout
self-explanatory, but if you find a good document that explains
this in detail, I'd like to hear about it.
Maybe something like 'objdump' or 'size' would be more useful
to you. Last time I checked (years ago) they were documented in
the 'binutils' manual.
|