SIZE(1)SIZE(1) NAME size - Prints the section sizes of object files SYNOPSIS size [-d] [-f] [-n] [-o] [-4] [-svr4] [-x] [-A] [-B] [-F] [-V] files DESCRIPTION The size command prints segment or section information in bytes about the various sections or segments of each named ELF object file. file can be an object or an archive. When calculating segment information, the size command prints out the total file size of the non-writable segments, the total file size of the writable segments, and the total memory size minus the total file size of the writable segments. If it cannot find segment information, size performs calculations based on section information. When performing calculations based on section information, it calculates the total size of sections that are allocatable, non-writable and not NOBITS; the total size of the sections that are allocatable, writable, and not NOBITS; and the total size of the writable sections of type NOBITS (NOBITS sections do not actually take up space in the file.) The following sections may be mentioned and counted: .text, .init, .rdata, .data, .sdata, .sbss, .dynsym, .dsolist, .conflict, and .lcldta. Some of the sections marked allocatable, for example, .strtab and .symtab, may be a surprise, because they do not seem as if they would be loaded at run time. However, some of this information does get into symbol tables which, for shared-code (PIC) are in memory at run time so rld(1) can use them. By default, the output format is that of AT&T System V Release 3 showing sections (not segments) as described above, followed by System V Release 4-style totals. size supports the following options: -d Prints the sizes in decimal. -f Prints out the size of each allocatable section, the name of the section, and the total of the section sizes. If there is no section data, size prints out an error message and stops processing the file. Segment information is ignored; only section information is used. -n Prints out non-loadable segment or non-allocatable section sizes. If segment data exists, size prints out the memory size of each loadable segment or file size of each non- loadable segment, the permission flags, and the total size of the segments. If there is no segment data, size prints out, for each allocatable and non-allocatable section, the memory size, the section name, and the total size of the sections. If there is no segment or section data, size prints an error message and stops processing. -o Prints the sizes in octal. -4 Suppresses detailed listings, leaving just the AT&T System V Release 4 summary output. Prints segment information if present, rather than section information (unless -f is also specified). -svr4 The same as specifying -4, but deprecated as multi-letter options are not appropriate under System V Release 4 option guidelines. -x Prints the sizes in hexadecimal. -A Use AT&T System V Release 3-style output. This is the default style. This style is more verbose than the -4 output; each section is printed with both size and physical and virtual addresses. It is followed by the System V Release 4-style totals. Segment information is ignored; only section information is used. -B Use Berkeley-style (4.3BSD) output. This style prints size information for each section, regardless of whether the file exists, and prints the total in both hexadecimal and decimal. The text and data section sizes reported may be rounded to page sizes. In the rounding (done by ld(1)) some bss may be moved into data. The numbers reported are the actual numbers used to load the program into memory. Only sections named .text, .init or .fini are counted as text. Segment information is ignored; only section information is used. -F Prints out the size of each loadable segment, the permission flags of the segment, then the total of the loadable segment sizes. If there is no segment data, size issues an error and stops processing the file. -V Prints the version of size on standard error. NOTES If size cannot calculate either segment or section information, it prints an error message and stops processing the file. Because the size of .bss sections is not known until link-time, size will not give the true total size of pre-linked objects. The rounding shown by the -B option can have effects that may be surprising; reducing the size of data a small amount can result in some bss space being moved from the rounded data back into bss and make bss appear to grow. Some sections are shown and counted as data with the -B option that might be considered text. For example, the .rodata section is counted as data even if it is part of the shared text program header segment. The -B option interacts strangely with other options such as -n and -f, making the output useless. If the -svr4, -4, -A, and -B options are specified, the last one specified is applied. For executables, size -4 a.out is more accurate than size -B a.out because the former reports totals of precisely what the kernel must load (using segment information) and the latter reports how the sections describe a.out; but this is counting only the text as text, not counting .dynsym, etc. The -B format directly describes the executable instructions (leaving out read-only tables), so for some purposes it may be more useful. Most section names previously mentioned are described in the Application Binary Interface books mentioned in the SEE ALSO section. In addition, some sections are described in the MIPSpro Assembly Language Programmers Guide. EXAMPLES The following examples show typical size output. size -4 file 90112 + 12288 + 0 = 102400 size -svr4 -f file 19(.interp) + 24(.reginfo) + 192(.dynamic) + 32(.liblist) /e + 1200(.msym) + 1600(.dynstr) + 2384(.dynsym) + 1632(.hash) /e + 82560(.text) + 32(.init) + 1472(.data) + 8000(.rodata) + /e 464(.got) + 48(.bss) = 99659 size -4 -F file 90112(r-x) + 12288(rw-) = 109483 FILES /usr/include/elf.h /usr/include/sys/elf.h SEE ALSO a.out(4) System V Application Binary Interface, Prentice Hall, ISBN 0-13-877598-2 System V Application Binary Interface MIPS, Processor Supplement, Prentice Hall, ISBN 0-13-880170-3 MIPSpro Assembly Language Programmer's Guide