Tool to analyze size of ELF sections and symbol

2019-01-13 04:32发布

I need a way to analyze output file of my GCC compiler for ARM. I am compiling for bare metal and I am quite concerned with size. I can use arm-none-eabi-objdump provided by the cross-compiler but parsing the output is not something I would be eager to do if there exists a tool for this task. Do you know of such a tool existing? My search turned out no results.

One more thing, every function in my own code is in its own section.

2条回答
何必那么认真
2楼-- · 2019-01-13 05:17

You can use nm and size to get the size of functions and ELF sections.

To get the size of the functions (and objects with static storage duration):

$ nm --print-size --size-sort --radix=d tst.o

The second column shows the size in decimal of function and objects.

To get the size of the sections:

$ size -A -d tst.o

The second column shows the size in decimal of the sections.

查看更多
SAY GOODBYE
3楼-- · 2019-01-13 05:29

The readelf utility is handy for displaying a variety of section information, including section sizes, e.g.:

arm-none-eabi-readelf -e foo.o

If you're interested in the run-time memory footprint, you can ignore the sections that do not have the 'A' (allocate) flag set.

查看更多
登录 后发表回答