llvm-strip.rst 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. llvm-strip - object stripping tool
  2. ==================================
  3. .. program:: llvm-strip
  4. SYNOPSIS
  5. --------
  6. :program:`llvm-strip` [*options*] *inputs...*
  7. DESCRIPTION
  8. -----------
  9. :program:`llvm-strip` is a tool to strip sections and symbols from object files.
  10. If no other stripping or remove options are specified, :option:`--strip-all`
  11. will be enabled.
  12. By default, the input files are modified in-place. If "-" is specified for the
  13. input file, the input is read from the program's standard input stream.
  14. If the input is an archive, any requested operations will be applied to each
  15. archive member individually.
  16. The tool is still in active development, but in most scenarios it works as a
  17. drop-in replacement for GNU's :program:`strip`.
  18. GENERIC AND CROSS-PLATFORM OPTIONS
  19. ----------------------------------
  20. The following options are either agnostic of the file format, or apply to
  21. multiple file formats.
  22. .. option:: --disable-deterministic-archives, -U
  23. Use real values for UIDs, GIDs and timestamps when updating archive member
  24. headers.
  25. .. option:: --discard-all, -x
  26. Remove most local symbols from the output. Different file formats may limit
  27. this to a subset of the local symbols. For example, file and section symbols in
  28. ELF objects will not be discarded.
  29. .. option:: --enable-deterministic-archives, -D
  30. Enable deterministic mode when stripping archives, i.e. use 0 for archive member
  31. header UIDs, GIDs and timestamp fields. On by default.
  32. .. option:: --help, -h
  33. Print a summary of command line options.
  34. .. option:: --no-strip-all
  35. Disable --strip-all.
  36. .. option:: -o <file>
  37. Write output to <file>. Multiple input files cannot be used in combination
  38. with -o.
  39. .. option:: --regex
  40. If specified, symbol and section names specified by other switches are treated
  41. as extended POSIX regular expression patterns.
  42. .. option:: --remove-section <section>, -R
  43. Remove the specified section from the output. Can be specified multiple times
  44. to remove multiple sections simultaneously.
  45. .. option:: --strip-all-gnu
  46. Remove all symbols, debug sections and relocations from the output. This option
  47. is equivalent to GNU :program:`strip`'s ``--strip-all`` switch.
  48. .. option:: --strip-all, -S
  49. For ELF objects, remove from the output all symbols and non-alloc sections not
  50. within segments, except for .gnu.warning sections and the section name table.
  51. For COFF objects, remove all symbols, debug sections, and relocations from the
  52. output.
  53. .. option:: --strip-debug, -g
  54. Remove all debug sections.
  55. .. option:: --strip-sections
  56. Remove all section headers and all sections not in segments.
  57. .. option:: --strip-symbol <symbol>, -N
  58. Remove all symbols named ``<symbol>`` from the output. Can be specified
  59. multiple times to remove multiple symbols.
  60. .. option:: --strip-unneeded
  61. Remove from the output all local or undefined symbols that are not required by
  62. relocations. Also remove all debug sections.
  63. .. option:: --version, -V
  64. Display the version of the :program:`llvm-strip` executable.
  65. .. option:: @<FILE>
  66. Read command-line options and commands from response file `<FILE>`.
  67. COFF-SPECIFIC OPTIONS
  68. ---------------------
  69. The following options are implemented only for COFF objects. If used with other
  70. objects, :program:`llvm-strip` will either emit an error or silently ignore
  71. them.
  72. .. option:: --only-keep-debug
  73. Remove the contents of non-debug sections from the output, but keep the section
  74. headers.
  75. ELF-SPECIFIC OPTIONS
  76. --------------------
  77. The following options are implemented only for ELF objects. If used with other
  78. objects, :program:`llvm-strip` will either emit an error or silently ignore
  79. them.
  80. .. option:: --allow-broken-links
  81. Allow :program:`llvm-strip` to remove sections even if it would leave invalid
  82. section references. Any invalid sh_link fields will be set to zero.
  83. .. option:: --discard-locals, -X
  84. Remove local symbols starting with ".L" from the output.
  85. .. option:: --keep-file-symbols
  86. Keep symbols of type `STT_FILE`, even if they would otherwise be stripped.
  87. .. option:: --keep-section <section>
  88. When removing sections from the output, do not remove sections named
  89. ``<section>``. Can be specified multiple times to keep multiple sections.
  90. .. option:: --keep-symbol <symbol>, -K
  91. Do not remove symbols named ``<symbol>``. Can be specified multiple times to
  92. keep multiple symbols.
  93. .. option:: --preserve-dates, -p
  94. Preserve access and modification timestamps.
  95. EXIT STATUS
  96. -----------
  97. :program:`llvm-strip` exits with a non-zero exit code if there is an error.
  98. Otherwise, it exits with code 0.
  99. BUGS
  100. ----
  101. To report bugs, please visit <http://llvm.org/bugs/>.
  102. SEE ALSO
  103. --------
  104. :manpage:`llvm-objcopy(1)`