2

Surprisingly I was not able to find the size command unit. For example in

$ size cat
   text    data     bss     dec     hex filename
  29150    1148     416   30714    77fa cat

I want to know what is cat program's text size. So is it 29150 bytes?

  • Size (without the -m option) prints the (decimal) number of bytes required by the __TEXT, __DATA and __OBJC segments. Source: size(1) – Jesse_b Mar 30 '18 at 19:34
  • I have checked the man page for size. There is no byte mentioned there. Please post the whole man page if you can. Mine does not have byte in it. – masec Mar 30 '18 at 19:39
1

It appears the GNU size manual does not specify, however I believe they are in bytes for all versions of size.

Here is the Apple size manual:

SIZE(1)                                                                                                                               SIZE(1)

NAME
       size - print the size of the sections in an object file

SYNOPSIS
       size [ option ... ] [ object ... ]

DESCRIPTION
       Size  (without the -m option) prints the (decimal) number of bytes required by the __TEXT, __DATA and __OBJC segments.  All other seg-
       ments are totaled and that size is listed in the `others' column.  The final two columns is the sum in decimal and hexadecimal.  If no
       file is specified, a.out is used.

       The options to size(1) are:

       -      Treat the remaining arguments as name of object files not options to size(1).

       -m     Print  the  sizes  of the Mach-O segments and sections as well as the total sizes of the sections in each segment and the total
              size of the segments in the file.

       -l     When used with the -m option, also print the addresses and offsets of the sections and segments.

       -x     When used with the -m option, print the values in hexadecimal (with leading 0x's) rather than decimal.

       -arch arch_type
              Specifies the architecture, arch_type, of the file for size(1) to operate on when the file is a universal file.   (See  arch(3)
              for the currently know arch_types.)  The arch_type can be "all" to operate on all architectures in the file.  The default is to
              display only the host architecture, if the file contains it; otherwise, all architectures in the file are shown.

SEE ALSO
       otool(1)

BUGS
       The size of common symbols can't be reflected in any of the numbers for relocatable object files.

Apple Computer, Inc.                                            July 28, 2005                                                         SIZE(1)

And the SmartOS size manual:

SIZE(1)                          User Commands                         SIZE(1)



NAME
       size - print section sizes in bytes of object files

SYNOPSIS
       size [-f] [-F] [-n] [-o] [-V] [-x] filename...


DESCRIPTION
       The size command produces segment or section size information in bytes
       for each loaded section in ELF object files. size prints out  the size
       of the text, data, and bss (uninitialized data) segments (or  sections)
       and their total.


       size processes ELF object files entered on the command line. If an
       archive file is input to the size command, the information for each
       object file in the archive is displayed.


       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 of the writable
       segments minus the total  file size of the writable segments.


       If it cannot calculate segment information, size calculates section
       information. When calculating section  information, it prints out 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 filename.


       If size cannot calculate either segment or section information, it
       prints an error message and stops processing the file.

OPTIONS
       The following options are supported:

       -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.


       -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 message
             and stops processing the file.


       -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 numbers in octal, not decimal.


       -V
             Prints the version information for the size command on the
             standard error output.


       -x
             Prints numbers in hexadecimal, not decimal.


EXAMPLES
       The examples below are typical size output.

       Example 1 Producing size information

         example% size filename
         2724 + 88 + 0 = 2812



       Example 2 Producing allocatable section size information

         example% size -f filename
         26(.text) + 5(.init) + 5(.fini) = 36



       Example 3 Producing loadable segment size information

         example% size -F filename
         2724(r-x) + 88(rwx) + 0(rwx) = 2812 ... (If statically linked)



SEE ALSO
       as(1), ld(1), ar.h(3HEAD), a.out(4), attributes(5)

NOTES
       Since the size of bss sections is not known until link-edit time, the
       size command will not give the true total size of pre-linked objects.



                                August 24, 2009                        SIZE(1)

More information about the output of size can be found here

  • Thanks. According to the size of the whole application I assume the same for GNU, however I expected such an important information for such an application to be documented. Overall this is its main functionality. Thanks. – masec Mar 30 '18 at 19:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.