14fe911d9SMichael Pozulpllvm-strip - object stripping tool 24fe911d9SMichael Pozulp================================== 34fe911d9SMichael Pozulp 44fe911d9SMichael Pozulp.. program:: llvm-strip 54fe911d9SMichael Pozulp 64fe911d9SMichael PozulpSYNOPSIS 74fe911d9SMichael Pozulp-------- 84fe911d9SMichael Pozulp 94fe911d9SMichael Pozulp:program:`llvm-strip` [*options*] *inputs...* 104fe911d9SMichael Pozulp 114fe911d9SMichael PozulpDESCRIPTION 124fe911d9SMichael Pozulp----------- 134fe911d9SMichael Pozulp 144fe911d9SMichael Pozulp:program:`llvm-strip` is a tool to strip sections and symbols from object files. 154fe911d9SMichael PozulpIf no other stripping or remove options are specified, :option:`--strip-all` 161b103864SJames Hendersonwill be enabled. 174fe911d9SMichael Pozulp 181b103864SJames HendersonBy default, the input files are modified in-place. If "-" is specified for the 191b103864SJames Hendersoninput file, the input is read from the program's standard input stream. 204fe911d9SMichael Pozulp 214fe911d9SMichael PozulpIf the input is an archive, any requested operations will be applied to each 224fe911d9SMichael Pozulparchive member individually. 234fe911d9SMichael Pozulp 244fe911d9SMichael PozulpThe tool is still in active development, but in most scenarios it works as a 254fe911d9SMichael Pozulpdrop-in replacement for GNU's :program:`strip`. 264fe911d9SMichael Pozulp 274fe911d9SMichael PozulpGENERIC AND CROSS-PLATFORM OPTIONS 284fe911d9SMichael Pozulp---------------------------------- 294fe911d9SMichael Pozulp 304fe911d9SMichael PozulpThe following options are either agnostic of the file format, or apply to 314fe911d9SMichael Pozulpmultiple file formats. 324fe911d9SMichael Pozulp 334fe911d9SMichael Pozulp.. option:: --disable-deterministic-archives, -U 344fe911d9SMichael Pozulp 354fe911d9SMichael Pozulp Use real values for UIDs, GIDs and timestamps when updating archive member 364fe911d9SMichael Pozulp headers. 374fe911d9SMichael Pozulp 384fe911d9SMichael Pozulp.. option:: --discard-all, -x 394fe911d9SMichael Pozulp 404fe911d9SMichael Pozulp Remove most local symbols from the output. Different file formats may limit 414fe911d9SMichael Pozulp this to a subset of the local symbols. For example, file and section symbols in 42f2e85c31SJames Henderson ELF objects will not be discarded. Additionally, remove all debug sections. 434fe911d9SMichael Pozulp 444fe911d9SMichael Pozulp.. option:: --enable-deterministic-archives, -D 454fe911d9SMichael Pozulp 464fe911d9SMichael Pozulp Enable deterministic mode when stripping archives, i.e. use 0 for archive member 474fe911d9SMichael Pozulp header UIDs, GIDs and timestamp fields. On by default. 484fe911d9SMichael Pozulp 494fe911d9SMichael Pozulp.. option:: --help, -h 504fe911d9SMichael Pozulp 514fe911d9SMichael Pozulp Print a summary of command line options. 524fe911d9SMichael Pozulp 534fe911d9SMichael Pozulp.. option:: --no-strip-all 544fe911d9SMichael Pozulp 554dd9b2faSJames Henderson Disable :option:`--strip-all`. 564fe911d9SMichael Pozulp 574fe911d9SMichael Pozulp.. option:: -o <file> 584fe911d9SMichael Pozulp 594fe911d9SMichael Pozulp Write output to <file>. Multiple input files cannot be used in combination 604fe911d9SMichael Pozulp with -o. 614fe911d9SMichael Pozulp 62*c975668fSJames Henderson.. option:: --only-keep-debug 63*c975668fSJames Henderson 64*c975668fSJames Henderson Produce a debug file as the output that only preserves contents of sections 65*c975668fSJames Henderson useful for debugging purposes. 66*c975668fSJames Henderson 67*c975668fSJames Henderson For ELF objects, this removes the contents of `SHF_ALLOC` sections that are not 68*c975668fSJames Henderson `SHT_NOTE` by making them `SHT_NOBITS` and shrinking the program headers where 69*c975668fSJames Henderson possible. 70*c975668fSJames Henderson 714fe911d9SMichael Pozulp.. option:: --regex 724fe911d9SMichael Pozulp 734fe911d9SMichael Pozulp If specified, symbol and section names specified by other switches are treated 744fe911d9SMichael Pozulp as extended POSIX regular expression patterns. 754fe911d9SMichael Pozulp 764fe911d9SMichael Pozulp.. option:: --remove-section <section>, -R 774fe911d9SMichael Pozulp 784fe911d9SMichael Pozulp Remove the specified section from the output. Can be specified multiple times 794fe911d9SMichael Pozulp to remove multiple sections simultaneously. 804fe911d9SMichael Pozulp 814fe911d9SMichael Pozulp.. option:: --strip-all-gnu 824fe911d9SMichael Pozulp 834fe911d9SMichael Pozulp Remove all symbols, debug sections and relocations from the output. This option 844fe911d9SMichael Pozulp is equivalent to GNU :program:`strip`'s ``--strip-all`` switch. 854fe911d9SMichael Pozulp 86d8678246SAlexander Shaposhnikov.. option:: --strip-all, -s 874fe911d9SMichael Pozulp 884fe911d9SMichael Pozulp For ELF objects, remove from the output all symbols and non-alloc sections not 89fb4a5501SJames Henderson within segments, except for .gnu.warning, .ARM.attribute sections and the 90fb4a5501SJames Henderson section name table. 914fe911d9SMichael Pozulp 924fe911d9SMichael Pozulp For COFF objects, remove all symbols, debug sections, and relocations from the 934fe911d9SMichael Pozulp output. 944fe911d9SMichael Pozulp 95d8678246SAlexander Shaposhnikov.. option:: --strip-debug, -d, -g, -S 964fe911d9SMichael Pozulp 974dd9b2faSJames Henderson Remove all debug sections from the output. 984fe911d9SMichael Pozulp 994fe911d9SMichael Pozulp.. option:: --strip-symbol <symbol>, -N 1004fe911d9SMichael Pozulp 1014fe911d9SMichael Pozulp Remove all symbols named ``<symbol>`` from the output. Can be specified 1024fe911d9SMichael Pozulp multiple times to remove multiple symbols. 1034fe911d9SMichael Pozulp 1044fe911d9SMichael Pozulp.. option:: --strip-unneeded 1054fe911d9SMichael Pozulp 106818e5c95SJames Henderson Remove from the output all local or undefined symbols that are not required by 107818e5c95SJames Henderson relocations. Also remove all debug sections. 1084fe911d9SMichael Pozulp 1094fe911d9SMichael Pozulp.. option:: --version, -V 1104fe911d9SMichael Pozulp 111778a5e57SJames Henderson Display the version of the :program:`llvm-strip` executable. 1124fe911d9SMichael Pozulp 113edeebad7SJordan Rupprecht.. option:: --wildcard, -w 114edeebad7SJordan Rupprecht 115edeebad7SJordan Rupprecht Allow wildcard syntax for symbol-related flags. On by default for 116edeebad7SJordan Rupprecht section-related flags. Incompatible with --regex. 117edeebad7SJordan Rupprecht 118edeebad7SJordan Rupprecht Wildcard syntax allows the following special symbols: 119edeebad7SJordan Rupprecht 120edeebad7SJordan Rupprecht ====================== ========================= ================== 121edeebad7SJordan Rupprecht Character Meaning Equivalent 122edeebad7SJordan Rupprecht ====================== ========================= ================== 123edeebad7SJordan Rupprecht ``*`` Any number of characters ``.*`` 124edeebad7SJordan Rupprecht ``?`` Any single character ``.`` 125edeebad7SJordan Rupprecht ``\`` Escape the next character ``\`` 126edeebad7SJordan Rupprecht ``[a-z]`` Character class ``[a-z]`` 127edeebad7SJordan Rupprecht ``[!a-z]``, ``[^a-z]`` Negated character class ``[^a-z]`` 128edeebad7SJordan Rupprecht ====================== ========================= ================== 129edeebad7SJordan Rupprecht 130edeebad7SJordan Rupprecht Additionally, starting a wildcard with '!' will prevent a match, even if 131edeebad7SJordan Rupprecht another flag matches. For example ``-w -N '*' -N '!x'`` will strip all symbols 132edeebad7SJordan Rupprecht except for ``x``. 133edeebad7SJordan Rupprecht 134edeebad7SJordan Rupprecht The order of wildcards does not matter. For example, ``-w -N '*' -N '!x'`` is 135edeebad7SJordan Rupprecht the same as ``-w -N '!x' -N '*'``. 136edeebad7SJordan Rupprecht 137974bce3eSJames Henderson.. option:: @<FILE> 138974bce3eSJames Henderson 139974bce3eSJames Henderson Read command-line options and commands from response file `<FILE>`. 140974bce3eSJames Henderson 1414fe911d9SMichael PozulpELF-SPECIFIC OPTIONS 1424fe911d9SMichael Pozulp-------------------- 1434fe911d9SMichael Pozulp 1444fe911d9SMichael PozulpThe following options are implemented only for ELF objects. If used with other 1454fe911d9SMichael Pozulpobjects, :program:`llvm-strip` will either emit an error or silently ignore 1464fe911d9SMichael Pozulpthem. 1474fe911d9SMichael Pozulp 1484fe911d9SMichael Pozulp.. option:: --allow-broken-links 1494fe911d9SMichael Pozulp 1501b103864SJames Henderson Allow :program:`llvm-strip` to remove sections even if it would leave invalid 1511b103864SJames Henderson section references. Any invalid sh_link fields will be set to zero. 1524fe911d9SMichael Pozulp 1534fe911d9SMichael Pozulp.. option:: --discard-locals, -X 1544fe911d9SMichael Pozulp 1554fe911d9SMichael Pozulp Remove local symbols starting with ".L" from the output. 1564fe911d9SMichael Pozulp 1574fe911d9SMichael Pozulp.. option:: --keep-file-symbols 1584fe911d9SMichael Pozulp 1594fe911d9SMichael Pozulp Keep symbols of type `STT_FILE`, even if they would otherwise be stripped. 1604fe911d9SMichael Pozulp 1614fe911d9SMichael Pozulp.. option:: --keep-section <section> 1624fe911d9SMichael Pozulp 1634fe911d9SMichael Pozulp When removing sections from the output, do not remove sections named 1644fe911d9SMichael Pozulp ``<section>``. Can be specified multiple times to keep multiple sections. 1654fe911d9SMichael Pozulp 1664fe911d9SMichael Pozulp.. option:: --keep-symbol <symbol>, -K 1674fe911d9SMichael Pozulp 1684dd9b2faSJames Henderson When removing symbols from the output, do not remove symbols named 1694dd9b2faSJames Henderson ``<symbol>``. Can be specified multiple times to keep multiple symbols. 1704fe911d9SMichael Pozulp 1714fe911d9SMichael Pozulp.. option:: --preserve-dates, -p 1724fe911d9SMichael Pozulp 1734dd9b2faSJames Henderson Preserve access and modification timestamps in the output. 1744dd9b2faSJames Henderson 1754dd9b2faSJames Henderson.. option:: --strip-sections 1764dd9b2faSJames Henderson 1774dd9b2faSJames Henderson Remove from the output all section headers and all section data not within 1784dd9b2faSJames Henderson segments. Note that many tools will not be able to use an object without 1794dd9b2faSJames Henderson section headers. 1804fe911d9SMichael Pozulp 181842a8cc1SAlexander Shaposhnikov.. option:: -T 182842a8cc1SAlexander Shaposhnikov 183842a8cc1SAlexander Shaposhnikov Remove Swift symbols. 184842a8cc1SAlexander Shaposhnikov 1854fe911d9SMichael PozulpEXIT STATUS 1864fe911d9SMichael Pozulp----------- 1874fe911d9SMichael Pozulp 1884fe911d9SMichael Pozulp:program:`llvm-strip` exits with a non-zero exit code if there is an error. 1894fe911d9SMichael PozulpOtherwise, it exits with code 0. 1904fe911d9SMichael Pozulp 1914fe911d9SMichael PozulpBUGS 1924fe911d9SMichael Pozulp---- 1934fe911d9SMichael Pozulp 194bbce75e3SChuanqi XuTo report bugs, please visit <https://github.com/llvm/llvm-project/labels/tools:llvm-objcopy%2Fstrip>. 1954fe911d9SMichael Pozulp 1964fe911d9SMichael PozulpSEE ALSO 1974fe911d9SMichael Pozulp-------- 1984fe911d9SMichael Pozulp 1994fe911d9SMichael Pozulp:manpage:`llvm-objcopy(1)` 200