Lists section sizes of an executables or object files.

linux1

Traditionally Linux has been supporting different file formats, most common is ELF, as it is flexible and extensible by design. For a given executable, there are four sections, in which information is arranged, namely .text, .data, .bss and .rodata.

.text section contains executable code and is packed in segment with read and execute access rights, as this part doesn’t change runtime.

.data section contains initialized data and segment has read/write access rights.

.bss section contains uninitialized data or statically allocated data.

.rodata is basically part of .text or is combined with .text section as it contains read only data.

No matter how many times program is executed .text is copied into memory only once. But for each instance of program, there is separate copy of others.

If you want to know sizes of each of these sections for a given executable

$ size /bin/ls
 text   data  bss   dec    hex   filename
 105475 1088  3172  109735 1aca7 /bin/ls

In above ouput, first column shows size of .text section in bytes in decimal, then .data and .bss.

Size of complete executable in decimal and hex is in dec and hex respectively.

If you sum text, data and bss then total should be dec.

For more info on size, see man page size(1)

Enjoy!

Post a Comment

You must be logged in to post a comment.
%d bloggers like this: