Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22024

How to calculate text, rodata, data and bss sizes of one module in C?

$
0
0

In my project, I first compile aa_1.c, aa_2.c... from folder A, then compile bb_1.cbb_2.c... from folder B. Then I use gcc-ar to generate libapps.a. At last, I link with other static libraries.

Now I want to calculate text, rodata, data and bss section of folder A.

My method is to execute gcc-nm -S --size-sort folder/*.o, and accumulate text, rodata, data and bss sections. But some functions may be optimized away because they're never called.

So how can I calculate text, data, rodata and bss sizes?

I also have another question, using gcc-nm -S --size-sort a.o there is no 'b' type. But using gcc-size a.o shows bss section is 8 bytes. So which one is right?


Viewing all articles
Browse latest Browse all 22024

Trending Articles