xref: /freebsd/contrib/elftoolchain/elfcopy/elfcopy.1 (revision bbb29a3c0f2c4565eff6fda70426807b6ed97f8b)
1.\" Copyright (c) 2008-2009,2011 Joseph Koshy.  All rights reserved.
2.\"
3.\" Redistribution and use in source and binary forms, with or without
4.\" modification, are permitted provided that the following conditions
5.\" are met:
6.\" 1. Redistributions of source code must retain the above copyright
7.\"    notice, this list of conditions and the following disclaimer.
8.\" 2. Redistributions in binary form must reproduce the above copyright
9.\"    notice, this list of conditions and the following disclaimer in the
10.\"    documentation and/or other materials provided with the distribution.
11.\"
12.\" This software is provided by Joseph Koshy ``as is'' and
13.\" any express or implied warranties, including, but not limited to, the
14.\" implied warranties of merchantability and fitness for a particular purpose
15.\" are disclaimed.  in no event shall Joseph Koshy be liable
16.\" for any direct, indirect, incidental, special, exemplary, or consequential
17.\" damages (including, but not limited to, procurement of substitute goods
18.\" or services; loss of use, data, or profits; or business interruption)
19.\" however caused and on any theory of liability, whether in contract, strict
20.\" liability, or tort (including negligence or otherwise) arising in any way
21.\" out of the use of this software, even if advised of the possibility of
22.\" such damage.
23.\"
24.\" $Id: elfcopy.1 2373 2011-12-30 07:13:44Z jkoshy $
25.\"
26.Dd October 03, 2011
27.Os
28.Dt ELFCOPY 1
29.Sh NAME
30.Nm elfcopy
31.Nd copy and translate object files
32.Sh SYNOPSIS
33.Nm
34.Op Fl I Ar objformat | Fl s Ar objformat | Fl -input-target= Ns Ar objformat
35.Op Fl K Ar symbolname | Fl -keep-symbol= Ns Ar symbolname
36.Op Fl L Ar symbolname | Fl -localize-symbol= Ns Ar symbolname
37.Op Fl N Ar symbolname | Fl -strip-symbol= Ns Ar symbolname
38.Op Fl O Ar objformat | Fl -output-target= Ns Ar objformat
39.Op Fl R Ar sectionname | Fl -remove-section= Ns Ar sectionname
40.Op Fl S | Fl -strip-all
41.Op Fl V | Fl -version
42.Op Fl W Ar symbolname | Fl -weaken-symbol= Ns Ar symbolname
43.Op Fl X | Fl -discard-locals
44.Op Fl d | Fl g | Fl -strip-debug
45.Op Fl h | Fl -help
46.Op Fl j Ar sectionname | Fl -only-section= Ns Ar sectionname
47.Op Fl p | Fl -preserve-dates
48.Op Fl w | Fl -wildcard
49.Op Fl x | Fl -discard-all
50.Op Fl -add-section Ar sectionname Ns = Ns Ar filename
51.Oo
52.Fl -adjust-section-vma Ar section Ns {+|-|=} Ns Ar val |
53.Fl -change-section-address Ar section Ns {+|-|=} Ns Ar val
54.Oc
55.Oo
56.Fl -adjust-start Ns = Ns Ar increment |
57.Fl -change-start Ns = Ns Ar increment
58.Oc
59.Oo
60.Fl -adjust-vma Ns = Ns Ar increment |
61.Fl -change-addresses Ns = Ns Ar increment
62.Oc
63.Op Fl -adjust-warnings | Fl -change-warnings
64.Op Fl -change-section-lma Ar section Ns {+|-|=} Ns Ar val
65.Op Fl -change-section-vma Ar section Ns {+|-|=} Ns Ar val
66.Op Fl -gap-fill Ns = Ns Ar val
67.Op Fl -no-adjust-warnings | Fl -no-change-warnings
68.Op Fl -only-keep-debug
69.Op Fl -pad-to Ns = Ns Ar address
70.Op Fl -prefix-alloc-sections Ns = Ns Ar string
71.Op Fl -prefix-sections Ns = Ns Ar string
72.Op Fl -prefix-symbols Ns = Ns Ar string
73.Op Fl -rename-section Ar oldname Ns = Ns Ar newname Ns Op Ar ,flags
74.Op Fl -set-section-flags Ar sectionname Ns = Ns Ar flags
75.Op Fl -set-start Ns = Ns Ar address
76.Op Fl -srec-forceS3
77.Op Fl -srec-len Ns = Ns Ar val
78.Op Fl -strip-unneeded
79.Ar infile
80.Op Ar outfile
81.Sh DESCRIPTION
82The
83.Nm
84utility copies the content of the ELF object named by argument
85.Ar infile
86to that named by argument
87.Ar outfile ,
88transforming it according to the command line options specified.
89If argument
90.Ar outfile
91is not specified,
92.Nm
93will create a temporary file and will subsequently rename it as
94.Ar infile .
95.Pp
96The
97.Nm
98utility supports the following options:
99.Bl -tag -width indent
100.It Fl I Ar objformat | Fl s Ar objformat | Fl -input-target= Ns Ar objformat
101Specify that the input file named by the argument
102.Ar infile
103is in the object format specified by the argument
104.Ar objformat .
105.It Fl K Ar symbolname | Fl -keep-symbol= Ns Ar symbolname
106Copy the symbol named by argument
107.Ar symbolname
108to the output.
109.It Fl L Ar symbolname | Fl -localize-symbol= Ns Ar symbolname
110Make the symbol named by argument
111.Ar symbolname
112local to the output file.
113.It Fl N Ar symbol | Fl -strip-symbol= Ns Ar symbolname
114Do not copy the symbol named by argument
115.Ar symbolname
116to the output.
117.It Fl O Ar objformat | Fl -output-target= Ns Ar objformat
118Write the output file using the object format specified in argument
119.Ar objformat .
120.It Fl R Ar sectionname | Fl -remove-section= Ns Ar sectionname
121Remove any section with name
122.Ar sectionname
123from the output file.
124.It Fl S | Fl -strip-all
125Do not copy symbol and relocation information to the target file.
126.It Fl V | Fl -version
127Print a version identifier and exit.
128.It Fl W Ar symbolname | Fl -weaken-symbol= Ns Ar symbolname
129Mark the symbol named by argument
130.Ar symbolname
131as weak in the output.
132.It Fl X | Fl -discard-locals
133Do not copy compiler generated local symbols to the output.
134.It Fl d | Fl g | Fl -strip-debug
135Do not copy debugging information to the target file.
136.It Fl h | Fl -help
137Display a help message and exit.
138.It Fl j Ar sectionname | Fl -only-section= Ns Ar sectionname
139Copy only the section named by argument
140.Ar sectionname
141to the output.
142.It Fl p | Fl -preserve-dates
143Set the access and modification times of the output file to the
144same as those of the input.
145.It Fl w | Fl -wildcard
146Use shell-style patterns to name symbols.
147The following meta-characters are recognized in patterns:
148.Bl -tag -width "...." -compact
149.It Li !
150If this is the first character of the pattern, invert the sense of the
151pattern match.
152.It Li *
153Matches any string of characters in a symbol name.
154.It Li ?
155Matches zero or one character in a symbol name.
156.It Li [
157Mark the start of a character class.
158.It Li \e
159Remove the special meaning of the next character in the pattern.
160.It Li ]
161Mark the end of a character class.
162.El
163.It Fl x | Fl -discard-all
164Do not copy non-global symbols to the output.
165.It Fl -add-section Ar sectionname Ns = Ns Ar filename
166Add a new section to the output file with name
167.Ar sectionname .
168The contents of the section are taken from the file named by
169argument
170.Ar filename .
171The size of the section will be the number of bytes in file
172.Ar filename .
173.It Xo
174.Fl -adjust-section-vma Ar section Ns {+|-|=} Ns Ar val |
175.Fl -change-section-address Ar section Ns {+|-|=} Ns Ar val
176.Xc
177Depending on the operator specified, increase, decrease or set both
178the virtual memory address and the load memory address of the section
179named by the argument
180.Ar section .
181The argument
182.Ar val
183specifies the desired increment, decrement or new value for the
184address.
185.It Xo
186.Fl -adjust-start Ns = Ns Ar increment |
187.Fl -change-start Ns = Ns Ar increment
188.Xc
189Increase the entry point address of the output ELF object by the value
190specified in the argument
191.Ar increment .
192.It Xo
193.Fl -adjust-vma Ns = Ns Ar increment |
194.Fl -change-addresses Ns = Ns Ar increment
195.Xc
196Increase the virtual memory address and the load memory address of all
197sections by the value specified by the argument
198.Ar increment .
199.It Fl -adjust-warnings | Fl -change-warnings
200Issue a warning if the section specified by the options
201.Fl -change-section-address ,
202.Fl -change-section-lma
203or
204.Fl -change-section-vma
205does not exist in the input object.
206This is the default.
207.It Fl -change-section-lma Ar section Ns {+|-|=} Ns Ar val
208Change or set the load memory address of the section named by the
209argument
210.Ar section .
211Depending on the operator specified, the value in argument
212.Ar val
213will be used as an increment, a decrement or as the new value
214of the load memory address.
215.It Fl -change-section-vma Ar section Ns {+|-|=} Ns Ar val
216Change or set the virtual memory address of the section named by the
217argument
218.Ar section .
219Depending on the operator specified, the value in argument
220.Ar val
221will be used as an increment, a decrement or as the new value
222of the virtual memory address.
223.It Fl -gap-fill Ns = Ns Ar val
224Fill the gaps between sections with the byte value specified by
225the argument
226.Ar val .
227.It Fl -no-adjust-warnings | Fl -no-change-warnings
228Do not issue a warning if the section specified by the options
229.Fl -change-section-address ,
230.Fl -change-section-lma
231or
232.Fl -change-section-vma
233is missing in the input object.
234.It Fl -only-keep-debug
235Copy only debugging information to the output file.
236.It Fl -pad-to Ns = Ns Ar address
237Pad the load memory address of the output object to the value
238specified by the argument
239.Ar address
240by increasing the size of the section with the highest load memory
241address.
242.It Fl -prefix-alloc-sections Ns = Ns Ar string
243Prefix the section names of all the allocated sections with
244.Ar string .
245.It Fl -prefix-sections Ns = Ns Ar string
246Prefix the section names of all the sections with
247.Ar string .
248.It Fl -prefix-symbols Ns = Ns Ar string
249Prefix the symbol names of all the symbols with
250.Ar string .
251.It Fl -rename-section Ar oldname Ns = Ns Ar newname Ns Op Ar ,flags
252Rename the section named by argument
253.Ar oldname
254to
255.Ar newname ,
256optionally changing the sections flags to that specified by argument
257.Ar flags .
258Allowed values for the argument
259.Ar flags
260are as for option
261.Fl -set-section-flags
262below.
263.It Fl -set-section-flags Ar sectionname Ns = Ns Ar flags
264Set the flags for the section named by argument
265.Ar sectionname
266to those specified by argument
267.Ar flags .
268Argument
269.Ar flags
270is a comma separated list of the following flag names:
271.Bl -tag -width "readonly" -compact
272.It alloc
273The section occupies space in the output file.
274.It code
275The section contains machine instructions.
276.It contents
277This flag is accepted but is ignored.
278.It data
279The section contains writeable data.
280.It debug
281The section holds debugging information.
282.It load
283The section is loadable.
284.It noload
285The section should not be loaded into memory.
286.It readonly
287The section is not writable.
288.It rom
289The section contains ROM'able contents.
290.It share
291This flag is accepted but is ignored.
292.El
293.It Fl -set-start Ns = Ns Ar address
294Set the start address of the output ELF object to the value specified
295by the argument
296.Ar address .
297.It Fl -srec-forceS3
298Only generate S-records of type
299.Dq S3 .
300This option is only meaningful when the output target is set to
301.Dq srec .
302.It Fl -srec-len Ns = Ns Ar val
303Set the maximum length of an S-record line to
304.Ar val .
305This option is only meaningful when the output target is set to
306.Dq srec .
307.It Fl -strip-unneeded
308Do not copy symbols that are not needed for relocation processing.
309.El
310.Sh DIAGNOSTICS
311.Ex -std
312.Sh SEE ALSO
313.Xr ar 1 ,
314.Xr ld 1 ,
315.Xr mcs 1 ,
316.Xr strip 1 ,
317.Xr elf 3 ,
318.Xr ar 5 ,
319.Xr elf 5
320.Sh HISTORY
321.Nm
322has been implemented by
323.An "Kai Wang" Aq kaiwang27@users.sourceforge.net .
324