Topic : Code Size / Data Size in ride 7

Forum : Ride IDE

Original Post
Post Information Post
January 25, 2010 - 6:39am
Guest

This will seem to be a very trivial question,
but how do you know how much is code size of the compiled code.

i can see the text/data/bss mentioned against theC files and their dependencies.

but how do i know how much is the final size of code.

i get warning only when the code size exceeds!

i am using ride 7 ver 7.24.09.0251
Rkit ARM ver 1.2.09.0254

Example of code Structure
Project text = 6572 data = 0 bss =260

main.c text=640 data=0 bss=0
dep1.c text=316 data=0 bss=0
dep2.c text=796 data=0 bss=0
dep3.c text=36 data=0 bss=0
dep4.c text=3296 data=0 bss=0

Replies
Post Information Post
+1
0
-1
January 25, 2010 - 10:17am
Raisonance Support Team

Hi,

This is an interesting question. Not trivial at all.

First, please note that the word "code" does not mean much with GCC, except as a synonym of "text" or maybe "source code", which I don't think is what you meant. So let's not use it at all...

In FLASH mode (default), ...

.text goes to FLASH.
.bss (and stack) goes to RAM.
.data goes to RAM for the symbols and _also_ to FLASH for the initialization values.
(Yes, data uses twice the memory you declare!)

So the FLASH used is ( size_of_text + size_of_data )
And the RAM used is ( size_of_bss + size_of_data + size_of_stack )

Ride doesn't display the FLASH and RAM sizes used like explained above because this can change if you select RAM mode, or if you use a custom linker script and change the sections allocation to memory regions.
If in doubt look at the map file generated by the linker, it will tell you the exact addresses used for each section.

Note also that the total sizes of the project most often do not match the sum of the sizes of the input modules for these two reasons:

1. Uncalled functions and variables are counted in the C file size displayed, but are not linked so they are not counted in the project size. Because of that the project size can be _smaller_ than the sum of the sizes of the input files.

2. Library functions, startup, alignment gaps, etc. use memory space that does not appear in the C files sizes, but that does appear in the project sizes. Because of that the project size can be _larger_ than the sum of the sizes of the input files.

I hope it helps.

Best Regards,

Vincent

+1
0
-1
January 25, 2010 - 10:54am
Guest

thank you Vincent C for your reply.

I will tell you the reason i need to know this exact information.

while working on a 8bit controller (assume with 64k flash) with a popular Compiler/IDE.
the code size as displayed by the IDE doesnot include startup code,ram initialization routines.
hence if the firmware size goes beyond a certain limit (say 63k) code will compile but will lead to errors which cannot be determined.

for this very reason i wanted to know the exact code size(memory occupied by the complete code in memory (including startup routines, ram initializations, etc), so as to avoid problems as mentioned above.

regards