I need to do analysis of memory requirements of one library written in C++, because HW engineers need get some idea about memory requirements of our hardware, there are working on. I can measure heapsize peak, I can measure stack size, but I don't know how to estimate/measure data segment size and Bss size. Is there any method in Visual Studio or GCC? I assume it will differs from compiler to compiler and from platform to platform, but an estimation is fine for me.
Asked
Active
Viewed 2,766 times
1
-
Have you tried just cross-compiling to your target platform and checking the produced binaries? – harald Mar 02 '15 at 13:23
-
2GCC (pedantically, GNU binutils) has a tool called [`size`](http://linux.die.net/man/1/size) for this. – Mike Seymour Mar 02 '15 at 13:28
-
I can cross-compile it for ARM in IAR Workbench. Do you mean that it should be possible to detect this from this IDE/tool somehow? – Tomas Kubes Mar 02 '15 at 13:29
3 Answers
4
There is a size
utility.
E.g. for ARM MCU project it can be something like:
arm-none-eabi-size --format=sysv "program_name.elf"
Example output:
program_name.elf :
section size addr
.text 14516 0
.data 160 268435456
.bss 1328 268435616
.stack 2528 268436944
.debug_aranges 2384 0
.debug_info 40951 0
.debug_abbrev 8870 0
.debug_line 27790 0
.debug_frame 6664 0
.debug_str 42157 0
.debug_loc 7074 0
.debug_macinfo 426030 0
.ARM.attributes 47 0
.debug_ranges 1760 0
.comment 96 0
.debug_macro 9236 0
Total 591591

Andrey Derevyanko
- 550
- 5
- 12
2
During the build:
For VC++ run
link.exe /map
.For GCC run
ld -Map
.
Both options generate a map file which will contain the segment sizes.

Remus Rusanu
- 288,378
- 40
- 442
- 569
2
You can use objdump
to get the size of the text, data and bss segments on Linux systems. You can examine the output for the .bss
and .text
sections.
See here for a more detailed explanation.

Community
- 1
- 1

Alexandru C.
- 3,337
- 1
- 25
- 27