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