* objcopy.c (struct section_list): Add fields remove, set_flags,
[binutils-gdb.git] / binutils / objcopy.1
1 .\" Copyright (c) 1991 Free Software Foundation
2 .\" See section COPYING for conditions for redistribution
3 .TH objcopy 1 "October 1994" "cygnus support" "GNU Development Tools"
4 .de BP
5 .sp
6 .ti \-.2i
7 \(**
8 ..
9
10 .SH NAME
11 objcopy \- copy and translate object files
12
13 .SH SYNOPSIS
14 .hy 0
15 .na
16 .TP
17 .B objcopy
18 .RB "[\|" \-F\ \fIbfdname\fB\ |\ \-\-target=\fIbfdname\fR "\|]"
19 .RB "[\|" \-I\ \fIbfdname\fB\ |\ \-\-input\-target=\fIbfdname\fR "\|]"
20 .RB "[\|" \-O\ \fIbfdname\fB\ |\ \-\-output\-target=\fIbfdname\fR "\|]"
21 .RB "[\|" \-R\ \fIsectionname\fB\ |\ \-\-remove\-section=\fIsectionname\fR "\|]"
22 .RB "[\|" \-S\ |\ \-\-strip\-all\fR "\|]"
23 .RB "[\|" \-g\ |\ \-\-strip\-debug\fR "\|]"
24 .RB "[\|" \-N\ \fIsymbolname\fR\ |\ \-\-strip\-symbol=\fIsymbolname\fR "\|]"
25 .RB "[\|" \-x\ |\ \-\-discard\-all\fR "\|]"
26 .RB "[\|" \-X\ |\ \-\-discard\-locals\fR "\|]"
27 .RB "[\|" \-b\ \fIbyte\fR\ |\ \fB\-\-byte=\fIbyte\fR "\|]"
28 .RB "[\|" \-i\ \fIinterleave\fR\ |\ \fB\-\-interleave=\fIinterleave\fR "\|]"
29 .RB "[\|" \-\-gap\-fill=\fIval\fR "\|]"
30 .RB "[\|" \-\-pad\-to=\fIaddress\fR "\|]"
31 .RB "[\|" \-\-set\-start=\fIval\fR "\|]"
32 .RB "[\|" \-\-adjust\-start=\fIincr\fR "\|]"
33 .RB "[\|" \-\-adjust\-vma=\fIincr\fR "\|]"
34 .RB "[\|" \-\-adjust\-section\-vma=\fIsection{=,+,-}val\fR "\|]"
35 .RB "[\|" \-\-adjust\-warnings\fR "\|]"
36 .RB "[\|" \-\-no\-adjust\-warnings\fR "\|]"
37 .RB "[\|" \-\-set\-section\-flags=\fIsection=flags\fR "\|]"
38 .RB "[\|" \-\-add\-section=\fIsectionname=filename\fR "\|]"
39 .RB "[\|" \-v\ |\ \-\-verbose\fR "\|]"
40 .RB "[\|" \-V\ |\ \-\-version\fR "\|]"
41 .RB "[\|" \-\-help\fR "\|]"
42 .B infile
43 .RB "[\|" outfile\fR "\|]"
44 .SH DESCRIPTION
45 The GNU
46 .B objcopy
47 utility copies the contents of an object file to another.
48 .B objcopy
49 uses the GNU BFD Library to read and write the object files. It can
50 write the destination object file in a format different from that of
51 the source object file. The exact behavior of
52 .B objcopy
53 is controlled by command-line options.
54 .PP
55 .B objcopy
56 creates temporary files to do its translations and deletes them
57 afterward.
58 .B objcopy
59 uses BFD to do all its translation work; it knows about all the
60 formats BFD knows about, and thus is able to recognize most formats
61 without being told explicitly.
62 .PP
63 .B objcopy
64 can be used to generate S-records by using an output target of
65 .B srec
66 (e.g., use
67 .B -O srec).
68 .PP
69 .B objcopy
70 can be used to generate a raw binary file by using an output target of
71 .B binary
72 (e.g., use
73 .B -O binary).
74 When
75 .B objcopy
76 generates a raw binary file, it will essentially produce a memory dump
77 of the contents of the input object file. All symbols and relocation
78 information will be discarded. The memory dump will start at the
79 virtual address of the lowest section copied into the output file.
80 .PP
81 When generating an S-record or a raw binary file, it may be helpful to
82 use
83 .B -S
84 to remove sections containing debugging information. In some cases
85 .B -R
86 will be useful to remove sections which contain information which is
87 not needed by the binary file.
88 .PP
89 .I infile
90 and
91 .I outfile
92 are the source and output files respectively. If you do not specify
93 .IR outfile ,
94 .B objcopy
95 creates a temporary file and destructively renames the result with the
96 name of the input file.
97
98 .SH OPTIONS
99 .TP
100 .B \-I \fIbfdname\fR, \fB\-\-input\-target=\fIbfdname
101 Consider the source file's object format to be
102 .IR bfdname ,
103 rather than attempting to deduce it.
104 .TP
105 .B \-O \fIbfdname\fR, \fB\-\-output\-target=\fIbfdname
106 Write the output file using the object format
107 .IR bfdname .
108 .TP
109 .B \-F \fIbfdname\fR, \fB\-\-target=\fIbfdname
110 Use
111 .I bfdname
112 as the object format for both the input and the output file; i.e.
113 simply transfer data from source to destination with no translation.
114 .TP
115 .B \-R \fIsectionname\fR, \fB\-\-remove-section=\fIsectionname
116 Remove the named section from the file. This option may be given more
117 than once. Note that using this option inappropriately may make the
118 output file unusable.
119 .TP
120 .B \-S\fR, \fB\-\-strip\-all
121 Do not copy relocation and symbol information from the source file.
122 .TP
123 .B \-g\fR, \fB\-\-strip\-debug
124 Do not copy debugging symbols from the source file.
125 .TP
126 .B \-N \fIsymbolname\fR, \fB\-\-strip\-symbol=\fIsymbolname
127 Do not copy symbol \fIsymbolname\fP from the source file. This option
128 may be given more than once, and may be combined with other strip
129 options.
130 .TP
131 .B \-x\fR, \fB \-\-discard\-all
132 Do not copy non-global symbols from the source file.
133 .TP
134 .B \-X\fR, \fB\-\-discard\-locals
135 Do not copy compiler-generated local symbols. (These usually start
136 with "L" or ".").
137 .TP
138 .B \-b \fIbyte\fR, \fB\-\-byte=\fIbyte
139 Keep only every \fIbyte\fPth byte of the input file (header data is
140 not affected). \fIbyte\fP can be in the range from 0 to the
141 interleave-1. This option is useful for creating files to program
142 ROMs. It is typically used with an srec output target.
143 .TP
144 .B \-i \fIinterleave\fR, \fB\-\-interleave=\fIinterleave
145 Only copy one out of every \fIinterleave\fP bytes. Which one to copy is
146 selected by the \fB\-b\fP or \fB\-\-byte\fP option. The default is 4.
147 The interleave is ignored if neither \fB\-b\fP nor \fB\-\-byte\fP is given.
148 .TP
149 .B \-\-gap\-fill=\fIval
150 Fill gaps between sections with \fIval\fP. This is done by increasing
151 the size of the section with the lower address, and filling in the extra
152 space created with \fIval\fP.
153 .TP
154 .B \-\-pad\-to=\fIaddress
155 Pad the output file up to the virtual address \fIaddress\fP. This is
156 done by increasing the size of the last section. The extra space is
157 filled in with the value specified by \fB\-\-gap\-fill\fP (default
158 zero).
159 .TP
160 .B \fB\-\-set\-start=\fIval
161 Set the start address of the new file to \fIval\fP. Not all object
162 file formats support setting the start address.
163 .TP
164 .B \fB\-\-adjust\-start=\fIincr
165 Adjust the start address by adding \fIincr\fP. Not all object file
166 formats support setting the start address.
167 .TP
168 .B \fB\-\-adjust\-vma=\fIincr
169 Adjust the address of all sections, as well as the start address, by
170 adding \fIincr\fP. Some object file formats do not permit section
171 addresses to be changed arbitrarily. Note that this does not relocate
172 the sections; if the program expects sections to be loaded at a
173 certain address, and this option is used to change the sections such
174 that they are loaded at a different address, the program may fail.
175 .TP
176 .B \fB\-\-adjust\-section\-vma=\fIsection{=,+,-}val
177 Set or adjust the address of the named \fIsection\fP. If \fI=\fP is
178 used, the section address is set to \fIval\fP. Otherwise, \fIval\fP
179 is added to or subtracted from the section address. See the comments
180 under \fB\-\-adjust\-vma\fP, above. If \fIsection\fP does not exist
181 in the input file, a warning will be issued, unless
182 \fB\-\-no\-adjust\-warnings\fP is used.
183 .TP
184 .B \fB\-\-adjust\-warnings
185 If \fB\-\-adjust\-section\-vma\fP is used, and the named section does
186 not exist, issue a warning. This is the default.
187 .TP
188 .B \fB\-\-no\-adjust\-warnings
189 Do not issue a warning if \fB\-\-adjust\-section\-vma\fP is used, even
190 if the named section does not exist.
191 .TP
192 .B \fB\-\-set\-section\-flags=\fIsection=flags
193 Set the flags for the named section. The \fIflags\fP argument is a
194 comma separated string of flag names. The recognized names are
195 \fIalloc\fP, \fIload\fP, \fIreadonly\fP, \fIcode\fP, \fIdata\fP, and
196 \fIrom\fP. Not all flags are meaningful for all object file
197 formats.
198 .TP
199 .B \fB\-\-add\-section=\fIsectionname=filename
200 Add a new section named \fIsectionname\fR while copying the file. The
201 contents of the new section are taken from the file \fIfilename\fR.
202 The size of the section will be the size of the file. This option
203 only works on file formats which can support sections with arbitrary
204 names.
205 .TP
206 .B \-v\fR, \fB\-\-verbose
207 Verbose output: list all object files modified. In the case of
208 archives, "\fBobjcopy \-V\fR" lists all members of the archive.
209 .TP
210 .B \-V\fR, \fB\-\-version
211 Show the version number of
212 .B objcopy
213 and exit.
214 .TP
215 .B \-\-help
216 Show a summary of the options to
217 .B objcopy
218 and exit.
219 .SH "SEE ALSO"
220 .RB "`\|" binutils "\|'"
221 entry in
222 .B
223 info\c
224 \&;
225 .I
226 The GNU Binary Utilities\c
227 \&, Roland H. Pesch (June 1993).
228
229 .SH COPYING
230 Copyright (c) 1993,1994 Free Software Foundation, Inc.
231 .PP
232 Permission is granted to make and distribute verbatim copies of
233 this manual provided the copyright notice and this permission notice
234 are preserved on all copies.
235 .PP
236 Permission is granted to copy and distribute modified versions of this
237 manual under the conditions for verbatim copying, provided that the
238 entire resulting derived work is distributed under the terms of a
239 permission notice identical to this one.
240 .PP
241 Permission is granted to copy and distribute translations of this
242 manual into another language, under the above conditions for modified
243 versions, except that this permission notice may be included in
244 translations approved by the Free Software Foundation instead of in
245 the original English.