xref: /freebsd/contrib/elftoolchain/elfcopy/strip.1 (revision ad13e15e1d9d61a3383394f689ccd3a40bdb1d8e)
1.\" Copyright (c) 2011 Joseph Koshy.  All rights reserved.
2.\"
3.\" Redistribution and use in source and binary forms, with or without
4.\" modification, are permitted provided that the following conditions
5.\" are met:
6.\" 1. Redistributions of source code must retain the above copyright
7.\"    notice, this list of conditions and the following disclaimer.
8.\" 2. Redistributions in binary form must reproduce the above copyright
9.\"    notice, this list of conditions and the following disclaimer in the
10.\"    documentation and/or other materials provided with the distribution.
11.\"
12.\" THIS SOFTWARE IS PROVIDED BY JOSEPH KOSHY ``AS IS'' AND
13.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15.\" ARE DISCLAIMED.  IN NO EVENT SHALL JOSEPH KOSHY BE LIABLE
16.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
18.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
21.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
22.\" SUCH DAMAGE.
23.\"
24.\" $Id: strip.1 3642 2018-10-14 14:24:28Z jkoshy $
25.\"
26.Dd July 27, 2019
27.Dt STRIP 1
28.Os
29.Sh NAME
30.Nm strip
31.Nd discard information from ELF objects
32.Sh SYNOPSIS
33.Nm
34.Op Fl d | Fl g | Fl S | Fl -strip-debug
35.Op Fl h | Fl -help
36.Op Fl -only-keep-debug
37.Op Fl o Ar outputfile | Fl -output-file= Ns Ar outputfile
38.Op Fl p | Fl -preserve-dates
39.Op Fl s | Fl -strip-all
40.Op Fl -strip-unneeded
41.Op Fl w | Fl -wildcard
42.Op Fl x | Fl -discard-all
43.Op Fl I Ar format | Fl -input-target= Ns Ar format
44.Op Fl K Ar symbol | Fl -keep-symbol= Ns Ar symbol
45.Op Fl N Ar symbol | Fl -strip-symbol= Ns Ar symbol
46.Op Fl O Ar format | Fl -output-target= Ns Ar format
47.Op Fl R Ar sectionname | Fl -remove-section= Ns Ar sectionname
48.Op Fl V | Fl -version
49.Op Fl X | Fl -discard-locals
50.Ar
51.Sh DESCRIPTION
52The
53.Nm
54utility is used to discard information from the ELF objects
55specified by the arguments
56.Ar .
57.Pp
58If an explicit output file name is not specified using the
59.Fl o
60option, the
61.Nm
62utility will modify its input arguments in-place.
63.Pp
64The
65.Nm
66utility supports the following options:
67.Bl -tag -width indent
68.It Fl d | Fl g | Fl S | Fl -strip-debug
69Remove debugging symbols only.
70.It Fl h | Fl -help
71Print a help message and exit.
72.It Fl -only-keep-debug
73Remove all content except that which would be used for debugging.
74.It Fl o Ar outputfile | Fl -output-file= Ns Ar outputfile
75Write the stripped object to file
76.Ar outputfile
77instead of modifying the input in-place.
78Only a single input object should be specified if this option is used.
79.It Fl p | Fl -preserve-dates
80Preserve the object's access and modification times.
81.It Fl s | Fl -strip-all
82Remove all symbols.
83.It Fl -strip-unneeded
84Remove all symbols not needed for further relocation processing.
85.It Fl w | Fl -wildcard
86Use shell-style patterns to name symbols.
87The following meta-characters are recognized in patterns:
88.Bl -tag -width "...." -compact
89.It Li !
90If this is the first character of the pattern, invert the sense of the
91pattern match.
92.It Li *
93Matches any string of characters in a symbol name.
94.It Li ?
95Matches zero or one character in a symbol name.
96.It Li [
97Mark the start of a character class.
98.It Li \e
99Remove the special meaning of the next character in the pattern.
100.It Li ]
101Mark the end of a character class.
102.El
103.It Fl x | Fl -discard-all
104Discard all non-global symbols.
105.It Fl I Ar format | Fl -input-target= Ns Ar format
106These options are accepted, but are ignored.
107.It Fl K Ar symbol | Fl -keep-symbol= Ns Ar symbol
108Keep the symbol
109.Ar symbol
110even if it would otherwise be stripped.
111This option may be specified multiple times.
112.It Fl N Ar symbol | Fl -strip-symbol= Ns Ar symbol
113Remove the symbol
114.Ar symbol
115even if it would otherwise have been kept.
116This option may be specified multiple times.
117.It Fl O Ar format | Fl -output-target= Ns Ar format
118Set the output file format to
119.Ar format .
120For the full list of supported formats, please see the documentation
121for function
122.Xr elftc_bfd_find_target 3 .
123.It Fl R Ar sectionname | Fl -remove-section= Ns Ar sectionname
124Remove the section named by the argument
125.Ar sectionname .
126This option may be specified multiple times.
127.It Fl V | Fl -version
128Print a version identifier and exit.
129.It Fl X | Fl -discard-locals
130Remove compiler-generated local symbols.
131.El
132.Sh DIAGNOSTICS
133.Ex -std
134.Sh SEE ALSO
135.Xr ar 1 ,
136.Xr elfcopy 1 ,
137.Xr ld 1 ,
138.Xr mcs 1 ,
139.Xr elf 3 ,
140.Xr elftc_bfd_find_target 3 ,
141.Xr fnmatch 3
142