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