Go to main content

man pages section 1: User Commands

Exit Print View

Updated: Wednesday, July 27, 2022

llvm-size (1)


llvm-size - print size information


llvm-size [options] [input...]


LLVM-SIZE(1)                         LLVM                         LLVM-SIZE(1)

       llvm-size - print size information

       llvm-size [options] [input...]

       llvm-size  is a tool that prints size information for binary files.  It
       is intended to be a drop-in replacement for GNU's size.

       The tool prints size information for each input specified. If no  input
       is  specified, the program prints size information for a.out. If "-" is
       specified as an input file, llvm-size reads a file  from  the  standard
       input  stream. If an input is an archive, size information will be dis-
       played for all its members.

       -A     Equivalent to --format with a value of sysv.

              Architecture(s) from Mach-O universal binaries to display infor-
              mation for.

       -B     Equivalent to --format with a value of berkeley.

              Include  ELF common symbol sizes in bss size for berkeley output
              format, or as a separate section entry for sysv output.  If  not
              specified, these symbols are ignored.

       -d     Equivalent to --radix with a value of 10.

       -l     Display  verbose address and offset information for segments and
              sections in Mach-O files in darwin format.

              Set the output format to the <format> specified. Available <for-
              mat> options are berkeley (the default), sysv and darwin.

              Berkeley  output  summarises  text,  data  and bss sizes in each
              file, as shown below for a typical pair of ELF files:

                 $ llvm-size --format=berkeley test.o test2.o
                    text    data     bss     dec     hex filename
                     182      16       5     203      cb test.elf
                      82       8       1      91      5b test2.o

              For Mach-O files, the output format is slightly different:

                 $ llvm-size --format=berkeley macho.obj macho2.obj
                 __TEXT  __DATA  __OBJC  others  dec     hex
                 4       8       0       0       12      c       macho.obj
                 16      32      0       0       48      30      macho2.obj

              Sysv output displays size and address information for most  sec-
              tions, with each file being listed separately:

                 $ llvm-size --format=sysv test.elf test2.o
                    test.elf  :
                    section       size      addr
                    .eh_frame       92   2097496
                    .text           90   2101248
                    .data           16   2105344
                    .bss             5   2105360
                    .comment       209         0
                    Total          412

                    test2.o  :
                    section             size   addr
                    .text                 26      0
                    .data                  8      0
                    .bss                   1      0
                    .comment             106      0
                    .note.GNU-stack        0      0
                    .eh_frame             56      0
                    .llvm_addrsig          2      0
                    Total                199

              darwin  format only affects Mach-O input files. If an input of a
              different file format is  specified,  llvm-size  falls  back  to
              berkeley format. When producing darwin format, the tool displays
              information about segments and sections:

                 $ llvm-size --format=darwin macho.obj macho2.obj
                    Segment : 12
                            Section (__TEXT, __text): 4
                            Section (__DATA, __data): 8
                            total 12
                    total 12
                    Segment : 48
                            Section (__TEXT, __text): 16
                            Section (__DATA, __data): 32
                            total 48
                    total 48

       --help, -h
              Display a summary of command line options.

              Display an uncategorized summary of command line options.

       -m     Equivalent to --format with a value of darwin.

       -o     Equivalent to --radix with a value of 8.

              Display size information in the specified radix. Permitted  val-
              ues  are 8, 10 (the default) and 16 for octal, decimal and hexa-
              decimal output respectively.


                 $ llvm-size --radix=8 test.o
                    text    data     bss     oct     hex filename
                    0152      04      04     162      72 test.o

                 $ llvm-size --radix=10 test.o
                    text    data     bss     dec     hex filename
                     106       4       4     114      72 test.o

                 $ llvm-size --radix=16 test.o
                    text    data     bss     dec     hex filename
                    0x6a     0x4     0x4     114      72 test.o

       --totals, -t
              Applies only to berkeley output format. Display the  totals  for
              all listed fields, in addition to the individual file listings.


                 $ llvm-size --totals test.elf test2.o
                    text    data     bss     dec     hex filename
                     182      16       5     203      cb test.elf
                      82       8       1      91      5b test2.o
                     264      24       6     294     126 (TOTALS)

              Display the version of the llvm-size executable.

       -x     Equivalent to --radix with a value of 16.

              Read command-line options from response file <FILE>.

       llvm-size exits with a non-zero exit code if there is an error.  Other-
       wise, it exits with code 0.

       To report bugs, please visit <https://bugs.llvm.org/>.

       Maintained by the LLVM Team (https://llvm.org/).

       2003-2022, LLVM Project

       See attributes(7) for descriptions of the following attributes:

       |Availability   | developer/llvm/llvm |
       |Stability      | Uncommitted         |

       Source code for open source software components in Oracle  Solaris  can
       be found at https://www.oracle.com/downloads/opensource/solaris-source-

       This    software    was    built    from    source     available     at
       https://github.com/oracle/solaris-userland.    The  original  community
       source    was    downloaded     from      https://github.com/llvm/llvm-

       Further information about this software can be found on the open source
       community website at https://llvm.org/.

11                                2022-06-28                      LLVM-SIZE(1)