Maulik
Maulik

Reputation: 19

"size" vs "readelf -t" command gives different segment length

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

Answers (1)

Mark Plotnick
Mark Plotnick

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

Related Questions