Greetings, I have a problem understanding how the arm-elf-size command works: When I use 'arm-elf-size -A' I get: arm-elf-size -B Output/Exe/Bootstrapper.elf text data bss dec hex filename 18068 0 5508 23576 5c18 Output/Exe/Bootstrapper.elf When I use 'arm-elf-size -B' I get: arm-elf-size -A Output/Exe/Bootstrapper.elf Output/Exe/Bootstrapper.elf : section size addr .startup 80 1048576 .text 16892 1048656 .data 1096 2097152 .bss 5508 2098248 .debug_abbrev 22956 0 .debug_info 102031 0 .debug_line 19194 0 .debug_frame 9912 0 .debug_loc 44707 0 .debug_pubnames 8590 0 .debug_aranges 4768 0 .debug_ranges 2104 0 .debug_str 17160 0 .comment 1188 0 Total 256186 Question is : Why does '-A' not show how much .data is used ? When trying to optimize the code I need to know how much flash-space and how much RAM is used. Using option '-A' I cannot see the .data-sections size so this is useless here. Using option '-B' I can see how much space is used in each segment, but I have to manually calculate the used space as in "Flash = .startup + .text + .data" and "RAM = .data + .bss". The '-B' option is the must usefull one but not very good. Is there a way / tool that can produce an output that simply tells me how much code space and RAM space I have used ??? Cheers RaceMouse P.S. This is using both GCC-4.1.0 and GCC-4.1.1 P.P.S. This is a crosspost from gnu.gcc.help, but there seems to be a lot more activity here - leading to an increasing the chance for an answer :-)
arm-elf-size
Started by ●June 21, 2007
Reply by ●June 23, 20072007-06-23
RaceMouse wrote:> When I use 'arm-elf-size -A' I get:Actually, no. You used the -B option here:> arm-elf-size -B Output/Exe/Bootstrapper.elf > text data bss dec hex filename > 18068 0 5508 23576 5c18 Output/Exe/Bootstrapper.elf > > When I use 'arm-elf-size -B' I get:... and -A here:> arm-elf-size -A Output/Exe/Bootstrapper.elf > Output/Exe/Bootstrapper.elf : > section size addr > .startup 80 1048576 > .text 16892 1048656 > .data 1096 2097152 > .bss 5508 2098248[...]> Total 256186> Why does '-A' not show how much .data is used ?First of all because it's -B, not -A, that fails to show it. Second reason is: because. The -B format is the traditional default output format of this tool, i.e. it's governed by history, not maximum possible usefulness. Third, possible reason is that your linker script is slightly strange, putting data into a segment where 'size -B' doesn't know to look for it. For comparison, some other platform has text = .text + .rdata data = .data + .idata Yours appears to have neither .rdata nor .idata. The fourth reason could be that your program just happens to have no initialized data at all, only constants and zero-initialized data. Quite impossible to tell without seeing the details section lists (objdump -s).
Reply by ●June 25, 20072007-06-25
Hans-Bernhard Br�ker wrote:> First of all because it's -B, not -A, that fails to show it. > > Second reason is: because. The -B format is the traditional default > output format of this tool, i.e. it's governed by history, not maximum > possible usefulness.I will send a feature request to the devs of arm-elf-size. A new option "-C" wich will produce a usable output... Until then : Do you have any idea how I can work around this and get me a usable output ?> > Third, possible reason is that your linker script is slightly strange, > putting data into a segment where 'size -B' doesn't know to look for it. > For comparison, some other platform has > > text = .text + .rdata > data = .data + .idata >I use -ffunction-sections and -fdata-sections when compiling. This puts all functions into their own (.text.*) segment and ofcourse all data segments into their own (.data.*) - not (.data). This explains why arm-elf-size -B can't see it. Thanks for the tip.> Yours appears to have neither .rdata nor .idata. > > The fourth reason could be that your program just happens to have no > initialized data at all, only constants and zero-initialized data. Quite > impossible to tell without seeing the details section lists > (objdump -s).
Reply by ●June 25, 20072007-06-25
RaceMouse wrote:> Hans-Bernhard Br�ker wrote:> I will send a feature request to the devs of arm-elf-size. A new option > "-C" wich will produce a usable output...The -A output is quite usable as it is --- it has more information than you need.> Until then : Do you have any idea how I can work around this and get me > a usable output ?Use the tools like they're supposed to be: as parts of a toolset, not as single be-all-and-do-everything gizmos. In the case at hands, that means to write a little script in a suitable scripting language (shell, awk, perl, python, whatever floats your boat) that parses 'size -A' output and computes whatever you want from the output. > I use -ffunction-sections and -fdata-sections when compiling. This puts> all functions into their own (.text.*) segment and ofcourse all data > segments into their own (.data.*) - not (.data).But the linker joins those segments back together into a single '.data' segment, as you can see in the 'size -A' output you posted originally.