xref: /freebsd/contrib/elftoolchain/size/size.1 (revision d6b92ffa)
1.\" Copyright (c) 2007 S.Sam Arun Raj
2.\" Copyright (c) 2008,2011 Joseph Koshy
3.\" All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\"
14.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24.\" SUCH DAMAGE.
25.\"
26.\" $Id: size.1 3195 2015-05-12 17:22:19Z emaste $
27.\"
28.Dd August 25, 2011
29.Dt SIZE 1
30.Os
31.Sh NAME
32.Nm size
33.Nd "display section sizes and total size of ELF objects"
34.Sh SYNOPSIS
35.Nm
36.Op Fl -format= Ns Ar format
37.Op Fl -help
38.Op Fl -radix= Ns Ar radix
39.Op Fl -totals
40.Op Fl -version
41.Op Fl ABVdhotx
42.Op Ar
43.Sh DESCRIPTION
44The
45.Nm
46utility
47lists the sizes of ELF sections, and optionally the total size, for
48each input
49.Ar file
50specified on the command line.
51The
52.Nm
53utility can operate on ELF objects, on
54.Xr ar 1
55archives containing ELF objects, and on core dumps.
56If no file name is specified on the command-line,
57.Pa a.out
58is assumed.
59.Pp
60The
61.Nm
62utility recognized the following options:
63.Bl -tag -width indent
64.It Fl -format= Ns Ar format
65Display output using the format specified by argument
66.Ar format .
67Supported values for this argument are:
68.Sq berkeley
69and
70.Sq sysv .
71The default output format is
72.Sq berkeley .
73See
74.Sx Display Formats
75below for more information.
76.It Fl -help
77Display a help message and exit.
78.It Fl -radix= Ns Ar radix
79Display numeric values using the radix specified by argument
80.Ar radix .
81Supported values for
82.Ar radix
83are 8, 10 and 16.
84The default radix is 10.
85.It Fl -totals
86Shows cumulative totals of section sizes from all objects.
87This option is ignored for System V style output.
88.It Fl -version
89Display a version identifier and exit.
90.It Fl A
91Equivalent to specifying option
92.Fl -format= Ns Ar sysv .
93.It Fl B
94Equivalent to specifying option
95.Fl -format= Ns Ar berkeley .
96.It Fl V
97Equivalent to specifying option
98.Fl -version .
99.It Fl d
100Equivalent to specifying option
101.Fl -radix= Ns Ar 10 .
102.It Fl h
103Equivalent to specifying option
104.Fl -help .
105.It Fl o
106Equivalent to specifying option
107.Fl -radix= Ns Ar 8 .
108.It Fl t
109Equivalent to specifying option
110.Fl -totals .
111.It Fl x
112Equivalent to specifying option
113.Fl -radix= Ns Ar 16 .
114.El
115.Sh DISPLAY FORMATS
116.Ss Berkeley Style Output
117If
118.Sq berkeley
119style output is in effect, an initial header line naming fields will
120be output, followed by one line of output for each ELF object specified
121on the command line or found in an archive.
122.Pp
123Each line will contain the following whitespace separated fields
124in order:
125.Bl -enum -compact
126.It
127The size of the text segment in the object.
128.It
129The size of the data segment in the object.
130.It
131The size of the
132.Sq bss
133segment in the object.
134.It
135The total size of the object in either decimal or octal.
136Decimal output is used if the specified output radix for numeric values
137is 10 or 16.
138Octal output is used if the radix being used for numeric values
139is 8.
140.It
141The total size of the object in hexadecimal.
142.It
143The file name of the object.
144.El
145.Pp
146If option
147.Fl -totals
148was specified, an additional line in the same format as above will be
149output at the end containing the sum of the respective fields.
150The file name field for the line will contain the string
151.Sq (TOTALS) .
152.Ss System V Style Output
153If System V style output is selected,
154.Nm
155will output the following information for each object:
156.Bl -enum -compact
157.It
158The name of the object followed by a colon.
159.It
160A header line containing the names of fields of subsequent lines.
161.It
162One line per section present in the object.
163Each line has three fields:
164.Bl -enum -compact
165.It
166The name of the section.
167.It
168Its size, in the selected radix for numeric values.
169.It
170The address associated with the section, in the selected numeric radix.
171.El
172.It
173A line whose section name field contains the string
174.Sq Total
175and whose size field contains the sum of all reported section sizes.
176.El
177.Sh EXIT STATUS
178.Ex -std
179.Sh EXAMPLES
180To display the section sizes for
181.Pa /bin/ls
182use:
183.Bd -literal
184$ size /bin/ls
185text       data       bss        dec        hex        filename
18620975      540        392        21907      5593        /bin/ls
187.Ed
188.Pp
189To display sizes and total for
190.Pa /bin/ls
191and
192.Pa /bin/dd
193in hexadecimal, use:
194.Bd -literal
195$ size -tx /bin/ls /bin/dd
196text       data       bss        dec        hex        filename
1970x51ef     0x21c      0x188      21907      5593        /bin/ls
1980x3df5     0x170      0x200      16741      4165        /bin/dd
1990x8fe4     0x38c      0x388      38648      96f8       (TOTALS)
200.Ed
201.Pp
202To display section sizes for
203.Pa /bin/ls
204in System V format use:
205.Bd -literal
206$ size -A /bin/ls
207/bin/ls  :
208section            size       addr
209\&.interp            21         4194704
210\&.note.ABI-tag      24         4194728
211\&.hash              624        4194752
212\&.dynsym            2088       4195376
213\&.dynstr            810        4197464
214\&.rela.dyn          120        4198280
215\&.rela.plt          1656       4198400
216\&.init              19         4200056
217\&.plt               1120       4200076
218\&.text              15224      4201200
219\&.fini              14         4216424
220\&.rodata            1472       4216448
221\&.data              80         5267456
222\&.eh_frame          1624       5267536
223\&.dynamic           384        5269160
224\&.ctors             16         5269544
225\&.dtors             16         5269560
226\&.jcr               8          5269576
227\&.got               576        5269584
228\&.bss               528        5270176
229\&.comment           686        0
230Total              27110
231.Ed
232.Sh SEE ALSO
233.Xr ar 1 ,
234.Xr nm 1 ,
235.Xr objdump 1 ,
236.Xr readelf 1 ,
237.Xr strings 1 ,
238.Xr elf 3 ,
239.Xr gelf 3
240.Rs
241.%A "AT&T Unix Systems Labs"
242.%T "System V Application Binary Interface"
243.%O http://www.sco.com/developers/gabi/
244.Re
245.Sh HISTORY
246The
247.Nm
248utility first appeared in
249.At v6 .
250.Sh AUTHORS
251.An -nosplit
252The
253.Nm
254utility was re-written by
255.An S. Sam Arun Raj Aq Mt samarunraj@gmail.com
256This manual page was written by
257.An S. Sam Arun Raj Aq Mt samarunraj@gmail.com
258