10127c4346b3731497e28556a726240d8fc0f1cc
[deliverable/binutils-gdb.git] / binutils / objcopy.1
1 .\" Copyright (c) 1991, 93, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation
2 .\" See section COPYING for conditions for redistribution
3 .TH objcopy 1 "05 April 2000" "Cygnus Solutions" "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\fR\ |\ \fB\-\-target=\fIbfdname\fR "\|]"
19 .RB "[\|" \-I\ \fIbfdname\fR\ |\ \fB\-\-input\-target=\fIbfdname\fR "\|]"
20 .RB "[\|" \-O\ \fIbfdname\fR\ |\ \fB\-\-output\-target=\fIbfdname\fR "\|]"
21 .RB "[\|" \-j\ \fIsectionname\fR\ |\ \fB\-\-only\-section=\fIsectionname\fR "\|]"
22 .RB "[\|" \-R\ \fIsectionname\fR\ |\ \fB\-\-remove\-section=\fIsectionname\fR "\|]"
23 .RB "[\|" \-S\fR\ |\ \fB\-\-strip\-all\fR "\|]"
24 .RB "[\|" \-g\fR\ |\ \fB\-\-strip\-debug\fR "\|]"
25 .RB "[\|" \-\-strip\-unneeded\fR "\|]"
26 .RB "[\|" \-K\ \fIsymbolname\fR\ |\ \fB\-\-keep\-symbol=\fIsymbolname\fR "\|]"
27 .RB "[\|" \-N\ \fIsymbolname\fR\ |\ \fB\-\-strip\-symbol=\fIsymbolname\fR "\|]"
28 .RB "[\|" \-L\ \fIsymbolname\fR\ |\ \fB\-\-localize\-symbol=\fIsymbolname\fR "\|]"
29 .RB "[\|" \-W\ \fIsymbolname\fR\ |\ \fB\-\-weaken\-symbol=\fIsymbolname\fR "\|]"
30 .RB "[\|" \-x\fR\ |\ \fB\-\-discard\-all\fR "\|]"
31 .RB "[\|" \-X\fR\ |\ \fB\-\-discard\-locals\fR "\|]"
32 .RB "[\|" \-b\ \fIbyte\fR\ |\ \fB\-\-byte=\fIbyte\fR "\|]"
33 .RB "[\|" \-i\ \fIinterleave\fR\ |\ \fB\-\-interleave=\fIinterleave\fR "\|]"
34 .RB "[\|" \-p\fR\ |\ \fB\-\-preserve\-dates\fR "\|]"
35 .RB "[\|" \-\-debugging "\|]"
36 .RB "[\|" \-\-gap\-fill=\fIval\fR "\|]"
37 .RB "[\|" \-\-pad\-to=\fIaddress\fR "\|]"
38 .RB "[\|" \-\-set\-start=\fIval\fR "\|]"
39 .RB "[\|" \-\-change\-start=\fIincr\fR "\|]"
40 .RB "[\|" \-\-change\-addresses=\fIincr\fR "\|]"
41 .RB "[\|" \-\-change\-section\-address\ \fIsection{=,+,-}val\fR "\|]"
42 .RB "[\|" \-\-change\-section\-lma\ \fIsection{=,+,-}val\fR "\|]"
43 .RB "[\|" \-\-change\-section\-vma\ \fIsection{=,+,-}val\fR "\|]"
44 .RB "[\|" \-\-change\-warnings\fR "\|]"
45 .RB "[\|" \-\-no\-change\-warnings\fR "\|]"
46 .RB "[\|" \-\-set\-section\-flags\ \fIsection=flags\fR "\|]"
47 .RB "[\|" \-\-add\-section\ \fIsectionname=filename\fR "\|]"
48 .RB "[\|" \-\-change\-leading\-char\fR "\|]"
49 .RB "[\|" \-\-remove\-leading\-char\fR "\|]"
50 .RB "[\|" \-\-srec\-len=\fIval\fR "\|]"
51 .RB "[\|" \-\-srec\-forceS3\fR "\|]"
52 .RB "[\|" \-\-redefine\-sym\ \fIold=new\fR "\|]"
53 .RB "[\|" \-\-weaken\fR "\|]"
54 .RB "[\|" \-v\ |\ \-\-verbose\fR "\|]"
55 .RB "[\|" \-V\ |\ \-\-version\fR "\|]"
56 .RB "[\|" \-\-help\fR "\|]"
57 .B infile
58 .RB "[\|" outfile\fR "\|]"
59 .SH DESCRIPTION
60 The GNU
61 .B objcopy
62 utility copies the contents of an object file to another.
63 .B objcopy
64 uses the GNU BFD Library to read and write the object files. It can
65 write the destination object file in a format different from that of
66 the source object file. The exact behavior of
67 .B objcopy
68 is controlled by command-line options.
69 .PP
70 .B objcopy
71 creates temporary files to do its translations and deletes them
72 afterward.
73 .B objcopy
74 uses BFD to do all its translation work; it knows about all the
75 formats BFD knows about, and thus is able to recognize most formats
76 without being told explicitly.
77 .PP
78 .B objcopy
79 can be used to generate S-records by using an output target of
80 .B srec
81 (e.g., use
82 .B -O srec).
83 .PP
84 .B objcopy
85 can be used to generate a raw binary file by using an output target of
86 .B binary
87 (e.g., use
88 .B -O binary).
89 When
90 .B objcopy
91 generates a raw binary file, it will essentially produce a memory dump
92 of the contents of the input object file. All symbols and relocation
93 information will be discarded. The memory dump will start at the
94 virtual address of the lowest section copied into the output file.
95 .PP
96 When generating an S-record or a raw binary file, it may be helpful to
97 use
98 .B -S
99 to remove sections containing debugging information. In some cases
100 .B -R
101 will be useful to remove sections which contain information which is
102 not needed by the binary file.
103 .PP
104 .I infile
105 and
106 .I outfile
107 are the source and output files respectively. If you do not specify
108 .IR outfile ,
109 .B objcopy
110 creates a temporary file and destructively renames the result with the
111 name of the input file.
112
113 .SH OPTIONS
114 .TP
115 .B \-I \fIbfdname\fR, \fB\-\-input\-target=\fIbfdname
116 Consider the source file's object format to be
117 .IR bfdname ,
118 rather than attempting to deduce it.
119 .TP
120 .B \-O \fIbfdname\fR, \fB\-\-output\-target=\fIbfdname
121 Write the output file using the object format
122 .IR bfdname .
123 .TP
124 .B \-F \fIbfdname\fR, \fB\-\-target=\fIbfdname
125 Use
126 .I bfdname
127 as the object format for both the input and the output file; i.e.
128 simply transfer data from source to destination with no translation.
129 .TP
130 .B \-j \fIsectionname\fR, \fB\-\-only\-section=\fIsectionname
131 Copy only the named section from the input file to the output file,
132 discarding all other sections. This option may be given more than
133 once. Note that using this option inappropriately may make the output
134 file unusable.
135 .TP
136 .B \-R \fIsectionname\fR, \fB\-\-remove-section=\fIsectionname
137 Remove the named section from the file. This option may be given more
138 than once. Note that using this option inappropriately may make the
139 output file unusable.
140 .TP
141 .B \-S\fR, \fB\-\-strip\-all
142 Do not copy relocation and symbol information from the source file.
143 .TP
144 .B \-g\fR, \fB\-\-strip\-debug
145 Do not copy debugging symbols from the source file.
146 .TP
147 .B \-\-strip\-unneeded
148 Strip all symbols that are not needed for relocation processing.
149 .TP
150 .B \-K \fIsymbolname\fR, \fB\-\-keep\-symbol=\fIsymbolname
151 Copy only symbol \fIsymbolname\fP from the source file. This option
152 may be given more than once.
153 .TP
154 .B \-N \fIsymbolname\fR, \fB\-\-strip\-symbol=\fIsymbolname
155 Do not copy symbol \fIsymbolname\fP from the source file. This option
156 may be given more than once.
157 .TP
158 .B \-L \fIsymbolname\fR, \fB\-\-localize\-symbol=\fIsymbolname
159 Make symbol \fIsymbolname\fP local to the file, so that it is not
160 visible externally. This option may be given more than once.
161 .TP
162 .B \-W \fIsymbolname\fR, \fB\-\-weaken\-symbol=\fIsymbolname
163 Make symbol \fIsymbolname\fP weak. This option may be given more than once.
164 .TP
165 .B \-x\fR, \fB\-\-discard\-all
166 Do not copy non-global symbols from the source file.
167 .TP
168 .B \-X\fR, \fB\-\-discard\-locals
169 Do not copy compiler-generated local symbols. (These usually start
170 with "L" or ".").
171 .TP
172 .B \-b \fIbyte\fR, \fB\-\-byte=\fIbyte
173 Keep only every \fIbyte\fPth byte of the input file (header data is
174 not affected). \fIbyte\fP can be in the range from 0 to the
175 interleave-1. This option is useful for creating files to program
176 ROMs. It is typically used with an srec output target.
177 .TP
178 .B \-i \fIinterleave\fR, \fB\-\-interleave=\fIinterleave
179 Only copy one out of every \fIinterleave\fP bytes. Which one to copy is
180 selected by the \fB\-b\fP or \fB\-\-byte\fP option. The default is 4.
181 The interleave is ignored if neither \fB\-b\fP nor \fB\-\-byte\fP is given.
182 .TP
183 .B \-p\fR, \fB\-\-preserve\-dates
184 Set the access and modification dates of the output file to be the same
185 as those of the input file.
186 .TP
187 .B \-\-debugging
188 Convert debugging information, if possible. This is not the default
189 because only certain debugging formats are supported, and the
190 conversion process can be time consuming.
191 .TP
192 .B \-\-gap\-fill=\fIval
193 Fill gaps between sections with \fIval\fP. This operation applies to
194 the \fIload address\fP (LMA) of the sections. It is done by increasing
195 the size of the section with the lower address, and filling in the extra
196 space created with \fIval\fP.
197 .TP
198 .B \-\-pad\-to=\fIaddress
199 Pad the output file up to the load address \fIaddress\fP. This is
200 done by increasing the size of the last section. The extra space is
201 filled in with the value specified by \fB\-\-gap\-fill\fP (default
202 zero).
203 .TP
204 .B \fB\-\-set\-start=\fIval
205 Set the start address of the new file to \fIval\fP. Not all object
206 file formats support setting the start address.
207 .TP
208 .B \fB\-\-change\-start=\fIincr\fR, \fB\-\-adjust\-start=\fIincr
209 Changes the start address by adding \fIincr\fP. Not all object file
210 formats support setting the start address.
211 .TP
212 .B \fB\-\-change\-addresses=\fIincr\fR, \fB\-\-adjust\-vma=\fIincr
213 Changes the address of all sections, as well as the start address, by
214 adding \fIincr\fP. Some object file formats do not permit section
215 addresses to be changed arbitrarily. Note that this does not relocate
216 the sections; if the program expects sections to be loaded at a
217 certain address, and this option is used to change the sections such
218 that they are loaded at a different address, the program may fail.
219 .TP
220 .B \fB\-\-change\-section\-address\ \fIsection{=,+,-}val\fR, \fB\-\-adjust\-section\-vma\ \fIsection{=,+,-}val
221 Set or changes the VMA and LMA addresses of the named \fIsection\fP.
222 If \fI=\fP is used, the section address is set to \fIval\fP.
223 Otherwise, \fIval\fP is added to or subtracted from the section
224 address. See the comments under \fB\-\-change\-addresses\fP, above. If
225 \fIsection\fP does not exist in the input file, a warning will be
226 issued, unless \fB\-\-no\-change\-warnings\fP is used.
227 .TP
228 .B \fB\-\-change\-section\-lma\ \fIsection{=,+,-}val
229 Set or change the LMA address of the named \fIsection\fP. If \fI=\fP is
230 used, the section address is set to \fIval\fP. Otherwise, \fIval\fP
231 is added to or subtracted from the section address. See the comments
232 under \fB\-\-change\-addresses\fP, above. If \fIsection\fP does not exist
233 in the input file, a warning will be issued, unless
234 \fB\-\-no\-change\-warnings\fP is used.
235 .TP
236 .B \fB\-\-change\-section\-vma\ \fIsection{=,+,-}val
237 Set or change the VMA address of the named \fIsection\fP. If \fI=\fP is
238 used, the section address is set to \fIval\fP. Otherwise, \fIval\fP
239 is added to or subtracted from the section address. See the comments
240 under \fB\-\-change\-addresses\fP, above. If \fIsection\fP does not exist
241 in the input file, a warning will be issued, unless
242 \fB\-\-no\-change\-warnings\fP is used.
243 .TP
244 .B \fB\-\-change\-warnings\fR, \fB\-\-adjust\-warnings
245 If \fB\-\-change\-section\-XXX\fP is used, and the named section does
246 not exist, issue a warning. This is the default.
247 .TP
248 .B \fB\-\-no\-change\-warnings\fR, \fB\-\-no\-adjust\-warnings
249 Do not issue a warning if \fB\-\-change\-section\-XXX\fP is used, even
250 if the named section does not exist.
251 .TP
252 .B \fB\-\-set\-section\-flags\ \fIsection=flags
253 Set the flags for the named section. The \fIflags\fP argument is a
254 comma separated string of flag names. The recognized names are
255 \fIalloc\fP, \fIcontents\fP, \fIload\fP, \fInoload\fP, \fIreadonly\fP,
256 \fIcode\fP, \fIdata\fP, \fIrom\fP, \fIshare\fP, and \fIdebug\fP. Not
257 all flags are meaningful for all object file formats.
258 .TP
259 .B \fB\-\-add\-section\ \fIsectionname=filename
260 Add a new section named \fIsectionname\fR while copying the file. The
261 contents of the new section are taken from the file \fIfilename\fR.
262 The size of the section will be the size of the file. This option
263 only works on file formats which can support sections with arbitrary
264 names.
265 .TP
266 .B \-\-change\-leading\-char
267 Some object file formats use special characters at the start of
268 symbols. The most common such character is underscore, which compilers
269 often add before every symbol. This option tells
270 .B objcopy
271 to change the leading character of every symbol when it converts
272 between object file formats. If the object file formats use the same
273 leading character, this option has no effect. Otherwise, it will add
274 a character, or remove a character, or change a character, as
275 appropriate.
276 .TP
277 .B \-\-remove\-leading\-char
278 If the first character of a global symbol is a special symbol leading
279 character used by the object file format, remove the character. The
280 most common symbol leading character is underscore. This option will
281 remove a leading underscore from all global symbols. This can be
282 useful if you want to link together objects of different file formats
283 with different conventions for symbol names. This is different from
284 \fB\-\-change\-leading\-char\fP because it always changes the symbol name
285 when appropriate, regardless of the object file format of the output
286 .TP
287 .B \fB\-\-srec\-len=\fIval
288 Meaningful only for srec output. Set the length of the Srecords to \fIval\fP.
289 This length covers both the address, data and crc fields.
290 .TP
291 .B \fB\-\-srec\-forceS3
292 Meaningful only for srec output. Avoid generation of S1/S2 records, creating
293 S3-only record format.
294 .TP
295 .B \-\-redefine\-sym\ \fIold=new
296 Change the name of symbol \fIold\fR to \fInew\fR. This can be useful
297 when one is trying link two things together for which you have no
298 source, and there are name collisions.
299 .TP
300 .B \-\-weaken
301 Change all global symbols in the file to be weak.
302 .TP
303 .B \-v\fR, \fB\-\-verbose
304 Verbose output: list all object files modified. In the case of
305 archives, "\fBobjcopy \-V\fR" lists all members of the archive.
306 .TP
307 .B \-V\fR, \fB\-\-version
308 Show the version number of
309 .B objcopy
310 and exit.
311 .TP
312 .B \-\-help
313 Show a summary of the options to
314 .B objcopy
315 and exit.
316 .SH "SEE ALSO"
317 .RB "`\|" binutils "\|'"
318 entry in
319 .B
320 info\c
321 \&;
322 .I
323 The GNU Binary Utilities\c
324 \&, Roland H. Pesch (June 1993).
325
326 .SH COPYING
327 Copyright (c) 1993, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc.
328 .PP
329 Permission is granted to make and distribute verbatim copies of
330 this manual provided the copyright notice and this permission notice
331 are preserved on all copies.
332 .PP
333 Permission is granted to copy and distribute modified versions of this
334 manual under the conditions for verbatim copying, provided that the
335 entire resulting derived work is distributed under the terms of a
336 permission notice identical to this one.
337 .PP
338 Permission is granted to copy and distribute translations of this
339 manual into another language, under the above conditions for modified
340 versions, except that this permission notice may be included in
341 translations approved by the Free Software Foundation instead of in
342 the original English.
This page took 0.043212 seconds and 4 git commands to generate.