In my project, I first compile aa_1.c
, aa_2.c
... from folder A
, then compile bb_1.c
bb_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?