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