I'm trying to understand linker map files. This is the beginning of my text-section:
.text 0x08000400 0x14ba0
0x08000400 . = ALIGN (_flash_alignment)
*(.text)
.text 0x08000400 0x40 .../lib/gcc/arm-none-eabi/10.3.1/thumb/v7e-m+dp/hard/crtbegin.o
.text 0x08000440 0x5ee4 .../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+dp/hard\libstdc++.a(cp-demangle.o)
0x0800623c __cxa_demangle
0x08006300 __gcclibcxx_demangle_callback
I used amap to analyze the map file and it reported a size of 196 bytes for __cxa_demangle and 24096 bytes for __gcclibcxx_demangle_callback.
I thought it works like this:
All the symbols from cp-demangle.o start at address 0x08000440 and there are a total of 0x5ee4 addresses used for all contained symbols.
__cxa_demangle starts at address 0x0800623c and ends at 0x08006300 - 1, so it has a size of 196 bytes.
So far, so good - this is matching what amap reported. But how is the size of __gcclibcxx_demangle_callback calculated?
If it starts at 0x8006300 and the whole section for cp-demangle.o ends at 0x08000440 + 0x5ee4 = 0x08006324, then __gcclibcxx_demangle_callback would have a size of 0x08006324 - 0x08006300 = 0x24 bytes. This is far off of the results yielded by amap.
Another thing that I don't understand is: What fills the memory between the start of the section at 0x08000440 and the start of __cxa_demangle at 0x0800623c? At the end of the day, the reported sizes from amap (196 bytes and 24096 bytes) sum up to 24292 which is the same 0x5ee4 (== number of adresses) that is written in the mapfile.