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