SIZE(1) SIZE(1)
size - print the section sizes of object files
size [ -d -f -n -o -4 -svr4 -x -A -B -F -V ] files
The size command prints segment or section information in bytes about the
various sections or segments of each named ELF object file. Each 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 calculates based on section
information. When calculating 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.)
Among the sections which may be mentioned and counted are: .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, since they don't 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 Print 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 nonallocatable
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.
Page 1
SIZE(1) SIZE(1)
-o Print the sizes in octal.
-4 Suppress detailed listings, leaving just the AT&T System V Release 4
summary output. If segment information is present, print it rather
than section information (unless -f is also present).
-svr4
The same as -4, but deprecated as multi-letter options are not
appropriate under System V Release 4 option guidelines.
-x Print 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 prints an error and stops processing
the file.
-V Print the version of size on standard error.
The examples below show typical size output.
size -4 file
90112 + 12288 + 0 = 102400
size -svr4 -f file
19(.interp) + 24(.reginfo) + 192(.dynamic) + 32(.liblist) + 1200(.msym)
+ 1600(.dynstr) + 2384(.dynsym) + 1632(.hash) + 82560(.text) + 32(.init)
+ 1472(.data) + 8000(.rodata) + 464(.got) + 48(.bss) = 99659
Page 2
SIZE(1) SIZE(1)
size -4 -F file
90112(r-x) + 12288(rw-) = 109483
a.out (4)
System V Application Binary Interface
Pub by Prentice Hall,
ISBN 0-13-877598-2
System V Application Binary Interface MIPS
Processor Supplement
Pub by Prentice Hall,
ISBN 0-13-880170-3
MIPSpro Assembly Language Programmer's Guide
/usr/include/elf.h
/usr/include/sys/elf.h
size cannot calculate either segment or section information, it prints an
error message and stops processing the file.
Since 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 surprise:
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 in some sense. 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.
The last of -svr4, -4, -A, and -B is the option applied if more than one
is supplied.
For executables, arguably size -4 a.out is more accurate than size -B
a.out since the former reports totals of precisely what the kernel must
load (using segment information) whereas the latter reports how the
sections describe the a.out but counting only the text as text, not
counting .dynsym etc. On the other hand, the -B format does directly
describe the executable instructions (leaving out read-only tables) so
for some purposes it may be more useful.
Section names given above are mostly described in the Application Binary
Interface books mentioned in the SEE ALSO section above. In addition,
some sections are described in the MIPSpro Assembly Language Programmers
Page 3
SIZE(1) SIZE(1)
Guide (mentioned above).
PPPPaaaaggggeeee 4444 [ Back ]
|