Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tool to analyze size of ELF sections and symbol

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.

like image 726
RushPL Avatar asked Jul 30 '12 11:07

RushPL


People also ask

How do I read ELF files?

you can use readelf and objdump to read parts of an elf file. You can also use 'hexdump filename' to get a hexdump of the contents of a binary file (this is likely only useful if you like reading machine code or you are writing an assembler).

What is the size of ELF?

Size: Elves range from under 5 to over 6 feet tall and have slender builds.


1 Answers

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.

like image 103
ouah Avatar answered Sep 28 '22 02:09

ouah