llvm-size.rst 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. llvm-size - print size information
  2. ==================================
  3. .. program:: llvm-size
  4. SYNOPSIS
  5. --------
  6. :program:`llvm-size` [*options*] [*input...*]
  7. DESCRIPTION
  8. -----------
  9. :program:`llvm-size` is a tool that prints size information for binary files.
  10. It is intended to be a drop-in replacement for GNU's :program:`size`.
  11. The tool prints size information for each ``input`` specified. If no input is
  12. specified, the program prints size information for ``a.out``. If "``-``" is
  13. specified as an input file, :program:`llvm-size` reads a file from the standard
  14. input stream. If an input is an archive, size information will be displayed for
  15. all its members.
  16. OPTIONS
  17. -------
  18. .. option:: -A
  19. Equivalent to :option:`--format` with a value of ``sysv``.
  20. .. option:: --arch=<arch>
  21. Architecture(s) from Mach-O universal binaries to display information for.
  22. .. option:: -B
  23. Equivalent to :option:`--format` with a value of ``berkeley``.
  24. .. option:: --common
  25. Include ELF common symbol sizes in bss size for ``berkeley`` output format, or
  26. as a separate section entry for ``sysv`` output. If not specified, these
  27. symbols are ignored.
  28. .. option:: -d
  29. Equivalent to :option:`--radix` with a value of ``10``.
  30. .. option:: -l
  31. Display verbose address and offset information for segments and sections in
  32. Mach-O files in ``darwin`` format.
  33. .. option:: --format=<format>
  34. Set the output format to the ``<format>`` specified. Available ``<format>``
  35. options are ``berkeley`` (the default), ``sysv`` and ``darwin``.
  36. Berkeley output summarises text, data and bss sizes in each file, as shown
  37. below for a typical pair of ELF files:
  38. .. code-block:: console
  39. $ llvm-size --format=berkeley test.o test2.o
  40. text data bss dec hex filename
  41. 182 16 5 203 cb test.elf
  42. 82 8 1 91 5b test2.o
  43. For Mach-O files, the output format is slightly different:
  44. .. code-block:: console
  45. $ llvm-size --format=berkeley macho.obj macho2.obj
  46. __TEXT __DATA __OBJC others dec hex
  47. 4 8 0 0 12 c macho.obj
  48. 16 32 0 0 48 30 macho2.obj
  49. Sysv output displays size and address information for most sections, with each
  50. file being listed separately:
  51. .. code-block:: console
  52. $ llvm-size --format=sysv test.elf test2.o
  53. test.elf :
  54. section size addr
  55. .eh_frame 92 2097496
  56. .text 90 2101248
  57. .data 16 2105344
  58. .bss 5 2105360
  59. .comment 209 0
  60. Total 412
  61. test2.o :
  62. section size addr
  63. .text 26 0
  64. .data 8 0
  65. .bss 1 0
  66. .comment 106 0
  67. .note.GNU-stack 0 0
  68. .eh_frame 56 0
  69. .llvm_addrsig 2 0
  70. Total 199
  71. ``darwin`` format only affects Mach-O input files. If an input of a different
  72. file format is specified, :program:`llvm-size` falls back to ``berkeley``
  73. format. When producing ``darwin`` format, the tool displays information about
  74. segments and sections:
  75. .. code-block:: console
  76. $ llvm-size --format=darwin macho.obj macho2.obj
  77. macho.obj:
  78. Segment : 12
  79. Section (__TEXT, __text): 4
  80. Section (__DATA, __data): 8
  81. total 12
  82. total 12
  83. macho2.obj:
  84. Segment : 48
  85. Section (__TEXT, __text): 16
  86. Section (__DATA, __data): 32
  87. total 48
  88. total 48
  89. .. option:: --help, -h
  90. Display a summary of command line options.
  91. .. option:: --help-list
  92. Display an uncategorized summary of command line options.
  93. .. option:: -m
  94. Equivalent to :option:`--format` with a value of ``darwin``.
  95. .. option:: -o
  96. Equivalent to :option:`--radix` with a value of ``8``.
  97. .. option:: --radix=<value>
  98. Display size information in the specified radix. Permitted values are ``8``,
  99. ``10`` (the default) and ``16`` for octal, decimal and hexadecimal output
  100. respectively.
  101. Example:
  102. .. code-block:: console
  103. $ llvm-size --radix=8 test.o
  104. text data bss oct hex filename
  105. 0152 04 04 162 72 test.o
  106. $ llvm-size --radix=10 test.o
  107. text data bss dec hex filename
  108. 106 4 4 114 72 test.o
  109. $ llvm-size --radix=16 test.o
  110. text data bss dec hex filename
  111. 0x6a 0x4 0x4 114 72 test.o
  112. .. option:: --totals, -t
  113. Applies only to ``berkeley`` output format. Display the totals for all listed
  114. fields, in addition to the individual file listings.
  115. Example:
  116. .. code-block:: console
  117. $ llvm-size --totals test.elf test2.o
  118. text data bss dec hex filename
  119. 182 16 5 203 cb test.elf
  120. 82 8 1 91 5b test2.o
  121. 264 24 6 294 126 (TOTALS)
  122. .. option:: --version
  123. Display the version of the :program:`llvm-size` executable.
  124. .. option:: -x
  125. Equivalent to :option:`--radix` with a value of ``16``.
  126. .. option:: @<FILE>
  127. Read command-line options from response file ``<FILE>``.
  128. EXIT STATUS
  129. -----------
  130. :program:`llvm-size` exits with a non-zero exit code if there is an error.
  131. Otherwise, it exits with code 0.
  132. BUGS
  133. ----
  134. To report bugs, please visit <http://llvm.org/bugs/>.