Pony279
Pony279

Reputation: 523

How to make gcc linker output section size at command line?

I program for MCUs. The size of code and data is important and I need to know the size of these section after compiling. I've known how to get these imformation. Just define

__text_size = SIZEOF(.text);

in the linker script file, and than I can get the value of it in the map file output by the linker. (the ".text" is a section defined in my linker script file). However, I hate to open the map file and search for the __text_size every time after compiling and linking. Is there any way to tell the linker to output the size of a section at command line? The Keil, for example, always output the code, rodata, data and zi-data size after compiling.

Upvotes: 1

Views: 3309

Answers (1)

iabdalkader
iabdalkader

Reputation: 17312

you can use the size utility:

$size test
text data bss dec hex filename
1153 504 24 1681 691 test

Upvotes: 3

Related Questions