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