1

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.

1 Answer 1

3

you can use the size utility:

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

Sign up to request clarification or add additional context in comments.

1 Comment

sorry, I'm not quite familiar with gcc. Could you explain it with more details ? Where should I put the size command?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.