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