Reputation: 19
size my_obj.o
, lists the size of text, .data segments
in bytes.
but readelf -t my_obj.o
gives different size (much lesser) of text & data segments.
**text .data .bss**
200890 4797 88
146172 1960 88
object dump also gives similar results.
Upvotes: 1
Views: 2020
Reputation: 10261
size
by default runs in "Berkeley compatibility mode".
In this mode, it will include certain non-executable read-only sections that have the ALLOC bit set, such as .rodata
, as text, and it will classify some non-executable non-NOBITS sections as data instead of bss.
If you run size
in "System V compatibility mode", size -A my_obj.o
, it should give you sizes close to the values reported by readelf -t
.
Upvotes: 3