]>
Commit | Line | Data |
---|---|---|
252b5132 RH |
1 | \input texinfo @c -*- Texinfo -*- |
2 | @setfilename binutils.info | |
e016ec1f NC |
3 | @settitle @sc{gnu} Binary Utilities |
4 | @finalout | |
5 | @synindex ky cp | |
8c2bc687 | 6 | |
dff70155 | 7 | @c man begin INCLUDE |
c428fa83 | 8 | @include bfdver.texi |
dff70155 | 9 | @c man end |
252b5132 | 10 | |
0e9517a9 | 11 | @copying |
0285c67d | 12 | @c man begin COPYRIGHT |
250d07de | 13 | Copyright @copyright{} 1991-2021 Free Software Foundation, Inc. |
252b5132 | 14 | |
0285c67d | 15 | Permission is granted to copy, distribute and/or modify this document |
793c5807 | 16 | under the terms of the GNU Free Documentation License, Version 1.3 |
0285c67d NC |
17 | or any later version published by the Free Software Foundation; |
18 | with no Invariant Sections, with no Front-Cover Texts, and with no | |
19 | Back-Cover Texts. A copy of the license is included in the | |
947ed062 | 20 | section entitled ``GNU Free Documentation License''. |
252b5132 | 21 | |
0285c67d | 22 | @c man end |
0e9517a9 | 23 | @end copying |
252b5132 | 24 | |
e016ec1f NC |
25 | @dircategory Software development |
26 | @direntry | |
27 | * Binutils: (binutils). The GNU binary utilities. | |
28 | @end direntry | |
29 | ||
30 | @dircategory Individual utilities | |
31 | @direntry | |
32 | * addr2line: (binutils)addr2line. Convert addresses to file and line. | |
33 | * ar: (binutils)ar. Create, modify, and extract from archives. | |
34 | * c++filt: (binutils)c++filt. Filter to demangle encoded C++ symbols. | |
35 | * cxxfilt: (binutils)c++filt. MS-DOS name for c++filt. | |
36 | * dlltool: (binutils)dlltool. Create files needed to build and use DLLs. | |
e016ec1f NC |
37 | * nm: (binutils)nm. List symbols from object files. |
38 | * objcopy: (binutils)objcopy. Copy and translate object files. | |
39 | * objdump: (binutils)objdump. Display information from object files. | |
40 | * ranlib: (binutils)ranlib. Generate index to archive contents. | |
41 | * readelf: (binutils)readelf. Display the contents of ELF format files. | |
42 | * size: (binutils)size. List section sizes and total size. | |
43 | * strings: (binutils)strings. List printable strings from files. | |
44 | * strip: (binutils)strip. Discard symbols. | |
8a6b075b | 45 | * elfedit: (binutils)elfedit. Update ELF header and property of ELF files. |
e016ec1f NC |
46 | * windmc: (binutils)windmc. Generator for Windows message resources. |
47 | * windres: (binutils)windres. Manipulate Windows resources. | |
48 | @end direntry | |
49 | ||
252b5132 | 50 | @titlepage |
252b5132 | 51 | @title The @sc{gnu} Binary Utilities |
e49e529d JM |
52 | @ifset VERSION_PACKAGE |
53 | @subtitle @value{VERSION_PACKAGE} | |
54 | @end ifset | |
252b5132 RH |
55 | @subtitle Version @value{VERSION} |
56 | @sp 1 | |
36607f99 | 57 | @subtitle @value{UPDATED} |
252b5132 RH |
58 | @author Roland H. Pesch |
59 | @author Jeffrey M. Osier | |
60 | @author Cygnus Support | |
61 | @page | |
62 | ||
63 | @tex | |
64 | {\parskip=0pt \hfill Cygnus Support\par \hfill | |
e016ec1f | 65 | Texinfo \texinfoversion\par } |
252b5132 RH |
66 | @end tex |
67 | ||
68 | @vskip 0pt plus 1filll | |
e016ec1f | 69 | @insertcopying |
252b5132 | 70 | @end titlepage |
4ecceb71 | 71 | @contents |
252b5132 RH |
72 | |
73 | @node Top | |
74 | @top Introduction | |
75 | ||
76 | @cindex version | |
947ed062 | 77 | This brief manual contains documentation for the @sc{gnu} binary |
e49e529d JM |
78 | utilities |
79 | @ifset VERSION_PACKAGE | |
80 | @value{VERSION_PACKAGE} | |
81 | @end ifset | |
82 | version @value{VERSION}: | |
252b5132 RH |
83 | |
84 | @iftex | |
85 | @table @code | |
86 | @item ar | |
87 | Create, modify, and extract from archives | |
88 | ||
89 | @item nm | |
90 | List symbols from object files | |
91 | ||
92 | @item objcopy | |
93 | Copy and translate object files | |
94 | ||
95 | @item objdump | |
96 | Display information from object files | |
97 | ||
98 | @item ranlib | |
99 | Generate index to archive contents | |
100 | ||
101 | @item readelf | |
102 | Display the contents of ELF format files. | |
103 | ||
104 | @item size | |
105 | List file section sizes and total size | |
106 | ||
107 | @item strings | |
108 | List printable strings from files | |
109 | ||
110 | @item strip | |
111 | Discard symbols | |
112 | ||
30fd33bb | 113 | @item elfedit |
8a6b075b | 114 | Update the ELF header and program property of ELF files. |
30fd33bb | 115 | |
252b5132 | 116 | @item c++filt |
9d51cc66 ILT |
117 | Demangle encoded C++ symbols (on MS-DOS, this program is named |
118 | @code{cxxfilt}) | |
252b5132 RH |
119 | |
120 | @item addr2line | |
121 | Convert addresses into file names and line numbers | |
122 | ||
252b5132 RH |
123 | @item windres |
124 | Manipulate Windows resources | |
125 | ||
692ed3e7 | 126 | @item windmc |
a8685210 | 127 | Generator for Windows message resources |
692ed3e7 | 128 | |
252b5132 RH |
129 | @item dlltool |
130 | Create the files needed to build and use Dynamic Link Libraries | |
131 | @end table | |
132 | @end iftex | |
133 | ||
cf055d54 | 134 | This document is distributed under the terms of the GNU Free |
793c5807 NC |
135 | Documentation License version 1.3. A copy of the license is included |
136 | in the section entitled ``GNU Free Documentation License''. | |
cf055d54 | 137 | |
252b5132 RH |
138 | @menu |
139 | * ar:: Create, modify, and extract from archives | |
140 | * nm:: List symbols from object files | |
141 | * objcopy:: Copy and translate object files | |
142 | * objdump:: Display information from object files | |
143 | * ranlib:: Generate index to archive contents | |
252b5132 RH |
144 | * size:: List section sizes and total size |
145 | * strings:: List printable strings from files | |
146 | * strip:: Discard symbols | |
147 | * c++filt:: Filter to demangle encoded C++ symbols | |
9d51cc66 | 148 | * cxxfilt: c++filt. MS-DOS name for c++filt |
252b5132 | 149 | * addr2line:: Convert addresses to file and line |
692ed3e7 | 150 | * windmc:: Generator for Windows message resources |
7ca01ed9 | 151 | * windres:: Manipulate Windows resources |
252b5132 | 152 | * dlltool:: Create files needed to build and use DLLs |
7ca01ed9 | 153 | * readelf:: Display the contents of ELF format files |
8a6b075b | 154 | * elfedit:: Update ELF header and property of ELF files |
07012eee | 155 | * Common Options:: Command-line options for all utilities |
fff279a7 | 156 | * Selecting the Target System:: How these utilities determine the target |
301a9420 | 157 | * debuginfod:: Using binutils with debuginfod |
252b5132 | 158 | * Reporting Bugs:: Reporting Bugs |
cf055d54 | 159 | * GNU Free Documentation License:: GNU Free Documentation License |
fa0d8a3e | 160 | * Binutils Index:: Binutils Index |
252b5132 RH |
161 | @end menu |
162 | ||
163 | @node ar | |
164 | @chapter ar | |
165 | ||
166 | @kindex ar | |
167 | @cindex archives | |
168 | @cindex collections of files | |
0285c67d NC |
169 | |
170 | @c man title ar create, modify, and extract from archives | |
171 | ||
252b5132 | 172 | @smallexample |
f3016d6c | 173 | ar [-]@var{p}[@var{mod}] [@option{--plugin} @var{name}] [@option{--target} @var{bfdname}] [@option{--output} @var{dirname}] [@option{--record-libdeps} @var{libdeps}] [@var{relpos}] [@var{count}] @var{archive} [@var{member}@dots{}] |
252b5132 RH |
174 | ar -M [ <mri-script ] |
175 | @end smallexample | |
176 | ||
0285c67d NC |
177 | @c man begin DESCRIPTION ar |
178 | ||
c7c55b78 | 179 | The @sc{gnu} @command{ar} program creates, modifies, and extracts from |
252b5132 RH |
180 | archives. An @dfn{archive} is a single file holding a collection of |
181 | other files in a structure that makes it possible to retrieve | |
182 | the original individual files (called @dfn{members} of the archive). | |
183 | ||
184 | The original files' contents, mode (permissions), timestamp, owner, and | |
185 | group are preserved in the archive, and can be restored on | |
c1c0eb9e | 186 | extraction. |
252b5132 RH |
187 | |
188 | @cindex name length | |
c7c55b78 NC |
189 | @sc{gnu} @command{ar} can maintain archives whose members have names of any |
190 | length; however, depending on how @command{ar} is configured on your | |
252b5132 RH |
191 | system, a limit on member-name length may be imposed for compatibility |
192 | with archive formats maintained with other tools. If it exists, the | |
193 | limit is often 15 characters (typical of formats related to a.out) or 16 | |
194 | characters (typical of formats related to coff). | |
195 | ||
196 | @cindex libraries | |
c7c55b78 | 197 | @command{ar} is considered a binary utility because archives of this sort |
252b5132 | 198 | are most often used as @dfn{libraries} holding commonly needed |
f3016d6c HC |
199 | subroutines. Since libraries often will depend on other libraries, |
200 | @command{ar} can also record the dependencies of a library when the | |
201 | @option{--record-libdeps} option is specified. | |
252b5132 RH |
202 | |
203 | @cindex symbol index | |
c7c55b78 | 204 | @command{ar} creates an index to the symbols defined in relocatable |
252b5132 | 205 | object modules in the archive when you specify the modifier @samp{s}. |
c7c55b78 | 206 | Once created, this index is updated in the archive whenever @command{ar} |
252b5132 RH |
207 | makes a change to its contents (save for the @samp{q} update operation). |
208 | An archive with such an index speeds up linking to the library, and | |
209 | allows routines in the library to call each other without regard to | |
210 | their placement in the archive. | |
211 | ||
212 | You may use @samp{nm -s} or @samp{nm --print-armap} to list this index | |
c7c55b78 NC |
213 | table. If an archive lacks the table, another form of @command{ar} called |
214 | @command{ranlib} can be used to add just the table. | |
252b5132 | 215 | |
a8da6403 NC |
216 | @cindex thin archives |
217 | @sc{gnu} @command{ar} can optionally create a @emph{thin} archive, | |
218 | which contains a symbol index and references to the original copies | |
a043396b NC |
219 | of the member files of the archive. This is useful for building |
220 | libraries for use within a local build tree, where the relocatable | |
221 | objects are expected to remain available, and copying the contents of | |
222 | each object would only waste time and space. | |
223 | ||
224 | An archive can either be @emph{thin} or it can be normal. It cannot | |
225 | be both at the same time. Once an archive is created its format | |
226 | cannot be changed without first deleting it and then creating a new | |
227 | archive in its place. | |
228 | ||
229 | Thin archives are also @emph{flattened}, so that adding one thin | |
230 | archive to another thin archive does not nest it, as would happen with | |
231 | a normal archive. Instead the elements of the first archive are added | |
232 | individually to the second archive. | |
233 | ||
a8da6403 | 234 | The paths to the elements of the archive are stored relative to the |
d8f187c1 | 235 | archive itself. |
a8da6403 | 236 | |
c7c55b78 NC |
237 | @cindex compatibility, @command{ar} |
238 | @cindex @command{ar} compatibility | |
239 | @sc{gnu} @command{ar} is designed to be compatible with two different | |
252b5132 | 240 | facilities. You can control its activity using command-line options, |
c7c55b78 NC |
241 | like the different varieties of @command{ar} on Unix systems; or, if you |
242 | specify the single command-line option @option{-M}, you can control it | |
252b5132 RH |
243 | with a script supplied via standard input, like the MRI ``librarian'' |
244 | program. | |
245 | ||
0285c67d NC |
246 | @c man end |
247 | ||
252b5132 | 248 | @menu |
c7c55b78 NC |
249 | * ar cmdline:: Controlling @command{ar} on the command line |
250 | * ar scripts:: Controlling @command{ar} with a script | |
252b5132 RH |
251 | @end menu |
252 | ||
253 | @page | |
254 | @node ar cmdline | |
947ed062 | 255 | @section Controlling @command{ar} on the Command Line |
252b5132 RH |
256 | |
257 | @smallexample | |
0285c67d | 258 | @c man begin SYNOPSIS ar |
f3016d6c | 259 | ar [@option{-X32_64}] [@option{-}]@var{p}[@var{mod}] [@option{--plugin} @var{name}] [@option{--target} @var{bfdname}] [@option{--output} @var{dirname}] [@option{--record-libdeps} @var{libdeps}] [@var{relpos}] [@var{count}] @var{archive} [@var{member}@dots{}] |
0285c67d | 260 | @c man end |
252b5132 RH |
261 | @end smallexample |
262 | ||
c7c55b78 NC |
263 | @cindex Unix compatibility, @command{ar} |
264 | When you use @command{ar} in the Unix style, @command{ar} insists on at least two | |
252b5132 RH |
265 | arguments to execute: one keyletter specifying the @emph{operation} |
266 | (optionally accompanied by other keyletters specifying | |
267 | @emph{modifiers}), and the archive name to act on. | |
268 | ||
269 | Most operations can also accept further @var{member} arguments, | |
270 | specifying particular files to operate on. | |
271 | ||
0285c67d NC |
272 | @c man begin OPTIONS ar |
273 | ||
c7c55b78 | 274 | @sc{gnu} @command{ar} allows you to mix the operation code @var{p} and modifier |
252b5132 RH |
275 | flags @var{mod} in any order, within the first command-line argument. |
276 | ||
277 | If you wish, you may begin the first command-line argument with a | |
278 | dash. | |
279 | ||
280 | @cindex operations on archive | |
281 | The @var{p} keyletter specifies what operation to execute; it may be | |
282 | any of the following, but you must specify only one of them: | |
283 | ||
c7c55b78 | 284 | @table @samp |
252b5132 RH |
285 | @item d |
286 | @cindex deleting from archive | |
287 | @emph{Delete} modules from the archive. Specify the names of modules to | |
288 | be deleted as @var{member}@dots{}; the archive is untouched if you | |
289 | specify no files to delete. | |
290 | ||
c7c55b78 | 291 | If you specify the @samp{v} modifier, @command{ar} lists each module |
252b5132 RH |
292 | as it is deleted. |
293 | ||
294 | @item m | |
295 | @cindex moving in archive | |
296 | Use this operation to @emph{move} members in an archive. | |
297 | ||
298 | The ordering of members in an archive can make a difference in how | |
299 | programs are linked using the library, if a symbol is defined in more | |
c1c0eb9e | 300 | than one member. |
252b5132 RH |
301 | |
302 | If no modifiers are used with @code{m}, any members you name in the | |
303 | @var{member} arguments are moved to the @emph{end} of the archive; | |
304 | you can use the @samp{a}, @samp{b}, or @samp{i} modifiers to move them to a | |
305 | specified place instead. | |
306 | ||
307 | @item p | |
308 | @cindex printing from archive | |
309 | @emph{Print} the specified members of the archive, to the standard | |
310 | output file. If the @samp{v} modifier is specified, show the member | |
311 | name before copying its contents to standard output. | |
312 | ||
313 | If you specify no @var{member} arguments, all the files in the archive are | |
314 | printed. | |
315 | ||
316 | @item q | |
317 | @cindex quick append to archive | |
318 | @emph{Quick append}; Historically, add the files @var{member}@dots{} to the end of | |
319 | @var{archive}, without checking for replacement. | |
320 | ||
321 | The modifiers @samp{a}, @samp{b}, and @samp{i} do @emph{not} affect this | |
322 | operation; new members are always placed at the end of the archive. | |
323 | ||
c7c55b78 | 324 | The modifier @samp{v} makes @command{ar} list each file as it is appended. |
252b5132 | 325 | |
ce0570c7 NC |
326 | Since the point of this operation is speed, implementations of |
327 | @command{ar} have the option of not updating the archive's symbol | |
328 | table if one exists. Too many different systems however assume that | |
329 | symbol tables are always up-to-date, so @sc{gnu} @command{ar} will | |
330 | rebuild the table even with a quick append. | |
331 | ||
5e080929 | 332 | Note - @sc{gnu} @command{ar} treats the command @samp{qs} as a |
ce0570c7 NC |
333 | synonym for @samp{r} - replacing already existing files in the |
334 | archive and appending new ones at the end. | |
252b5132 RH |
335 | |
336 | @item r | |
337 | @cindex replacement in archive | |
338 | Insert the files @var{member}@dots{} into @var{archive} (with | |
339 | @emph{replacement}). This operation differs from @samp{q} in that any | |
340 | previously existing members are deleted if their names match those being | |
341 | added. | |
342 | ||
c7c55b78 | 343 | If one of the files named in @var{member}@dots{} does not exist, @command{ar} |
252b5132 RH |
344 | displays an error message, and leaves undisturbed any existing members |
345 | of the archive matching that name. | |
346 | ||
347 | By default, new members are added at the end of the file; but you may | |
348 | use one of the modifiers @samp{a}, @samp{b}, or @samp{i} to request | |
349 | placement relative to some existing member. | |
350 | ||
351 | The modifier @samp{v} used with this operation elicits a line of | |
352 | output for each file inserted, along with one of the letters @samp{a} or | |
353 | @samp{r} to indicate whether the file was appended (no old member | |
354 | deleted) or replaced. | |
355 | ||
e58bcb8f NC |
356 | @item s |
357 | @cindex ranlib | |
358 | Add an index to the archive, or update it if it already exists. Note | |
359 | this command is an exception to the rule that there can only be one | |
360 | command letter, as it is possible to use it as either a command or a | |
361 | modifier. In either case it does the same thing. | |
362 | ||
252b5132 RH |
363 | @item t |
364 | @cindex contents of archive | |
365 | Display a @emph{table} listing the contents of @var{archive}, or those | |
366 | of the files listed in @var{member}@dots{} that are present in the | |
1869e86f AB |
367 | archive. Normally only the member name is shown, but if the modifier |
368 | @samp{O} is specified, then the corresponding offset of the member is also | |
369 | displayed. Finally, in order to see the modes (permissions), timestamp, | |
370 | owner, group, and size the @samp{v} modifier should be included. | |
252b5132 RH |
371 | |
372 | If you do not specify a @var{member}, all files in the archive | |
373 | are listed. | |
374 | ||
375 | @cindex repeated names in archive | |
376 | @cindex name duplication in archive | |
377 | If there is more than one file with the same name (say, @samp{fie}) in | |
378 | an archive (say @samp{b.a}), @samp{ar t b.a fie} lists only the | |
379 | first instance; to see them all, you must ask for a complete | |
380 | listing---in our example, @samp{ar t b.a}. | |
381 | @c WRS only; per Gumby, this is implementation-dependent, and in a more | |
382 | @c recent case in fact works the other way. | |
383 | ||
384 | @item x | |
385 | @cindex extract from archive | |
386 | @emph{Extract} members (named @var{member}) from the archive. You can | |
387 | use the @samp{v} modifier with this operation, to request that | |
c7c55b78 | 388 | @command{ar} list each name as it extracts it. |
252b5132 RH |
389 | |
390 | If you do not specify a @var{member}, all files in the archive | |
391 | are extracted. | |
392 | ||
95cc7c16 AM |
393 | Files cannot be extracted from a thin archive, and there are |
394 | restrictions on extracting from archives created with @option{P}: The | |
395 | paths must not be absolute, may not contain @code{..}, and any | |
e264b5b7 NC |
396 | subdirectories in the paths must exist. If it is desired to avoid |
397 | these restrictions then used the @option{--output} option to specify | |
398 | an output directory. | |
252b5132 RH |
399 | @end table |
400 | ||
401 | A number of modifiers (@var{mod}) may immediately follow the @var{p} | |
402 | keyletter, to specify variations on an operation's behavior: | |
403 | ||
c7c55b78 | 404 | @table @samp |
252b5132 RH |
405 | @item a |
406 | @cindex relative placement in archive | |
407 | Add new files @emph{after} an existing member of the | |
408 | archive. If you use the modifier @samp{a}, the name of an existing archive | |
409 | member must be present as the @var{relpos} argument, before the | |
410 | @var{archive} specification. | |
411 | ||
412 | @item b | |
413 | Add new files @emph{before} an existing member of the | |
414 | archive. If you use the modifier @samp{b}, the name of an existing archive | |
415 | member must be present as the @var{relpos} argument, before the | |
416 | @var{archive} specification. (same as @samp{i}). | |
417 | ||
418 | @item c | |
419 | @cindex creating archives | |
420 | @emph{Create} the archive. The specified @var{archive} is always | |
421 | created if it did not exist, when you request an update. But a warning is | |
422 | issued unless you specify in advance that you expect to create it, by | |
423 | using this modifier. | |
424 | ||
36e4dce6 CD |
425 | @item D |
426 | @cindex deterministic archives | |
9cb80f72 | 427 | @kindex --enable-deterministic-archives |
36e4dce6 CD |
428 | Operate in @emph{deterministic} mode. When adding files and the archive |
429 | index use zero for UIDs, GIDs, timestamps, and use consistent file modes | |
430 | for all files. When this option is used, if @command{ar} is used with | |
431 | identical options and identical input files, multiple runs will create | |
432 | identical output files regardless of the input files' owners, groups, | |
433 | file modes, or modification times. | |
434 | ||
9cb80f72 RM |
435 | If @file{binutils} was configured with |
436 | @option{--enable-deterministic-archives}, then this mode is on by default. | |
437 | It can be disabled with the @samp{U} modifier, below. | |
438 | ||
252b5132 | 439 | @item f |
c7c55b78 | 440 | Truncate names in the archive. @sc{gnu} @command{ar} will normally permit file |
252b5132 | 441 | names of any length. This will cause it to create archives which are |
c7c55b78 | 442 | not compatible with the native @command{ar} program on some systems. If |
252b5132 RH |
443 | this is a concern, the @samp{f} modifier may be used to truncate file |
444 | names when putting them in the archive. | |
445 | ||
446 | @item i | |
447 | Insert new files @emph{before} an existing member of the | |
448 | archive. If you use the modifier @samp{i}, the name of an existing archive | |
449 | member must be present as the @var{relpos} argument, before the | |
450 | @var{archive} specification. (same as @samp{b}). | |
451 | ||
452 | @item l | |
f3016d6c | 453 | @c This modifier was accepted but not used. |
252b5132 | 454 | @c whaffor ar l modifier??? presumably compat; with |
c1c0eb9e | 455 | @c what???---doc@@cygnus.com, 25jan91 |
f3016d6c HC |
456 | Specify dependencies of this library. The dependencies must immediately |
457 | follow this option character, must use the same syntax as the linker | |
458 | command line, and must be specified within a single argument. I.e., if | |
459 | multiple items are needed, they must be quoted to form a single command | |
460 | line argument. For example @samp{L "-L/usr/local/lib -lmydep1 -lmydep2"} | |
252b5132 | 461 | |
3de39064 ILT |
462 | @item N |
463 | Uses the @var{count} parameter. This is used if there are multiple | |
464 | entries in the archive with the same name. Extract or delete instance | |
465 | @var{count} of the given name from the archive. | |
466 | ||
252b5132 RH |
467 | @item o |
468 | @cindex dates in archive | |
469 | Preserve the @emph{original} dates of members when extracting them. If | |
470 | you do not specify this modifier, files extracted from the archive | |
471 | are stamped with the time of extraction. | |
472 | ||
1869e86f AB |
473 | @item O |
474 | @cindex offsets of files | |
475 | Display member offsets inside the archive. Use together with the @samp{t} | |
476 | option. | |
477 | ||
3de39064 | 478 | @item P |
95cc7c16 AM |
479 | Use the full path name when matching or storing names in the archive. |
480 | Archives created with full path names are not POSIX compliant, and | |
481 | thus may not work with tools other than up to date @sc{gnu} tools. | |
482 | Modifying such archives with @sc{gnu} @command{ar} without using | |
483 | @option{P} will remove the full path names unless the archive is a | |
484 | thin archive. Note that @option{P} may be useful when adding files to | |
485 | a thin archive since @option{r} without @option{P} ignores the path | |
486 | when choosing which element to replace. Thus | |
487 | @smallexample | |
488 | ar rcST archive.a subdir/file1 subdir/file2 file1 | |
489 | @end smallexample | |
490 | will result in the first @code{subdir/file1} being replaced with | |
491 | @code{file1} from the current directory. Adding @option{P} will | |
492 | prevent this replacement. | |
3de39064 | 493 | |
252b5132 RH |
494 | @item s |
495 | @cindex writing archive index | |
496 | Write an object-file index into the archive, or update an existing one, | |
497 | even if no other change is made to the archive. You may use this modifier | |
498 | flag either with any operation, or alone. Running @samp{ar s} on an | |
499 | archive is equivalent to running @samp{ranlib} on it. | |
500 | ||
501 | @item S | |
502 | @cindex not writing archive index | |
503 | Do not generate an archive symbol table. This can speed up building a | |
504 | large library in several steps. The resulting archive can not be used | |
505 | with the linker. In order to build a symbol table, you must omit the | |
506 | @samp{S} modifier on the last execution of @samp{ar}, or you must run | |
507 | @samp{ranlib} on the archive. | |
508 | ||
a8da6403 NC |
509 | @item T |
510 | @cindex creating thin archive | |
511 | Make the specified @var{archive} a @emph{thin} archive. If it already | |
512 | exists and is a regular archive, the existing members must be present | |
513 | in the same directory as @var{archive}. | |
514 | ||
252b5132 RH |
515 | @item u |
516 | @cindex updating an archive | |
517 | Normally, @samp{ar r}@dots{} inserts all files | |
518 | listed into the archive. If you would like to insert @emph{only} those | |
519 | of the files you list that are newer than existing members of the same | |
520 | names, use this modifier. The @samp{u} modifier is allowed only for the | |
521 | operation @samp{r} (replace). In particular, the combination @samp{qu} is | |
522 | not allowed, since checking the timestamps would lose any speed | |
523 | advantage from the operation @samp{q}. | |
524 | ||
9cb80f72 RM |
525 | @item U |
526 | @cindex deterministic archives | |
527 | @kindex --enable-deterministic-archives | |
528 | Do @emph{not} operate in @emph{deterministic} mode. This is the inverse | |
529 | of the @samp{D} modifier, above: added files and the archive index will | |
530 | get their actual UID, GID, timestamp, and file mode values. | |
531 | ||
532 | This is the default unless @file{binutils} was configured with | |
533 | @option{--enable-deterministic-archives}. | |
534 | ||
252b5132 RH |
535 | @item v |
536 | This modifier requests the @emph{verbose} version of an operation. Many | |
537 | operations display additional information, such as filenames processed, | |
538 | when the modifier @samp{v} is appended. | |
539 | ||
540 | @item V | |
c7c55b78 | 541 | This modifier shows the version number of @command{ar}. |
252b5132 RH |
542 | @end table |
543 | ||
a05a5b64 | 544 | The @command{ar} program also supports some command-line options which |
387dd777 DP |
545 | are neither modifiers nor actions, but which do change its behaviour |
546 | in specific ways: | |
547 | ||
548 | @table @samp | |
549 | @item --help | |
a05a5b64 | 550 | Displays the list of command-line options supported by @command{ar} |
387dd777 DP |
551 | and then exits. |
552 | ||
553 | @item --version | |
554 | Displays the version information of @command{ar} and then exits. | |
555 | ||
556 | @item -X32_64 | |
95cc7c16 | 557 | @command{ar} ignores an initial option spelled @samp{-X32_64}, for |
6e800839 | 558 | compatibility with AIX. The behaviour produced by this option is the |
387dd777 DP |
559 | default for @sc{gnu} @command{ar}. @command{ar} does not support any |
560 | of the other @samp{-X} options; in particular, it does not support | |
561 | @option{-X32} which is the default for AIX @command{ar}. | |
6e800839 | 562 | |
387dd777 DP |
563 | @item --plugin @var{name} |
564 | @cindex plugins | |
a05a5b64 | 565 | The optional command-line switch @option{--plugin @var{name}} causes |
ce3c775b | 566 | @command{ar} to load the plugin called @var{name} which adds support |
387dd777 DP |
567 | for more file formats, including object files with link-time |
568 | optimization information. | |
569 | ||
570 | This option is only available if the toolchain has been built with | |
571 | plugin support enabled. | |
572 | ||
573 | If @option{--plugin} is not provided, but plugin support has been | |
574 | enabled then @command{ar} iterates over the files in | |
575 | @file{$@{libdir@}/bfd-plugins} in alphabetic order and the first | |
576 | plugin that claims the object in question is used. | |
577 | ||
578 | Please note that this plugin search directory is @emph{not} the one | |
579 | used by @command{ld}'s @option{-plugin} option. In order to make | |
580 | @command{ar} use the linker plugin it must be copied into the | |
581 | @file{$@{libdir@}/bfd-plugins} directory. For GCC based compilations | |
582 | the linker plugin is called @file{liblto_plugin.so.0.0.0}. For Clang | |
583 | based compilations it is called @file{LLVMgold.so}. The GCC plugin | |
584 | is always backwards compatible with earlier versions, so it is | |
585 | sufficient to just copy the newest one. | |
586 | ||
587 | @item --target @var{target} | |
a05a5b64 | 588 | The optional command-line switch @option{--target @var{bfdname}} |
8adf5d70 NC |
589 | specifies that the archive members are in an object code format |
590 | different from your system's default format. See | |
591 | @xref{Target Selection}, for more information. | |
197245e3 FS |
592 | |
593 | @item --output @var{dirname} | |
594 | The @option{--output} option can be used to specify a path to a | |
595 | directory into which archive members should be extracted. If this | |
596 | option is not specified then the current directory will be used. | |
597 | ||
598 | Note - although the presence of this option does imply a @option{x} | |
599 | extraction operation that option must still be included on the command | |
600 | line. | |
601 | ||
f3016d6c HC |
602 | @item --record-libdeps @var{libdeps} |
603 | The @option{--record-libdeps} option is identical to the @option{l} modifier, | |
604 | just handled in long form. | |
605 | ||
387dd777 | 606 | @end table |
0285c67d NC |
607 | @c man end |
608 | ||
609 | @ignore | |
610 | @c man begin SEEALSO ar | |
611 | nm(1), ranlib(1), and the Info entries for @file{binutils}. | |
612 | @c man end | |
613 | @end ignore | |
614 | ||
252b5132 | 615 | @node ar scripts |
947ed062 | 616 | @section Controlling @command{ar} with a Script |
252b5132 RH |
617 | |
618 | @smallexample | |
619 | ar -M [ <@var{script} ] | |
620 | @end smallexample | |
621 | ||
c7c55b78 NC |
622 | @cindex MRI compatibility, @command{ar} |
623 | @cindex scripts, @command{ar} | |
624 | If you use the single command-line option @samp{-M} with @command{ar}, you | |
252b5132 | 625 | can control its operation with a rudimentary command language. This |
c7c55b78 NC |
626 | form of @command{ar} operates interactively if standard input is coming |
627 | directly from a terminal. During interactive use, @command{ar} prompts for | |
252b5132 RH |
628 | input (the prompt is @samp{AR >}), and continues executing even after |
629 | errors. If you redirect standard input to a script file, no prompts are | |
c7c55b78 | 630 | issued, and @command{ar} abandons execution (with a nonzero exit code) |
252b5132 RH |
631 | on any error. |
632 | ||
c7c55b78 | 633 | The @command{ar} command language is @emph{not} designed to be equivalent |
252b5132 RH |
634 | to the command-line options; in fact, it provides somewhat less control |
635 | over archives. The only purpose of the command language is to ease the | |
c7c55b78 | 636 | transition to @sc{gnu} @command{ar} for developers who already have scripts |
252b5132 RH |
637 | written for the MRI ``librarian'' program. |
638 | ||
c7c55b78 | 639 | The syntax for the @command{ar} command language is straightforward: |
252b5132 RH |
640 | @itemize @bullet |
641 | @item | |
642 | commands are recognized in upper or lower case; for example, @code{LIST} | |
643 | is the same as @code{list}. In the following descriptions, commands are | |
644 | shown in upper case for clarity. | |
645 | ||
646 | @item | |
647 | a single command may appear on each line; it is the first word on the | |
648 | line. | |
649 | ||
650 | @item | |
651 | empty lines are allowed, and have no effect. | |
652 | ||
653 | @item | |
654 | comments are allowed; text after either of the characters @samp{*} | |
655 | or @samp{;} is ignored. | |
656 | ||
657 | @item | |
c7c55b78 | 658 | Whenever you use a list of names as part of the argument to an @command{ar} |
252b5132 RH |
659 | command, you can separate the individual names with either commas or |
660 | blanks. Commas are shown in the explanations below, for clarity. | |
661 | ||
662 | @item | |
663 | @samp{+} is used as a line continuation character; if @samp{+} appears | |
664 | at the end of a line, the text on the following line is considered part | |
665 | of the current command. | |
666 | @end itemize | |
667 | ||
c7c55b78 NC |
668 | Here are the commands you can use in @command{ar} scripts, or when using |
669 | @command{ar} interactively. Three of them have special significance: | |
252b5132 RH |
670 | |
671 | @code{OPEN} or @code{CREATE} specify a @dfn{current archive}, which is | |
672 | a temporary file required for most of the other commands. | |
673 | ||
674 | @code{SAVE} commits the changes so far specified by the script. Prior | |
675 | to @code{SAVE}, commands affect only the temporary copy of the current | |
676 | archive. | |
677 | ||
678 | @table @code | |
c1c0eb9e | 679 | @item ADDLIB @var{archive} |
252b5132 RH |
680 | @itemx ADDLIB @var{archive} (@var{module}, @var{module}, @dots{} @var{module}) |
681 | Add all the contents of @var{archive} (or, if specified, each named | |
682 | @var{module} from @var{archive}) to the current archive. | |
683 | ||
684 | Requires prior use of @code{OPEN} or @code{CREATE}. | |
685 | ||
686 | @item ADDMOD @var{member}, @var{member}, @dots{} @var{member} | |
687 | @c FIXME! w/Replacement?? If so, like "ar r @var{archive} @var{names}" | |
688 | @c else like "ar q..." | |
689 | Add each named @var{member} as a module in the current archive. | |
690 | ||
691 | Requires prior use of @code{OPEN} or @code{CREATE}. | |
692 | ||
693 | @item CLEAR | |
694 | Discard the contents of the current archive, canceling the effect of | |
695 | any operations since the last @code{SAVE}. May be executed (with no | |
696 | effect) even if no current archive is specified. | |
697 | ||
698 | @item CREATE @var{archive} | |
699 | Creates an archive, and makes it the current archive (required for many | |
700 | other commands). The new archive is created with a temporary name; it | |
701 | is not actually saved as @var{archive} until you use @code{SAVE}. | |
702 | You can overwrite existing archives; similarly, the contents of any | |
703 | existing file named @var{archive} will not be destroyed until @code{SAVE}. | |
704 | ||
705 | @item DELETE @var{module}, @var{module}, @dots{} @var{module} | |
706 | Delete each listed @var{module} from the current archive; equivalent to | |
707 | @samp{ar -d @var{archive} @var{module} @dots{} @var{module}}. | |
708 | ||
709 | Requires prior use of @code{OPEN} or @code{CREATE}. | |
710 | ||
711 | @item DIRECTORY @var{archive} (@var{module}, @dots{} @var{module}) | |
712 | @itemx DIRECTORY @var{archive} (@var{module}, @dots{} @var{module}) @var{outputfile} | |
713 | List each named @var{module} present in @var{archive}. The separate | |
714 | command @code{VERBOSE} specifies the form of the output: when verbose | |
715 | output is off, output is like that of @samp{ar -t @var{archive} | |
716 | @var{module}@dots{}}. When verbose output is on, the listing is like | |
717 | @samp{ar -tv @var{archive} @var{module}@dots{}}. | |
718 | ||
719 | Output normally goes to the standard output stream; however, if you | |
c7c55b78 | 720 | specify @var{outputfile} as a final argument, @command{ar} directs the |
252b5132 RH |
721 | output to that file. |
722 | ||
723 | @item END | |
c7c55b78 | 724 | Exit from @command{ar}, with a @code{0} exit code to indicate successful |
252b5132 RH |
725 | completion. This command does not save the output file; if you have |
726 | changed the current archive since the last @code{SAVE} command, those | |
727 | changes are lost. | |
728 | ||
729 | @item EXTRACT @var{module}, @var{module}, @dots{} @var{module} | |
730 | Extract each named @var{module} from the current archive, writing them | |
731 | into the current directory as separate files. Equivalent to @samp{ar -x | |
732 | @var{archive} @var{module}@dots{}}. | |
733 | ||
734 | Requires prior use of @code{OPEN} or @code{CREATE}. | |
735 | ||
736 | @ignore | |
737 | @c FIXME Tokens but no commands??? | |
738 | @item FULLDIR | |
739 | ||
740 | @item HELP | |
741 | @end ignore | |
742 | ||
743 | @item LIST | |
744 | Display full contents of the current archive, in ``verbose'' style | |
745 | regardless of the state of @code{VERBOSE}. The effect is like @samp{ar | |
c7c55b78 | 746 | tv @var{archive}}. (This single command is a @sc{gnu} @command{ar} |
252b5132 RH |
747 | enhancement, rather than present for MRI compatibility.) |
748 | ||
749 | Requires prior use of @code{OPEN} or @code{CREATE}. | |
750 | ||
751 | @item OPEN @var{archive} | |
752 | Opens an existing archive for use as the current archive (required for | |
753 | many other commands). Any changes as the result of subsequent commands | |
754 | will not actually affect @var{archive} until you next use @code{SAVE}. | |
755 | ||
756 | @item REPLACE @var{module}, @var{module}, @dots{} @var{module} | |
757 | In the current archive, replace each existing @var{module} (named in | |
758 | the @code{REPLACE} arguments) from files in the current working directory. | |
759 | To execute this command without errors, both the file, and the module in | |
c1c0eb9e | 760 | the current archive, must exist. |
252b5132 RH |
761 | |
762 | Requires prior use of @code{OPEN} or @code{CREATE}. | |
763 | ||
764 | @item VERBOSE | |
765 | Toggle an internal flag governing the output from @code{DIRECTORY}. | |
766 | When the flag is on, @code{DIRECTORY} output matches output from | |
767 | @samp{ar -tv }@dots{}. | |
768 | ||
769 | @item SAVE | |
770 | Commit your changes to the current archive, and actually save it as a | |
771 | file with the name specified in the last @code{CREATE} or @code{OPEN} | |
c1c0eb9e | 772 | command. |
252b5132 RH |
773 | |
774 | Requires prior use of @code{OPEN} or @code{CREATE}. | |
775 | ||
776 | @end table | |
777 | ||
778 | @iftex | |
779 | @node ld | |
780 | @chapter ld | |
781 | @cindex linker | |
782 | @kindex ld | |
c7c55b78 | 783 | The @sc{gnu} linker @command{ld} is now described in a separate manual. |
252b5132 RH |
784 | @xref{Top,, Overview,, Using LD: the @sc{gnu} linker}. |
785 | @end iftex | |
786 | ||
787 | @node nm | |
788 | @chapter nm | |
789 | @cindex symbols | |
790 | @kindex nm | |
791 | ||
0285c67d NC |
792 | @c man title nm list symbols from object files |
793 | ||
252b5132 | 794 | @smallexample |
0285c67d | 795 | @c man begin SYNOPSIS nm |
1996d0f1 NC |
796 | nm [@option{-A}|@option{-o}|@option{--print-file-name}] |
797 | [@option{-a}|@option{--debug-syms}] | |
798 | [@option{-B}|@option{--format=bsd}] | |
799 | [@option{-C}|@option{--demangle}[=@var{style}]] | |
800 | [@option{-D}|@option{--dynamic}] | |
801 | [@option{-f}@var{format}|@option{--format=}@var{format}] | |
802 | [@option{-g}|@option{--extern-only}] | |
803 | [@option{-h}|@option{--help}] | |
e6f6aa8d | 804 | [@option{--ifunc-chars=@var{CHARS}}] |
1996d0f1 | 805 | [@option{-j}|@option{--format=just-symbols}] |
4a14e306 AK |
806 | [@option{-l}|@option{--line-numbers}] [@option{--inlines}] |
807 | [@option{-n}|@option{-v}|@option{--numeric-sort}] | |
1996d0f1 NC |
808 | [@option{-P}|@option{--portability}] |
809 | [@option{-p}|@option{--no-sort}] | |
810 | [@option{-r}|@option{--reverse-sort}] | |
811 | [@option{-S}|@option{--print-size}] | |
812 | [@option{-s}|@option{--print-armap}] | |
813 | [@option{-t} @var{radix}|@option{--radix=}@var{radix}] | |
814 | [@option{-u}|@option{--undefined-only}] | |
b3aa80b4 | 815 | [@option{-U} @var{method}] [@option{--unicode=}@var{method}] |
1996d0f1 NC |
816 | [@option{-V}|@option{--version}] |
817 | [@option{-X 32_64}] | |
818 | [@option{--defined-only}] | |
819 | [@option{--no-demangle}] | |
af03af8f | 820 | [@option{--no-recurse-limit}|@option{--recurse-limit}]] |
1996d0f1 NC |
821 | [@option{--plugin} @var{name}] |
822 | [@option{--size-sort}] | |
823 | [@option{--special-syms}] | |
824 | [@option{--synthetic}] | |
825 | [@option{--target=}@var{bfdname}] | |
826 | [@option{--with-symbol-versions}] | |
827 | [@option{--without-symbol-versions}] | |
fa8f3997 | 828 | [@var{objfile}@dots{}] |
0285c67d | 829 | @c man end |
252b5132 RH |
830 | @end smallexample |
831 | ||
0285c67d | 832 | @c man begin DESCRIPTION nm |
c7c55b78 NC |
833 | @sc{gnu} @command{nm} lists the symbols from object files @var{objfile}@dots{}. |
834 | If no object files are listed as arguments, @command{nm} assumes the file | |
252b5132 RH |
835 | @file{a.out}. |
836 | ||
c7c55b78 | 837 | For each symbol, @command{nm} shows: |
252b5132 RH |
838 | |
839 | @itemize @bullet | |
840 | @item | |
841 | The symbol value, in the radix selected by options (see below), or | |
842 | hexadecimal by default. | |
843 | ||
844 | @item | |
845 | The symbol type. At least the following types are used; others are, as | |
846 | well, depending on the object file format. If lowercase, the symbol is | |
0ba0c2b3 NC |
847 | usually local; if uppercase, the symbol is global (external). There |
848 | are however a few lowercase symbols that are shown for special global | |
849 | symbols (@code{u}, @code{v} and @code{w}). | |
252b5132 RH |
850 | |
851 | @c Some more detail on exactly what these symbol types are used for | |
852 | @c would be nice. | |
853 | @table @code | |
854 | @item A | |
855 | The symbol's value is absolute, and will not be changed by further | |
856 | linking. | |
857 | ||
858 | @item B | |
a1039809 | 859 | @itemx b |
fcabedd5 NC |
860 | The symbol is in the BSS data section. This section typically |
861 | contains zero-initialized or uninitialized data, although the exact | |
862 | behavior is system dependent. | |
252b5132 RH |
863 | |
864 | @item C | |
a2ab5831 | 865 | @itemx c |
252b5132 RH |
866 | The symbol is common. Common symbols are uninitialized data. When |
867 | linking, multiple common symbols may appear with the same name. If the | |
868 | symbol is defined anywhere, the common symbols are treated as undefined | |
0285c67d NC |
869 | references. |
870 | @ifclear man | |
871 | For more details on common symbols, see the discussion of | |
252b5132 | 872 | --warn-common in @ref{Options,,Linker options,ld.info,The GNU linker}. |
0879a67a | 873 | @end ifclear |
a2ab5831 NC |
874 | The lower case @var{c} character is used when the symbol is in a |
875 | special section for small commons. | |
252b5132 RH |
876 | |
877 | @item D | |
a1039809 | 878 | @itemx d |
252b5132 RH |
879 | The symbol is in the initialized data section. |
880 | ||
881 | @item G | |
a1039809 | 882 | @itemx g |
252b5132 RH |
883 | The symbol is in an initialized data section for small objects. Some |
884 | object file formats permit more efficient access to small data objects, | |
885 | such as a global int variable as opposed to a large global array. | |
886 | ||
a1039809 | 887 | @item i |
3e7a7d11 | 888 | For PE format files this indicates that the symbol is in a section |
e6f6aa8d NC |
889 | specific to the implementation of DLLs. |
890 | ||
891 | For ELF format files this indicates that the symbol is an indirect | |
892 | function. This is a GNU extension to the standard set of ELF symbol | |
893 | types. It indicates a symbol which if referenced by a relocation does | |
894 | not evaluate to its address, but instead must be invoked at runtime. | |
895 | The runtime execution will then return the value to be used in the | |
896 | relocation. | |
897 | ||
898 | Note - the actual symbols display for GNU indirect symbols is | |
899 | controlled by the @option{--ifunc-chars} command line option. If this | |
900 | option has been provided then the first character in the string will | |
901 | be used for global indirect function symbols. If the string contains | |
902 | a second character then that will be used for local indirect function | |
903 | symbols. | |
a1039809 | 904 | |
021f8a30 NC |
905 | @item I |
906 | The symbol is an indirect reference to another symbol. | |
907 | ||
252b5132 RH |
908 | @item N |
909 | The symbol is a debugging symbol. | |
910 | ||
6ae978f1 NC |
911 | @item n |
912 | The symbol is in the read-only data section. | |
913 | ||
a1039809 | 914 | @item p |
6ae978f1 | 915 | The symbol is in a stack unwind section. |
a1039809 | 916 | |
252b5132 | 917 | @item R |
a1039809 | 918 | @itemx r |
252b5132 RH |
919 | The symbol is in a read only data section. |
920 | ||
921 | @item S | |
a1039809 | 922 | @itemx s |
fcabedd5 NC |
923 | The symbol is in an uninitialized or zero-initialized data section |
924 | for small objects. | |
252b5132 RH |
925 | |
926 | @item T | |
a1039809 | 927 | @itemx t |
252b5132 RH |
928 | The symbol is in the text (code) section. |
929 | ||
930 | @item U | |
931 | The symbol is undefined. | |
932 | ||
3e7a7d11 NC |
933 | @item u |
934 | The symbol is a unique global symbol. This is a GNU extension to the | |
935 | standard set of ELF symbol bindings. For such a symbol the dynamic linker | |
936 | will make sure that in the entire process there is just one symbol with | |
937 | this name and type in use. | |
938 | ||
fad6fcbb | 939 | @item V |
a1039809 | 940 | @itemx v |
fad6fcbb NC |
941 | The symbol is a weak object. When a weak defined symbol is linked with |
942 | a normal defined symbol, the normal defined symbol is used with no error. | |
943 | When a weak undefined symbol is linked and the symbol is not defined, | |
a1039809 NC |
944 | the value of the weak symbol becomes zero with no error. On some |
945 | systems, uppercase indicates that a default value has been specified. | |
fad6fcbb | 946 | |
252b5132 | 947 | @item W |
a1039809 | 948 | @itemx w |
fad6fcbb NC |
949 | The symbol is a weak symbol that has not been specifically tagged as a |
950 | weak object symbol. When a weak defined symbol is linked with a normal | |
951 | defined symbol, the normal defined symbol is used with no error. | |
952 | When a weak undefined symbol is linked and the symbol is not defined, | |
c87db184 | 953 | the value of the symbol is determined in a system-specific manner without |
c1c0eb9e | 954 | error. On some systems, uppercase indicates that a default value has been |
977cdf5a NC |
955 | specified. |
956 | ||
252b5132 RH |
957 | @item - |
958 | The symbol is a stabs symbol in an a.out object file. In this case, the | |
959 | next values printed are the stabs other field, the stabs desc field, and | |
c7c55b78 | 960 | the stab type. Stabs symbols are used to hold debugging information. |
252b5132 RH |
961 | |
962 | @item ? | |
963 | The symbol type is unknown, or object file format specific. | |
964 | @end table | |
965 | ||
966 | @item | |
3f2e9699 L |
967 | The symbol name. If a symbol has version information associated with it, |
968 | then the version information is displayed as well. If the versioned | |
969 | symbol is undefined or hidden from linker, the version string is displayed | |
970 | as a suffix to the symbol name, preceded by an @@ character. For example | |
971 | @samp{foo@@VER_1}. If the version is the default version to be used when | |
972 | resolving unversioned references to the symbol, then it is displayed as a | |
973 | suffix preceded by two @@ characters. For example @samp{foo@@@@VER_2}. | |
252b5132 RH |
974 | @end itemize |
975 | ||
0285c67d NC |
976 | @c man end |
977 | ||
978 | @c man begin OPTIONS nm | |
252b5132 RH |
979 | The long and short forms of options, shown here as alternatives, are |
980 | equivalent. | |
981 | ||
c7c55b78 | 982 | @table @env |
252b5132 RH |
983 | @item -A |
984 | @itemx -o | |
c1c0eb9e | 985 | @itemx --print-file-name |
252b5132 RH |
986 | @cindex input file name |
987 | @cindex file name | |
988 | @cindex source file name | |
f20a759a | 989 | Precede each symbol by the name of the input file (or archive member) |
252b5132 RH |
990 | in which it was found, rather than identifying the input file once only, |
991 | before all of its symbols. | |
992 | ||
993 | @item -a | |
c1c0eb9e | 994 | @itemx --debug-syms |
252b5132 RH |
995 | @cindex debugging symbols |
996 | Display all symbols, even debugger-only symbols; normally these are not | |
997 | listed. | |
998 | ||
999 | @item -B | |
c7c55b78 NC |
1000 | @cindex @command{nm} format |
1001 | @cindex @command{nm} compatibility | |
1002 | The same as @option{--format=bsd} (for compatibility with the MIPS @command{nm}). | |
252b5132 RH |
1003 | |
1004 | @item -C | |
28c309a2 | 1005 | @itemx --demangle[=@var{style}] |
252b5132 RH |
1006 | @cindex demangling in nm |
1007 | Decode (@dfn{demangle}) low-level symbol names into user-level names. | |
1008 | Besides removing any initial underscore prepended by the system, this | |
28c309a2 | 1009 | makes C++ function names readable. Different compilers have different |
c1c0eb9e RM |
1010 | mangling styles. The optional demangling style argument can be used to |
1011 | choose an appropriate demangling style for your compiler. @xref{c++filt}, | |
28c309a2 | 1012 | for more information on demangling. |
252b5132 RH |
1013 | |
1014 | @item --no-demangle | |
1015 | Do not demangle low-level symbol names. This is the default. | |
1016 | ||
af03af8f NC |
1017 | @item --recurse-limit |
1018 | @itemx --no-recurse-limit | |
1019 | @itemx --recursion-limit | |
1020 | @itemx --no-recursion-limit | |
1021 | Enables or disables a limit on the amount of recursion performed | |
1022 | whilst demangling strings. Since the name mangling formats allow for | |
0cc79db2 | 1023 | an infinite level of recursion it is possible to create strings whose |
af03af8f NC |
1024 | decoding will exhaust the amount of stack space available on the host |
1025 | machine, triggering a memory fault. The limit tries to prevent this | |
69799d67 | 1026 | from happening by restricting recursion to 2048 levels of nesting. |
af03af8f NC |
1027 | |
1028 | The default is for this limit to be enabled, but disabling it may be | |
1029 | necessary in order to demangle truly complicated names. Note however | |
1030 | that if the recursion limit is disabled then stack exhaustion is | |
1031 | possible and any bug reports about such an event will be rejected. | |
1032 | ||
252b5132 RH |
1033 | @item -D |
1034 | @itemx --dynamic | |
1035 | @cindex dynamic symbols | |
1036 | Display the dynamic symbols rather than the normal symbols. This is | |
1037 | only meaningful for dynamic objects, such as certain types of shared | |
1038 | libraries. | |
1039 | ||
1040 | @item -f @var{format} | |
1041 | @itemx --format=@var{format} | |
c7c55b78 NC |
1042 | @cindex @command{nm} format |
1043 | @cindex @command{nm} compatibility | |
252b5132 | 1044 | Use the output format @var{format}, which can be @code{bsd}, |
1996d0f1 | 1045 | @code{sysv}, @code{posix} or @code{just-symbols}. The default is @code{bsd}. |
252b5132 RH |
1046 | Only the first character of @var{format} is significant; it can be |
1047 | either upper or lower case. | |
1048 | ||
1049 | @item -g | |
c1c0eb9e | 1050 | @itemx --extern-only |
252b5132 RH |
1051 | @cindex external symbols |
1052 | Display only external symbols. | |
1053 | ||
fa8f3997 NC |
1054 | @item -h |
1055 | @itemx --help | |
1056 | Show a summary of the options to @command{nm} and exit. | |
ce3c775b | 1057 | |
e6f6aa8d NC |
1058 | @item --ifunc-chars=@var{CHARS} |
1059 | When display GNU indirect function symbols @command{nm} will default | |
1060 | to using the @code{i} character for both local indirect functions and | |
1061 | global indirect functions. The @option{--ifunc-chars} option allows | |
1062 | the user to specify a string containing one or two characters. The | |
1063 | first character will be used for global indirect function symbols and | |
1064 | the second character, if present, will be used for local indirect | |
1065 | function symbols. | |
1066 | ||
1996d0f1 NC |
1067 | @item j |
1068 | The same as @option{--format=just-symbols}. | |
1069 | ||
252b5132 RH |
1070 | @item -l |
1071 | @itemx --line-numbers | |
1072 | @cindex symbol line numbers | |
1073 | For each symbol, use debugging information to try to find a filename and | |
1074 | line number. For a defined symbol, look for the line number of the | |
1075 | address of the symbol. For an undefined symbol, look for the line | |
1076 | number of a relocation entry which refers to the symbol. If line number | |
1077 | information can be found, print it after the other symbol information. | |
1078 | ||
4a14e306 AK |
1079 | @item --inlines |
1080 | @cindex objdump inlines | |
1081 | When option @option{-l} is active, if the address belongs to a | |
1082 | function that was inlined, then this option causes the source | |
1083 | information for all enclosing scopes back to the first non-inlined | |
1084 | function to be printed as well. For example, if @code{main} inlines | |
1085 | @code{callee1} which inlines @code{callee2}, and address is from | |
1086 | @code{callee2}, the source information for @code{callee1} and @code{main} | |
1087 | will also be printed. | |
1088 | ||
252b5132 RH |
1089 | @item -n |
1090 | @itemx -v | |
c1c0eb9e | 1091 | @itemx --numeric-sort |
252b5132 | 1092 | Sort symbols numerically by their addresses, rather than alphabetically |
c1c0eb9e | 1093 | by their names. |
252b5132 RH |
1094 | |
1095 | @item -p | |
c1c0eb9e | 1096 | @itemx --no-sort |
252b5132 RH |
1097 | @cindex sorting symbols |
1098 | Do not bother to sort the symbols in any order; print them in the order | |
1099 | encountered. | |
1100 | ||
1101 | @item -P | |
1102 | @itemx --portability | |
1103 | Use the POSIX.2 standard output format instead of the default format. | |
1104 | Equivalent to @samp{-f posix}. | |
1105 | ||
fa8f3997 NC |
1106 | @item -r |
1107 | @itemx --reverse-sort | |
1108 | Reverse the order of the sort (whether numeric or alphabetic); let the | |
1109 | last come first. | |
1110 | ||
72797995 L |
1111 | @item -S |
1112 | @itemx --print-size | |
1533edfb AM |
1113 | Print both value and size of defined symbols for the @code{bsd} output style. |
1114 | This option has no effect for object formats that do not record symbol | |
1115 | sizes, unless @samp{--size-sort} is also used in which case a | |
1116 | calculated size is displayed. | |
72797995 | 1117 | |
252b5132 RH |
1118 | @item -s |
1119 | @itemx --print-armap | |
1120 | @cindex symbol index, listing | |
1121 | When listing symbols from archive members, include the index: a mapping | |
c7c55b78 | 1122 | (stored in the archive by @command{ar} or @command{ranlib}) of which modules |
252b5132 RH |
1123 | contain definitions for which names. |
1124 | ||
fa8f3997 NC |
1125 | @item -t @var{radix} |
1126 | @itemx --radix=@var{radix} | |
1127 | Use @var{radix} as the radix for printing the symbol values. It must be | |
1128 | @samp{d} for decimal, @samp{o} for octal, or @samp{x} for hexadecimal. | |
1129 | ||
1130 | @item -u | |
1131 | @itemx --undefined-only | |
1132 | @cindex external symbols | |
1133 | @cindex undefined symbols | |
1134 | Display only undefined symbols (those external to each object file). | |
1135 | ||
b3aa80b4 NC |
1136 | @item -U @var{[d|i|l|e|x|h]} |
1137 | @itemx --unicode=@var{[default|invalid|locale|escape|hex|highlight]} | |
1138 | Controls the display of UTF-8 encoded mulibyte characters in strings. | |
1139 | The default (@option{--unicode=default}) is to give them no special | |
1140 | treatment. The @option{--unicode=locale} option displays the sequence | |
1141 | in the current locale, which may or may not support them. The options | |
1142 | @option{--unicode=hex} and @option{--unicode=invalid} display them as | |
1143 | hex byte sequences enclosed by either angle brackets or curly braces. | |
1144 | ||
1145 | The @option{--unicode=escape} option displays them as escape sequences | |
1146 | (@var{\uxxxx}) and the @option{--unicode=highlight} option displays | |
1147 | them as escape sequences highlighted in red (if supported by the | |
1148 | output device). The colouring is intended to draw attention to the | |
1149 | presence of unicode sequences where they might not be expected. | |
1150 | ||
fa8f3997 NC |
1151 | @item -V |
1152 | @itemx --version | |
1153 | Show the version number of @command{nm} and exit. | |
1154 | ||
1155 | @item -X | |
1156 | This option is ignored for compatibility with the AIX version of | |
1157 | @command{nm}. It takes one parameter which must be the string | |
1158 | @option{32_64}. The default mode of AIX @command{nm} corresponds | |
1159 | to @option{-X 32}, which is not supported by @sc{gnu} @command{nm}. | |
1160 | ||
1161 | @item --defined-only | |
1162 | @cindex external symbols | |
1163 | @cindex undefined symbols | |
1164 | Display only defined symbols for each object file. | |
1165 | ||
1166 | @item --plugin @var{name} | |
387dd777 | 1167 | @cindex plugins |
fa8f3997 NC |
1168 | Load the plugin called @var{name} to add support for extra target |
1169 | types. This option is only available if the toolchain has been built | |
1170 | with plugin support enabled. | |
252b5132 | 1171 | |
387dd777 DP |
1172 | If @option{--plugin} is not provided, but plugin support has been |
1173 | enabled then @command{nm} iterates over the files in | |
1174 | @file{$@{libdir@}/bfd-plugins} in alphabetic order and the first | |
1175 | plugin that claims the object in question is used. | |
1176 | ||
1177 | Please note that this plugin search directory is @emph{not} the one | |
1178 | used by @command{ld}'s @option{-plugin} option. In order to make | |
1179 | @command{nm} use the linker plugin it must be copied into the | |
1180 | @file{$@{libdir@}/bfd-plugins} directory. For GCC based compilations | |
1181 | the linker plugin is called @file{liblto_plugin.so.0.0.0}. For Clang | |
1182 | based compilations it is called @file{LLVMgold.so}. The GCC plugin | |
1183 | is always backwards compatible with earlier versions, so it is | |
1184 | sufficient to just copy the newest one. | |
1185 | ||
252b5132 | 1186 | @item --size-sort |
29f4fdc4 AB |
1187 | Sort symbols by size. For ELF objects symbol sizes are read from the |
1188 | ELF, for other object types the symbol sizes are computed as the | |
1189 | difference between the value of the symbol and the value of the symbol | |
1190 | with the next higher value. If the @code{bsd} output format is used | |
1191 | the size of the symbol is printed, rather than the value, and | |
1192 | @samp{-S} must be used in order both size and value to be printed. | |
252b5132 | 1193 | |
3c9458e9 NC |
1194 | @item --special-syms |
1195 | Display symbols which have a target-specific special meaning. These | |
1196 | symbols are usually used by the target for some special processing and | |
a575c958 NC |
1197 | are not normally helpful when included in the normal symbol lists. |
1198 | For example for ARM targets this option would skip the mapping symbols | |
1199 | used to mark transitions between ARM code, THUMB code and data. | |
3c9458e9 | 1200 | |
fa8f3997 NC |
1201 | @item --synthetic |
1202 | Include synthetic symbols in the output. These are special symbols | |
1203 | created by the linker for various purposes. They are not shown by | |
1204 | default since they are not part of the binary's original source code. | |
252b5132 | 1205 | |
6a1224ec AM |
1206 | @item --with-symbol-versions |
1207 | @item --without-symbol-versions | |
1208 | Enables or disables the display of symbol version information. The | |
1209 | version string is displayed as a suffix to the symbol name, preceded | |
1210 | by an @@ character. For example @samp{foo@@VER_1}. If the version is | |
1211 | the default version to be used when resolving unversioned references | |
1212 | to the symbol then it is displayed as a suffix preceded by two @@ | |
1213 | characters. For example @samp{foo@@@@VER_2}. By default, symbol | |
1214 | version information is displayed. | |
1215 | ||
252b5132 RH |
1216 | @item --target=@var{bfdname} |
1217 | @cindex object code format | |
1218 | Specify an object code format other than your system's default format. | |
1219 | @xref{Target Selection}, for more information. | |
1220 | ||
252b5132 RH |
1221 | @end table |
1222 | ||
0285c67d NC |
1223 | @c man end |
1224 | ||
1225 | @ignore | |
1226 | @c man begin SEEALSO nm | |
1227 | ar(1), objdump(1), ranlib(1), and the Info entries for @file{binutils}. | |
1228 | @c man end | |
1229 | @end ignore | |
1230 | ||
252b5132 RH |
1231 | @node objcopy |
1232 | @chapter objcopy | |
1233 | ||
0285c67d NC |
1234 | @c man title objcopy copy and translate object files |
1235 | ||
252b5132 | 1236 | @smallexample |
0285c67d | 1237 | @c man begin SYNOPSIS objcopy |
c7c55b78 NC |
1238 | objcopy [@option{-F} @var{bfdname}|@option{--target=}@var{bfdname}] |
1239 | [@option{-I} @var{bfdname}|@option{--input-target=}@var{bfdname}] | |
1240 | [@option{-O} @var{bfdname}|@option{--output-target=}@var{bfdname}] | |
1241 | [@option{-B} @var{bfdarch}|@option{--binary-architecture=}@var{bfdarch}] | |
2593f09a NC |
1242 | [@option{-S}|@option{--strip-all}] |
1243 | [@option{-g}|@option{--strip-debug}] | |
0fbdde94 | 1244 | [@option{--strip-unneeded}] |
c7c55b78 | 1245 | [@option{-K} @var{symbolname}|@option{--keep-symbol=}@var{symbolname}] |
ca0e11aa NC |
1246 | [@option{--keep-file-symbols}] |
1247 | [@option{--keep-section-symbols}] | |
c7c55b78 | 1248 | [@option{-N} @var{symbolname}|@option{--strip-symbol=}@var{symbolname}] |
bcf32829 | 1249 | [@option{--strip-unneeded-symbol=}@var{symbolname}] |
c7c55b78 | 1250 | [@option{-G} @var{symbolname}|@option{--keep-global-symbol=}@var{symbolname}] |
d58c2e3a | 1251 | [@option{--localize-hidden}] |
c7c55b78 | 1252 | [@option{-L} @var{symbolname}|@option{--localize-symbol=}@var{symbolname}] |
7b4a0685 | 1253 | [@option{--globalize-symbol=}@var{symbolname}] |
de564eb5 | 1254 | [@option{--globalize-symbols=}@var{filename}] |
c7c55b78 | 1255 | [@option{-W} @var{symbolname}|@option{--weaken-symbol=}@var{symbolname}] |
5fe11841 | 1256 | [@option{-w}|@option{--wildcard}] |
2593f09a NC |
1257 | [@option{-x}|@option{--discard-all}] |
1258 | [@option{-X}|@option{--discard-locals}] | |
c7c55b78 | 1259 | [@option{-b} @var{byte}|@option{--byte=}@var{byte}] |
b7dd81f7 NC |
1260 | [@option{-i} [@var{breadth}]|@option{--interleave}[=@var{breadth}]] |
1261 | [@option{--interleave-width=}@var{width}] | |
2e62b721 NC |
1262 | [@option{-j} @var{sectionpattern}|@option{--only-section=}@var{sectionpattern}] |
1263 | [@option{-R} @var{sectionpattern}|@option{--remove-section=}@var{sectionpattern}] | |
64f52b3e | 1264 | [@option{--keep-section=}@var{sectionpattern}] |
d3e5f6c8 | 1265 | [@option{--remove-relocations=}@var{sectionpattern}] |
c7c55b78 | 1266 | [@option{-p}|@option{--preserve-dates}] |
2e30cb57 | 1267 | [@option{-D}|@option{--enable-deterministic-archives}] |
955d0b3b | 1268 | [@option{-U}|@option{--disable-deterministic-archives}] |
c7c55b78 | 1269 | [@option{--debugging}] |
2593f09a NC |
1270 | [@option{--gap-fill=}@var{val}] |
1271 | [@option{--pad-to=}@var{address}] | |
1272 | [@option{--set-start=}@var{val}] | |
1273 | [@option{--adjust-start=}@var{incr}] | |
c7c55b78 | 1274 | [@option{--change-addresses=}@var{incr}] |
2e62b721 NC |
1275 | [@option{--change-section-address} @var{sectionpattern}@{=,+,-@}@var{val}] |
1276 | [@option{--change-section-lma} @var{sectionpattern}@{=,+,-@}@var{val}] | |
1277 | [@option{--change-section-vma} @var{sectionpattern}@{=,+,-@}@var{val}] | |
c7c55b78 | 1278 | [@option{--change-warnings}] [@option{--no-change-warnings}] |
2e62b721 | 1279 | [@option{--set-section-flags} @var{sectionpattern}=@var{flags}] |
fa463e9f | 1280 | [@option{--set-section-alignment} @var{sectionpattern}=@var{align}] |
c7c55b78 | 1281 | [@option{--add-section} @var{sectionname}=@var{filename}] |
bbad633b | 1282 | [@option{--dump-section} @var{sectionname}=@var{filename}] |
acf1419f | 1283 | [@option{--update-section} @var{sectionname}=@var{filename}] |
c7c55b78 | 1284 | [@option{--rename-section} @var{oldname}=@var{newname}[,@var{flags}]] |
0408dee6 | 1285 | [@option{--long-section-names} @{enable,disable,keep@}] |
2593f09a | 1286 | [@option{--change-leading-char}] [@option{--remove-leading-char}] |
9e48b4c6 | 1287 | [@option{--reverse-bytes=}@var{num}] |
2593f09a NC |
1288 | [@option{--srec-len=}@var{ival}] [@option{--srec-forceS3}] |
1289 | [@option{--redefine-sym} @var{old}=@var{new}] | |
1290 | [@option{--redefine-syms=}@var{filename}] | |
c7c55b78 NC |
1291 | [@option{--weaken}] |
1292 | [@option{--keep-symbols=}@var{filename}] | |
1293 | [@option{--strip-symbols=}@var{filename}] | |
bcf32829 | 1294 | [@option{--strip-unneeded-symbols=}@var{filename}] |
c7c55b78 NC |
1295 | [@option{--keep-global-symbols=}@var{filename}] |
1296 | [@option{--localize-symbols=}@var{filename}] | |
1297 | [@option{--weaken-symbols=}@var{filename}] | |
b0ab9c45 | 1298 | [@option{--add-symbol} @var{name}=[@var{section}:]@var{value}[,@var{flags}]] |
c51238bc DA |
1299 | [@option{--alt-machine-code=}@var{index}] |
1300 | [@option{--prefix-symbols=}@var{string}] | |
1301 | [@option{--prefix-sections=}@var{string}] | |
1302 | [@option{--prefix-alloc-sections=}@var{string}] | |
ed1653a7 NC |
1303 | [@option{--add-gnu-debuglink=}@var{path-to-file}] |
1304 | [@option{--only-keep-debug}] | |
96109726 CC |
1305 | [@option{--strip-dwo}] |
1306 | [@option{--extract-dwo}] | |
d3e52d40 | 1307 | [@option{--extract-symbol}] |
4087920c MR |
1308 | [@option{--writable-text}] |
1309 | [@option{--readonly-text}] | |
1310 | [@option{--pure}] | |
1311 | [@option{--impure}] | |
92dd4511 L |
1312 | [@option{--file-alignment=}@var{num}] |
1313 | [@option{--heap=}@var{size}] | |
1314 | [@option{--image-base=}@var{address}] | |
1315 | [@option{--section-alignment=}@var{num}] | |
1316 | [@option{--stack=}@var{size}] | |
1317 | [@option{--subsystem=}@var{which}:@var{major}.@var{minor}] | |
4a114e3e L |
1318 | [@option{--compress-debug-sections}] |
1319 | [@option{--decompress-debug-sections}] | |
b8871f35 | 1320 | [@option{--elf-stt-common=@var{val}}] |
9ef920e9 | 1321 | [@option{--merge-notes}] |
1d15e434 | 1322 | [@option{--no-merge-notes}] |
37d0d091 | 1323 | [@option{--verilog-data-width=@var{val}}] |
c7c55b78 | 1324 | [@option{-v}|@option{--verbose}] |
c1c0eb9e | 1325 | [@option{-V}|@option{--version}] |
7c29036b | 1326 | [@option{--help}] [@option{--info}] |
252b5132 | 1327 | @var{infile} [@var{outfile}] |
0285c67d | 1328 | @c man end |
252b5132 RH |
1329 | @end smallexample |
1330 | ||
0285c67d | 1331 | @c man begin DESCRIPTION objcopy |
c7c55b78 NC |
1332 | The @sc{gnu} @command{objcopy} utility copies the contents of an object |
1333 | file to another. @command{objcopy} uses the @sc{gnu} @sc{bfd} Library to | |
252b5132 RH |
1334 | read and write the object files. It can write the destination object |
1335 | file in a format different from that of the source object file. The | |
c7c55b78 NC |
1336 | exact behavior of @command{objcopy} is controlled by command-line options. |
1337 | Note that @command{objcopy} should be able to copy a fully linked file | |
ccd13d18 L |
1338 | between any two formats. However, copying a relocatable object file |
1339 | between any two formats may not work as expected. | |
252b5132 | 1340 | |
c7c55b78 NC |
1341 | @command{objcopy} creates temporary files to do its translations and |
1342 | deletes them afterward. @command{objcopy} uses @sc{bfd} to do all its | |
252b5132 RH |
1343 | translation work; it has access to all the formats described in @sc{bfd} |
1344 | and thus is able to recognize most formats without being told | |
1345 | explicitly. @xref{BFD,,BFD,ld.info,Using LD}. | |
1346 | ||
c7c55b78 | 1347 | @command{objcopy} can be used to generate S-records by using an output |
252b5132 RH |
1348 | target of @samp{srec} (e.g., use @samp{-O srec}). |
1349 | ||
c7c55b78 NC |
1350 | @command{objcopy} can be used to generate a raw binary file by using an |
1351 | output target of @samp{binary} (e.g., use @option{-O binary}). When | |
1352 | @command{objcopy} generates a raw binary file, it will essentially produce | |
252b5132 RH |
1353 | a memory dump of the contents of the input object file. All symbols and |
1354 | relocation information will be discarded. The memory dump will start at | |
1355 | the load address of the lowest section copied into the output file. | |
1356 | ||
1357 | When generating an S-record or a raw binary file, it may be helpful to | |
c7c55b78 NC |
1358 | use @option{-S} to remove sections containing debugging information. In |
1359 | some cases @option{-R} will be useful to remove sections which contain | |
f20a759a | 1360 | information that is not needed by the binary file. |
252b5132 | 1361 | |
947ed062 NC |
1362 | Note---@command{objcopy} is not able to change the endianness of its input |
1363 | files. If the input format has an endianness (some formats do not), | |
c7c55b78 | 1364 | @command{objcopy} can only copy the inputs into file formats that have the |
947ed062 | 1365 | same endianness or which have no endianness (e.g., @samp{srec}). |
9e48b4c6 | 1366 | (However, see the @option{--reverse-bytes} option.) |
18356cf2 | 1367 | |
0285c67d NC |
1368 | @c man end |
1369 | ||
1370 | @c man begin OPTIONS objcopy | |
1371 | ||
c7c55b78 | 1372 | @table @env |
252b5132 RH |
1373 | @item @var{infile} |
1374 | @itemx @var{outfile} | |
f20a759a | 1375 | The input and output files, respectively. |
c7c55b78 | 1376 | If you do not specify @var{outfile}, @command{objcopy} creates a |
252b5132 RH |
1377 | temporary file and destructively renames the result with |
1378 | the name of @var{infile}. | |
1379 | ||
c7c55b78 | 1380 | @item -I @var{bfdname} |
252b5132 RH |
1381 | @itemx --input-target=@var{bfdname} |
1382 | Consider the source file's object format to be @var{bfdname}, rather than | |
1383 | attempting to deduce it. @xref{Target Selection}, for more information. | |
1384 | ||
1385 | @item -O @var{bfdname} | |
1386 | @itemx --output-target=@var{bfdname} | |
1387 | Write the output file using the object format @var{bfdname}. | |
1388 | @xref{Target Selection}, for more information. | |
1389 | ||
1390 | @item -F @var{bfdname} | |
1391 | @itemx --target=@var{bfdname} | |
1392 | Use @var{bfdname} as the object format for both the input and the output | |
1393 | file; i.e., simply transfer data from source to destination with no | |
1394 | translation. @xref{Target Selection}, for more information. | |
1395 | ||
43a0748c NC |
1396 | @item -B @var{bfdarch} |
1397 | @itemx --binary-architecture=@var{bfdarch} | |
8b31b6c4 NC |
1398 | Useful when transforming a architecture-less input file into an object file. |
1399 | In this case the output architecture can be set to @var{bfdarch}. This | |
1400 | option will be ignored if the input file has a known @var{bfdarch}. You | |
43a0748c NC |
1401 | can access this binary data inside a program by referencing the special |
1402 | symbols that are created by the conversion process. These symbols are | |
1403 | called _binary_@var{objfile}_start, _binary_@var{objfile}_end and | |
1404 | _binary_@var{objfile}_size. e.g. you can transform a picture file into | |
c1c0eb9e | 1405 | an object file and then access it in your code using these symbols. |
43a0748c | 1406 | |
2e62b721 NC |
1407 | @item -j @var{sectionpattern} |
1408 | @itemx --only-section=@var{sectionpattern} | |
1409 | Copy only the indicated sections from the input file to the output file. | |
f91ea849 | 1410 | This option may be given more than once. Note that using this option |
2e62b721 NC |
1411 | inappropriately may make the output file unusable. Wildcard |
1412 | characters are accepted in @var{sectionpattern}. | |
f91ea849 | 1413 | |
e511c9b1 AB |
1414 | If the first character of @var{sectionpattern} is the exclamation |
1415 | point (!) then matching sections will not be copied, even if earlier | |
1416 | use of @option{--only-section} on the same command line would | |
1417 | otherwise copy it. For example: | |
1418 | ||
1419 | @smallexample | |
1420 | --only-section=.text.* --only-section=!.text.foo | |
1421 | @end smallexample | |
1422 | ||
0cc79db2 | 1423 | will copy all sectinos matching '.text.*' but not the section |
e511c9b1 AB |
1424 | '.text.foo'. |
1425 | ||
2e62b721 NC |
1426 | @item -R @var{sectionpattern} |
1427 | @itemx --remove-section=@var{sectionpattern} | |
1428 | Remove any section matching @var{sectionpattern} from the output file. | |
1429 | This option may be given more than once. Note that using this option | |
1430 | inappropriately may make the output file unusable. Wildcard | |
1431 | characters are accepted in @var{sectionpattern}. Using both the | |
1432 | @option{-j} and @option{-R} options together results in undefined | |
1433 | behaviour. | |
252b5132 | 1434 | |
e511c9b1 AB |
1435 | If the first character of @var{sectionpattern} is the exclamation |
1436 | point (!) then matching sections will not be removed even if an | |
1437 | earlier use of @option{--remove-section} on the same command line | |
1438 | would otherwise remove it. For example: | |
1439 | ||
1440 | @smallexample | |
1441 | --remove-section=.text.* --remove-section=!.text.foo | |
1442 | @end smallexample | |
1443 | ||
1444 | will remove all sections matching the pattern '.text.*', but will not | |
1445 | remove the section '.text.foo'. | |
1446 | ||
64f52b3e FS |
1447 | @item --keep-section=@var{sectionpattern} |
1448 | When removing sections from the output file, keep sections that match | |
1449 | @var{sectionpattern}. | |
1450 | ||
d3e5f6c8 | 1451 | @item --remove-relocations=@var{sectionpattern} |
f9853190 AM |
1452 | Remove non-dynamic relocations from the output file for any section |
1453 | matching @var{sectionpattern}. This option may be given more than | |
1454 | once. Note that using this option inappropriately may make the output | |
1455 | file unusable, and attempting to remove a dynamic relocation section | |
1456 | such as @samp{.rela.plt} from an executable or shared library with | |
1457 | @option{--remove-relocations=.plt} will not work. Wildcard characters | |
1458 | are accepted in @var{sectionpattern}. | |
d3e5f6c8 AB |
1459 | For example: |
1460 | ||
1461 | @smallexample | |
1462 | --remove-relocations=.text.* | |
1463 | @end smallexample | |
1464 | ||
f9853190 | 1465 | will remove the relocations for all sections matching the pattern |
d3e5f6c8 AB |
1466 | '.text.*'. |
1467 | ||
1468 | If the first character of @var{sectionpattern} is the exclamation | |
1469 | point (!) then matching sections will not have their relocation | |
1470 | removed even if an earlier use of @option{--remove-relocations} on the | |
1471 | same command line would otherwise cause the relocations to be removed. | |
1472 | For example: | |
1473 | ||
1474 | @smallexample | |
1475 | --remove-relocations=.text.* --remove-relocations=!.text.foo | |
1476 | @end smallexample | |
1477 | ||
1478 | will remove all relocations for sections matching the pattern | |
1479 | '.text.*', but will not remove relocations for the section | |
1480 | '.text.foo'. | |
1481 | ||
252b5132 RH |
1482 | @item -S |
1483 | @itemx --strip-all | |
1484 | Do not copy relocation and symbol information from the source file. | |
427234c7 | 1485 | Also deletes debug sections. |
252b5132 RH |
1486 | |
1487 | @item -g | |
1488 | @itemx --strip-debug | |
2593f09a | 1489 | Do not copy debugging symbols or sections from the source file. |
252b5132 RH |
1490 | |
1491 | @item --strip-unneeded | |
427234c7 LC |
1492 | Remove all symbols that are not needed for relocation processing in |
1493 | addition to debugging symbols and sections stripped by | |
1494 | @option{--strip-debug}. | |
252b5132 RH |
1495 | |
1496 | @item -K @var{symbolname} | |
1497 | @itemx --keep-symbol=@var{symbolname} | |
e7f918ad NC |
1498 | When stripping symbols, keep symbol @var{symbolname} even if it would |
1499 | normally be stripped. This option may be given more than once. | |
252b5132 RH |
1500 | |
1501 | @item -N @var{symbolname} | |
1502 | @itemx --strip-symbol=@var{symbolname} | |
1503 | Do not copy symbol @var{symbolname} from the source file. This option | |
1504 | may be given more than once. | |
1505 | ||
bcf32829 JB |
1506 | @item --strip-unneeded-symbol=@var{symbolname} |
1507 | Do not copy symbol @var{symbolname} from the source file unless it is needed | |
1508 | by a relocation. This option may be given more than once. | |
1509 | ||
16b2b71c NC |
1510 | @item -G @var{symbolname} |
1511 | @itemx --keep-global-symbol=@var{symbolname} | |
1512 | Keep only symbol @var{symbolname} global. Make all other symbols local | |
1513 | to the file, so that they are not visible externally. This option may | |
de564eb5 NC |
1514 | be given more than once. Note: this option cannot be used in |
1515 | conjunction with the @option{--globalize-symbol} or | |
1516 | @option{--globalize-symbols} options. | |
16b2b71c | 1517 | |
d58c2e3a RS |
1518 | @item --localize-hidden |
1519 | In an ELF object, mark all symbols that have hidden or internal visibility | |
1520 | as local. This option applies on top of symbol-specific localization options | |
1521 | such as @option{-L}. | |
1522 | ||
252b5132 RH |
1523 | @item -L @var{symbolname} |
1524 | @itemx --localize-symbol=@var{symbolname} | |
f2629855 NC |
1525 | Convert a global or weak symbol called @var{symbolname} into a local |
1526 | symbol, so that it is not visible externally. This option may be | |
1527 | given more than once. Note - unique symbols are not converted. | |
252b5132 RH |
1528 | |
1529 | @item -W @var{symbolname} | |
1530 | @itemx --weaken-symbol=@var{symbolname} | |
1531 | Make symbol @var{symbolname} weak. This option may be given more than once. | |
1532 | ||
7b4a0685 NC |
1533 | @item --globalize-symbol=@var{symbolname} |
1534 | Give symbol @var{symbolname} global scoping so that it is visible | |
1535 | outside of the file in which it is defined. This option may be given | |
de564eb5 NC |
1536 | more than once. Note: this option cannot be used in conjunction with |
1537 | the @option{-G} or @option{--keep-global-symbol} options. | |
7b4a0685 | 1538 | |
5fe11841 NC |
1539 | @item -w |
1540 | @itemx --wildcard | |
1541 | Permit regular expressions in @var{symbolname}s used in other command | |
1542 | line options. The question mark (?), asterisk (*), backslash (\) and | |
1543 | square brackets ([]) operators can be used anywhere in the symbol | |
1544 | name. If the first character of the symbol name is the exclamation | |
1545 | point (!) then the sense of the switch is reversed for that symbol. | |
1546 | For example: | |
1547 | ||
1548 | @smallexample | |
1549 | -w -W !foo -W fo* | |
1550 | @end smallexample | |
1551 | ||
1552 | would cause objcopy to weaken all symbols that start with ``fo'' | |
1553 | except for the symbol ``foo''. | |
1554 | ||
252b5132 RH |
1555 | @item -x |
1556 | @itemx --discard-all | |
1557 | Do not copy non-global symbols from the source file. | |
1558 | @c FIXME any reason to prefer "non-global" to "local" here? | |
1559 | ||
1560 | @item -X | |
1561 | @itemx --discard-locals | |
1562 | Do not copy compiler-generated local symbols. | |
1563 | (These usually start with @samp{L} or @samp{.}.) | |
1564 | ||
1565 | @item -b @var{byte} | |
1566 | @itemx --byte=@var{byte} | |
b7dd81f7 NC |
1567 | If interleaving has been enabled via the @option{--interleave} option |
1568 | then start the range of bytes to keep at the @var{byte}th byte. | |
1569 | @var{byte} can be in the range from 0 to @var{breadth}-1, where | |
1570 | @var{breadth} is the value given by the @option{--interleave} option. | |
1571 | ||
1572 | @item -i [@var{breadth}] | |
1573 | @itemx --interleave[=@var{breadth}] | |
1574 | Only copy a range out of every @var{breadth} bytes. (Header data is | |
1575 | not affected). Select which byte in the range begins the copy with | |
1576 | the @option{--byte} option. Select the width of the range with the | |
1577 | @option{--interleave-width} option. | |
1578 | ||
1579 | This option is useful for creating files to program @sc{rom}. It is | |
1580 | typically used with an @code{srec} output target. Note that | |
1581 | @command{objcopy} will complain if you do not specify the | |
1582 | @option{--byte} option as well. | |
1583 | ||
1584 | The default interleave breadth is 4, so with @option{--byte} set to 0, | |
1585 | @command{objcopy} would copy the first byte out of every four bytes | |
1586 | from the input to the output. | |
1587 | ||
1588 | @item --interleave-width=@var{width} | |
1589 | When used with the @option{--interleave} option, copy @var{width} | |
1590 | bytes at a time. The start of the range of bytes to be copied is set | |
1591 | by the @option{--byte} option, and the extent of the range is set with | |
1592 | the @option{--interleave} option. | |
1593 | ||
1594 | The default value for this option is 1. The value of @var{width} plus | |
1595 | the @var{byte} value set by the @option{--byte} option must not exceed | |
1596 | the interleave breadth set by the @option{--interleave} option. | |
1597 | ||
1598 | This option can be used to create images for two 16-bit flashes interleaved | |
1599 | in a 32-bit bus by passing @option{-b 0 -i 4 --interleave-width=2} | |
1600 | and @option{-b 2 -i 4 --interleave-width=2} to two @command{objcopy} | |
1601 | commands. If the input was '12345678' then the outputs would be | |
1602 | '1256' and '3478' respectively. | |
252b5132 RH |
1603 | |
1604 | @item -p | |
1605 | @itemx --preserve-dates | |
1606 | Set the access and modification dates of the output file to be the same | |
1607 | as those of the input file. | |
1608 | ||
2e30cb57 CC |
1609 | @item -D |
1610 | @itemx --enable-deterministic-archives | |
955d0b3b RM |
1611 | @cindex deterministic archives |
1612 | @kindex --enable-deterministic-archives | |
2e30cb57 CC |
1613 | Operate in @emph{deterministic} mode. When copying archive members |
1614 | and writing the archive index, use zero for UIDs, GIDs, timestamps, | |
1615 | and use consistent file modes for all files. | |
1616 | ||
955d0b3b RM |
1617 | If @file{binutils} was configured with |
1618 | @option{--enable-deterministic-archives}, then this mode is on by default. | |
1619 | It can be disabled with the @samp{-U} option, below. | |
1620 | ||
1621 | @item -U | |
1622 | @itemx --disable-deterministic-archives | |
1623 | @cindex deterministic archives | |
1624 | @kindex --enable-deterministic-archives | |
1625 | Do @emph{not} operate in @emph{deterministic} mode. This is the | |
1626 | inverse of the @option{-D} option, above: when copying archive members | |
1627 | and writing the archive index, use their actual UID, GID, timestamp, | |
1628 | and file mode values. | |
1629 | ||
1630 | This is the default unless @file{binutils} was configured with | |
1631 | @option{--enable-deterministic-archives}. | |
1632 | ||
252b5132 RH |
1633 | @item --debugging |
1634 | Convert debugging information, if possible. This is not the default | |
1635 | because only certain debugging formats are supported, and the | |
1636 | conversion process can be time consuming. | |
1637 | ||
1638 | @item --gap-fill @var{val} | |
1639 | Fill gaps between sections with @var{val}. This operation applies to | |
1640 | the @emph{load address} (LMA) of the sections. It is done by increasing | |
1641 | the size of the section with the lower address, and filling in the extra | |
1642 | space created with @var{val}. | |
1643 | ||
1644 | @item --pad-to @var{address} | |
1645 | Pad the output file up to the load address @var{address}. This is | |
1646 | done by increasing the size of the last section. The extra space is | |
c7c55b78 | 1647 | filled in with the value specified by @option{--gap-fill} (default zero). |
252b5132 RH |
1648 | |
1649 | @item --set-start @var{val} | |
d11a9fab AB |
1650 | Set the start address (also known as the entry address) of the new |
1651 | file to @var{val}. Not all object file formats support setting the | |
1652 | start address. | |
252b5132 RH |
1653 | |
1654 | @item --change-start @var{incr} | |
1655 | @itemx --adjust-start @var{incr} | |
1656 | @cindex changing start address | |
d11a9fab AB |
1657 | Change the start address (also known as the entry address) by adding |
1658 | @var{incr}. Not all object file formats support setting the start | |
1659 | address. | |
252b5132 RH |
1660 | |
1661 | @item --change-addresses @var{incr} | |
1662 | @itemx --adjust-vma @var{incr} | |
1663 | @cindex changing object addresses | |
1664 | Change the VMA and LMA addresses of all sections, as well as the start | |
1665 | address, by adding @var{incr}. Some object file formats do not permit | |
1666 | section addresses to be changed arbitrarily. Note that this does not | |
1667 | relocate the sections; if the program expects sections to be loaded at a | |
1668 | certain address, and this option is used to change the sections such | |
c1c0eb9e | 1669 | that they are loaded at a different address, the program may fail. |
252b5132 | 1670 | |
2e62b721 NC |
1671 | @item --change-section-address @var{sectionpattern}@{=,+,-@}@var{val} |
1672 | @itemx --adjust-section-vma @var{sectionpattern}@{=,+,-@}@var{val} | |
252b5132 | 1673 | @cindex changing section address |
2e62b721 NC |
1674 | Set or change both the VMA address and the LMA address of any section |
1675 | matching @var{sectionpattern}. If @samp{=} is used, the section | |
1676 | address is set to @var{val}. Otherwise, @var{val} is added to or | |
1677 | subtracted from the section address. See the comments under | |
1678 | @option{--change-addresses}, above. If @var{sectionpattern} does not | |
1679 | match any sections in the input file, a warning will be issued, unless | |
1680 | @option{--no-change-warnings} is used. | |
252b5132 | 1681 | |
2e62b721 | 1682 | @item --change-section-lma @var{sectionpattern}@{=,+,-@}@var{val} |
252b5132 | 1683 | @cindex changing section LMA |
2e62b721 NC |
1684 | Set or change the LMA address of any sections matching |
1685 | @var{sectionpattern}. The LMA address is the address where the | |
1686 | section will be loaded into memory at program load time. Normally | |
1687 | this is the same as the VMA address, which is the address of the | |
1688 | section at program run time, but on some systems, especially those | |
1689 | where a program is held in ROM, the two can be different. If @samp{=} | |
1690 | is used, the section address is set to @var{val}. Otherwise, | |
1691 | @var{val} is added to or subtracted from the section address. See the | |
1692 | comments under @option{--change-addresses}, above. If | |
1693 | @var{sectionpattern} does not match any sections in the input file, a | |
1694 | warning will be issued, unless @option{--no-change-warnings} is used. | |
1695 | ||
1696 | @item --change-section-vma @var{sectionpattern}@{=,+,-@}@var{val} | |
1697 | @cindex changing section VMA | |
1698 | Set or change the VMA address of any section matching | |
1699 | @var{sectionpattern}. The VMA address is the address where the | |
1700 | section will be located once the program has started executing. | |
1701 | Normally this is the same as the LMA address, which is the address | |
1702 | where the section will be loaded into memory, but on some systems, | |
252b5132 RH |
1703 | especially those where a program is held in ROM, the two can be |
1704 | different. If @samp{=} is used, the section address is set to | |
1705 | @var{val}. Otherwise, @var{val} is added to or subtracted from the | |
c7c55b78 | 1706 | section address. See the comments under @option{--change-addresses}, |
2e62b721 NC |
1707 | above. If @var{sectionpattern} does not match any sections in the |
1708 | input file, a warning will be issued, unless | |
c1c0eb9e | 1709 | @option{--no-change-warnings} is used. |
252b5132 RH |
1710 | |
1711 | @item --change-warnings | |
1712 | @itemx --adjust-warnings | |
c7c55b78 | 1713 | If @option{--change-section-address} or @option{--change-section-lma} or |
2e62b721 NC |
1714 | @option{--change-section-vma} is used, and the section pattern does not |
1715 | match any sections, issue a warning. This is the default. | |
252b5132 RH |
1716 | |
1717 | @item --no-change-warnings | |
1718 | @itemx --no-adjust-warnings | |
c7c55b78 NC |
1719 | Do not issue a warning if @option{--change-section-address} or |
1720 | @option{--adjust-section-lma} or @option{--adjust-section-vma} is used, even | |
2e62b721 NC |
1721 | if the section pattern does not match any sections. |
1722 | ||
1723 | @item --set-section-flags @var{sectionpattern}=@var{flags} | |
1724 | Set the flags for any sections matching @var{sectionpattern}. The | |
1725 | @var{flags} argument is a comma separated string of flag names. The | |
1726 | recognized names are @samp{alloc}, @samp{contents}, @samp{load}, | |
1727 | @samp{noload}, @samp{readonly}, @samp{code}, @samp{data}, @samp{rom}, | |
3a5d12fb FS |
1728 | @samp{exclude}, @samp{share}, and @samp{debug}. You can set the |
1729 | @samp{contents} flag for a section which does not have contents, but it | |
1730 | is not meaningful to clear the @samp{contents} flag of a section which | |
1731 | does have contents--just remove the section instead. Not all flags are | |
a0dcf297 NC |
1732 | meaningful for all object file formats. In particular the |
1733 | @samp{share} flag is only meaningful for COFF format files and not for | |
1734 | ELF format files. | |
252b5132 | 1735 | |
fa463e9f | 1736 | @item --set-section-alignment @var{sectionpattern}=@var{align} |
de4859ea NC |
1737 | Set the alignment for any sections matching @var{sectionpattern}. |
1738 | @var{align} specifies the alignment in bytes and must be a power of | |
1739 | two, i.e. 1, 2, 4, 8@dots{}. | |
fa463e9f | 1740 | |
252b5132 RH |
1741 | @item --add-section @var{sectionname}=@var{filename} |
1742 | Add a new section named @var{sectionname} while copying the file. The | |
1743 | contents of the new section are taken from the file @var{filename}. The | |
1744 | size of the section will be the size of the file. This option only | |
1745 | works on file formats which can support sections with arbitrary names. | |
bbad633b NC |
1746 | Note - it may be necessary to use the @option{--set-section-flags} |
1747 | option to set the attributes of the newly created section. | |
1748 | ||
1749 | @item --dump-section @var{sectionname}=@var{filename} | |
1750 | Place the contents of section named @var{sectionname} into the file | |
1751 | @var{filename}, overwriting any contents that may have been there | |
1752 | previously. This option is the inverse of @option{--add-section}. | |
1753 | This option is similar to the @option{--only-section} option except | |
1754 | that it does not create a formatted file, it just dumps the contents | |
1755 | as raw binary data, without applying any relocations. The option can | |
1756 | be specified more than once. | |
252b5132 | 1757 | |
acf1419f AB |
1758 | @item --update-section @var{sectionname}=@var{filename} |
1759 | Replace the existing contents of a section named @var{sectionname} | |
1760 | with the contents of file @var{filename}. The size of the section | |
1761 | will be adjusted to the size of the file. The section flags for | |
1762 | @var{sectionname} will be unchanged. For ELF format files the section | |
1763 | to segment mapping will also remain unchanged, something which is not | |
1764 | possible using @option{--remove-section} followed by | |
1765 | @option{--add-section}. The option can be specified more than once. | |
1766 | ||
1767 | Note - it is possible to use @option{--rename-section} and | |
1768 | @option{--update-section} to both update and rename a section from one | |
1769 | command line. In this case, pass the original section name to | |
1770 | @option{--update-section}, and the original and new section names to | |
1771 | @option{--rename-section}. | |
1772 | ||
2b35fb28 RH |
1773 | @item --add-symbol @var{name}=[@var{section}:]@var{value}[,@var{flags}] |
1774 | Add a new symbol named @var{name} while copying the file. This option may be | |
1775 | specified multiple times. If the @var{section} is given, the symbol will be | |
1776 | associated with and relative to that section, otherwise it will be an ABS | |
1777 | symbol. Specifying an undefined section will result in a fatal error. There | |
1778 | is no check for the value, it will be taken as specified. Symbol flags can | |
1779 | be specified and not all flags will be meaningful for all object file | |
1780 | formats. By default, the symbol will be global. The special flag | |
1781 | 'before=@var{othersym}' will insert the new symbol in front of the specified | |
1782 | @var{othersym}, otherwise the symbol(s) will be added at the end of the | |
1783 | symbol table in the order they appear. | |
1784 | ||
594ef5db NC |
1785 | @item --rename-section @var{oldname}=@var{newname}[,@var{flags}] |
1786 | Rename a section from @var{oldname} to @var{newname}, optionally | |
1787 | changing the section's flags to @var{flags} in the process. This has | |
1ea332d6 | 1788 | the advantage over using a linker script to perform the rename in that |
594ef5db | 1789 | the output stays as an object file and does not become a linked |
a0dcf297 NC |
1790 | executable. This option accepts the same set of flags as the |
1791 | @option{--sect-section-flags} option. | |
594ef5db NC |
1792 | |
1793 | This option is particularly helpful when the input format is binary, | |
1794 | since this will always create a section called .data. If for example, | |
1795 | you wanted instead to create a section called .rodata containing binary | |
1796 | data you could use the following command line to achieve it: | |
1797 | ||
1798 | @smallexample | |
1799 | objcopy -I binary -O <output_format> -B <architecture> \ | |
1800 | --rename-section .data=.rodata,alloc,load,readonly,data,contents \ | |
1801 | <input_binary_file> <output_object_file> | |
1802 | @end smallexample | |
1803 | ||
0408dee6 DK |
1804 | @item --long-section-names @{enable,disable,keep@} |
1805 | Controls the handling of long section names when processing @code{COFF} | |
1806 | and @code{PE-COFF} object formats. The default behaviour, @samp{keep}, | |
1807 | is to preserve long section names if any are present in the input file. | |
1808 | The @samp{enable} and @samp{disable} options forcibly enable or disable | |
1809 | the use of long section names in the output object; when @samp{disable} | |
1810 | is in effect, any long section names in the input object will be truncated. | |
1811 | The @samp{enable} option will only emit long section names if any are | |
1812 | present in the inputs; this is mostly the same as @samp{keep}, but it | |
b3364cb9 | 1813 | is left undefined whether the @samp{enable} option might force the |
0408dee6 DK |
1814 | creation of an empty string table in the output file. |
1815 | ||
252b5132 RH |
1816 | @item --change-leading-char |
1817 | Some object file formats use special characters at the start of | |
1818 | symbols. The most common such character is underscore, which compilers | |
c7c55b78 | 1819 | often add before every symbol. This option tells @command{objcopy} to |
252b5132 RH |
1820 | change the leading character of every symbol when it converts between |
1821 | object file formats. If the object file formats use the same leading | |
1822 | character, this option has no effect. Otherwise, it will add a | |
1823 | character, or remove a character, or change a character, as | |
1824 | appropriate. | |
1825 | ||
1826 | @item --remove-leading-char | |
1827 | If the first character of a global symbol is a special symbol leading | |
1828 | character used by the object file format, remove the character. The | |
1829 | most common symbol leading character is underscore. This option will | |
1830 | remove a leading underscore from all global symbols. This can be useful | |
1831 | if you want to link together objects of different file formats with | |
1832 | different conventions for symbol names. This is different from | |
c7c55b78 | 1833 | @option{--change-leading-char} because it always changes the symbol name |
252b5132 RH |
1834 | when appropriate, regardless of the object file format of the output |
1835 | file. | |
1836 | ||
9e48b4c6 NC |
1837 | @item --reverse-bytes=@var{num} |
1838 | Reverse the bytes in a section with output contents. A section length must | |
1839 | be evenly divisible by the value given in order for the swap to be able to | |
1840 | take place. Reversing takes place before the interleaving is performed. | |
1841 | ||
1842 | This option is used typically in generating ROM images for problematic | |
1843 | target systems. For example, on some target boards, the 32-bit words | |
1844 | fetched from 8-bit ROMs are re-assembled in little-endian byte order | |
1845 | regardless of the CPU byte order. Depending on the programming model, the | |
1846 | endianness of the ROM may need to be modified. | |
1847 | ||
1848 | Consider a simple file with a section containing the following eight | |
1849 | bytes: @code{12345678}. | |
1850 | ||
1851 | Using @samp{--reverse-bytes=2} for the above example, the bytes in the | |
1852 | output file would be ordered @code{21436587}. | |
1853 | ||
1854 | Using @samp{--reverse-bytes=4} for the above example, the bytes in the | |
1855 | output file would be ordered @code{43218765}. | |
1856 | ||
1857 | By using @samp{--reverse-bytes=2} for the above example, followed by | |
1858 | @samp{--reverse-bytes=4} on the output file, the bytes in the second | |
1859 | output file would be ordered @code{34127856}. | |
1860 | ||
420496c1 NC |
1861 | @item --srec-len=@var{ival} |
1862 | Meaningful only for srec output. Set the maximum length of the Srecords | |
1863 | being produced to @var{ival}. This length covers both address, data and | |
1864 | crc fields. | |
1865 | ||
1866 | @item --srec-forceS3 | |
c1c0eb9e | 1867 | Meaningful only for srec output. Avoid generation of S1/S2 records, |
420496c1 NC |
1868 | creating S3-only record format. |
1869 | ||
57938635 AM |
1870 | @item --redefine-sym @var{old}=@var{new} |
1871 | Change the name of a symbol @var{old}, to @var{new}. This can be useful | |
1872 | when one is trying link two things together for which you have no | |
1873 | source, and there are name collisions. | |
1874 | ||
92991082 JT |
1875 | @item --redefine-syms=@var{filename} |
1876 | Apply @option{--redefine-sym} to each symbol pair "@var{old} @var{new}" | |
1877 | listed in the file @var{filename}. @var{filename} is simply a flat file, | |
1878 | with one symbol pair per line. Line comments may be introduced by the hash | |
1879 | character. This option may be given more than once. | |
1880 | ||
252b5132 RH |
1881 | @item --weaken |
1882 | Change all global symbols in the file to be weak. This can be useful | |
1883 | when building an object which will be linked against other objects using | |
c7c55b78 | 1884 | the @option{-R} option to the linker. This option is only effective when |
252b5132 RH |
1885 | using an object file format which supports weak symbols. |
1886 | ||
16b2b71c | 1887 | @item --keep-symbols=@var{filename} |
c7c55b78 | 1888 | Apply @option{--keep-symbol} option to each symbol listed in the file |
16b2b71c NC |
1889 | @var{filename}. @var{filename} is simply a flat file, with one symbol |
1890 | name per line. Line comments may be introduced by the hash character. | |
1891 | This option may be given more than once. | |
1892 | ||
1893 | @item --strip-symbols=@var{filename} | |
c7c55b78 | 1894 | Apply @option{--strip-symbol} option to each symbol listed in the file |
16b2b71c NC |
1895 | @var{filename}. @var{filename} is simply a flat file, with one symbol |
1896 | name per line. Line comments may be introduced by the hash character. | |
1897 | This option may be given more than once. | |
1898 | ||
bcf32829 JB |
1899 | @item --strip-unneeded-symbols=@var{filename} |
1900 | Apply @option{--strip-unneeded-symbol} option to each symbol listed in | |
1901 | the file @var{filename}. @var{filename} is simply a flat file, with one | |
1902 | symbol name per line. Line comments may be introduced by the hash | |
1903 | character. This option may be given more than once. | |
1904 | ||
16b2b71c | 1905 | @item --keep-global-symbols=@var{filename} |
c7c55b78 | 1906 | Apply @option{--keep-global-symbol} option to each symbol listed in the |
16b2b71c NC |
1907 | file @var{filename}. @var{filename} is simply a flat file, with one |
1908 | symbol name per line. Line comments may be introduced by the hash | |
1909 | character. This option may be given more than once. | |
1910 | ||
1911 | @item --localize-symbols=@var{filename} | |
c7c55b78 | 1912 | Apply @option{--localize-symbol} option to each symbol listed in the file |
16b2b71c NC |
1913 | @var{filename}. @var{filename} is simply a flat file, with one symbol |
1914 | name per line. Line comments may be introduced by the hash character. | |
1915 | This option may be given more than once. | |
1916 | ||
7b4a0685 NC |
1917 | @item --globalize-symbols=@var{filename} |
1918 | Apply @option{--globalize-symbol} option to each symbol listed in the file | |
1919 | @var{filename}. @var{filename} is simply a flat file, with one symbol | |
1920 | name per line. Line comments may be introduced by the hash character. | |
de564eb5 NC |
1921 | This option may be given more than once. Note: this option cannot be |
1922 | used in conjunction with the @option{-G} or @option{--keep-global-symbol} | |
1923 | options. | |
7b4a0685 | 1924 | |
16b2b71c | 1925 | @item --weaken-symbols=@var{filename} |
c7c55b78 | 1926 | Apply @option{--weaken-symbol} option to each symbol listed in the file |
16b2b71c NC |
1927 | @var{filename}. @var{filename} is simply a flat file, with one symbol |
1928 | name per line. Line comments may be introduced by the hash character. | |
1929 | This option may be given more than once. | |
1930 | ||
1ae8b3d2 AO |
1931 | @item --alt-machine-code=@var{index} |
1932 | If the output architecture has alternate machine codes, use the | |
1933 | @var{index}th code instead of the default one. This is useful in case | |
c1c0eb9e | 1934 | a machine is assigned an official code and the tool-chain adopts the |
1ae8b3d2 | 1935 | new code, but other applications still depend on the original code |
f9d4ad2a NC |
1936 | being used. For ELF based architectures if the @var{index} |
1937 | alternative does not exist then the value is treated as an absolute | |
1938 | number to be stored in the e_machine field of the ELF header. | |
1ae8b3d2 | 1939 | |
4087920c MR |
1940 | @item --writable-text |
1941 | Mark the output text as writable. This option isn't meaningful for all | |
1942 | object file formats. | |
1943 | ||
1944 | @item --readonly-text | |
1945 | Make the output text write protected. This option isn't meaningful for all | |
1946 | object file formats. | |
1947 | ||
1948 | @item --pure | |
1949 | Mark the output file as demand paged. This option isn't meaningful for all | |
1950 | object file formats. | |
1951 | ||
1952 | @item --impure | |
1953 | Mark the output file as impure. This option isn't meaningful for all | |
1954 | object file formats. | |
1955 | ||
d7fb0dd2 NC |
1956 | @item --prefix-symbols=@var{string} |
1957 | Prefix all symbols in the output file with @var{string}. | |
1958 | ||
1959 | @item --prefix-sections=@var{string} | |
1960 | Prefix all section names in the output file with @var{string}. | |
1961 | ||
1962 | @item --prefix-alloc-sections=@var{string} | |
1963 | Prefix all the names of all allocated sections in the output file with | |
1964 | @var{string}. | |
1965 | ||
ed1653a7 | 1966 | @item --add-gnu-debuglink=@var{path-to-file} |
4fd77a3d NC |
1967 | Creates a .gnu_debuglink section which contains a reference to |
1968 | @var{path-to-file} and adds it to the output file. Note: the file at | |
1969 | @var{path-to-file} must exist. Part of the process of adding the | |
1970 | .gnu_debuglink section involves embedding a checksum of the contents | |
1971 | of the debug info file into the section. | |
1972 | ||
1973 | If the debug info file is built in one location but it is going to be | |
1974 | installed at a later time into a different location then do not use | |
1975 | the path to the installed location. The @option{--add-gnu-debuglink} | |
1976 | option will fail because the installed file does not exist yet. | |
1977 | Instead put the debug info file in the current directory and use the | |
1978 | @option{--add-gnu-debuglink} option without any directory components, | |
1979 | like this: | |
1980 | ||
1981 | @smallexample | |
1982 | objcopy --add-gnu-debuglink=foo.debug | |
1983 | @end smallexample | |
37d0d091 | 1984 | |
4fd77a3d NC |
1985 | At debug time the debugger will attempt to look for the separate debug |
1986 | info file in a set of known locations. The exact set of these | |
1987 | locations varies depending upon the distribution being used, but it | |
1988 | typically includes: | |
1989 | ||
1990 | @table @code | |
1991 | ||
1992 | @item * The same directory as the executable. | |
1993 | ||
1994 | @item * A sub-directory of the directory containing the executable | |
1995 | called .debug | |
1996 | ||
1997 | @item * A global debug directory such as /usr/lib/debug. | |
1998 | @end table | |
1999 | ||
2000 | As long as the debug info file has been installed into one of these | |
2001 | locations before the debugger is run everything should work | |
2002 | correctly. | |
ed1653a7 | 2003 | |
ca0e11aa NC |
2004 | @item --keep-section-symbils |
2005 | When stripping a file, perhaps with @option{--strip-debug} or | |
2006 | @option{--strip-unneeded}, retain any symbols specifying section names, | |
2007 | which would otherwise get stripped. | |
2008 | ||
1637cd90 JB |
2009 | @item --keep-file-symbols |
2010 | When stripping a file, perhaps with @option{--strip-debug} or | |
2011 | @option{--strip-unneeded}, retain any symbols specifying source file names, | |
2012 | which would otherwise get stripped. | |
2013 | ||
ed1653a7 | 2014 | @item --only-keep-debug |
36d3b955 MR |
2015 | Strip a file, removing contents of any sections that would not be |
2016 | stripped by @option{--strip-debug} and leaving the debugging sections | |
c1c0eb9e | 2017 | intact. In ELF files, this preserves all note sections in the output. |
ed1653a7 | 2018 | |
63b9bbb7 NC |
2019 | Note - the section headers of the stripped sections are preserved, |
2020 | including their sizes, but the contents of the section are discarded. | |
2021 | The section headers are preserved so that other tools can match up the | |
2022 | debuginfo file with the real executable, even if that executable has | |
2023 | been relocated to a different address space. | |
2024 | ||
ed1653a7 NC |
2025 | The intention is that this option will be used in conjunction with |
2026 | @option{--add-gnu-debuglink} to create a two part executable. One a | |
2027 | stripped binary which will occupy less space in RAM and in a | |
2028 | distribution and the second a debugging information file which is only | |
2029 | needed if debugging abilities are required. The suggested procedure | |
2030 | to create these files is as follows: | |
2031 | ||
b96fec5e | 2032 | @enumerate |
eca4b721 | 2033 | @item Link the executable as normal. Assuming that it is called |
b96fec5e DK |
2034 | @code{foo} then... |
2035 | @item Run @code{objcopy --only-keep-debug foo foo.dbg} to | |
2036 | create a file containing the debugging info. | |
2037 | @item Run @code{objcopy --strip-debug foo} to create a | |
2038 | stripped executable. | |
2039 | @item Run @code{objcopy --add-gnu-debuglink=foo.dbg foo} | |
2040 | to add a link to the debugging info into the stripped executable. | |
2041 | @end enumerate | |
2042 | ||
2043 | Note---the choice of @code{.dbg} as an extension for the debug info | |
2044 | file is arbitrary. Also the @code{--only-keep-debug} step is | |
2045 | optional. You could instead do this: | |
2046 | ||
2047 | @enumerate | |
2048 | @item Link the executable as normal. | |
2049 | @item Copy @code{foo} to @code{foo.full} | |
2050 | @item Run @code{objcopy --strip-debug foo} | |
2051 | @item Run @code{objcopy --add-gnu-debuglink=foo.full foo} | |
2052 | @end enumerate | |
2053 | ||
2054 | i.e., the file pointed to by the @option{--add-gnu-debuglink} can be the | |
2055 | full executable. It does not have to be a file created by the | |
2056 | @option{--only-keep-debug} switch. | |
2057 | ||
2058 | Note---this switch is only intended for use on fully linked files. It | |
2059 | does not make sense to use it on object files where the debugging | |
2060 | information may be incomplete. Besides the gnu_debuglink feature | |
2061 | currently only supports the presence of one filename containing | |
2062 | debugging information, not multiple filenames on a one-per-object-file | |
2063 | basis. | |
2064 | ||
96109726 CC |
2065 | @item --strip-dwo |
2066 | Remove the contents of all DWARF .dwo sections, leaving the | |
2067 | remaining debugging sections and all symbols intact. | |
2068 | This option is intended for use by the compiler as part of | |
2069 | the @option{-gsplit-dwarf} option, which splits debug information | |
2070 | between the .o file and a separate .dwo file. The compiler | |
2071 | generates all debug information in the same file, then uses | |
2072 | the @option{--extract-dwo} option to copy the .dwo sections to | |
2073 | the .dwo file, then the @option{--strip-dwo} option to remove | |
2074 | those sections from the original .o file. | |
2075 | ||
2076 | @item --extract-dwo | |
2077 | Extract the contents of all DWARF .dwo sections. See the | |
2078 | @option{--strip-dwo} option for more information. | |
2079 | ||
92dd4511 L |
2080 | @item --file-alignment @var{num} |
2081 | Specify the file alignment. Sections in the file will always begin at | |
2082 | file offsets which are multiples of this number. This defaults to | |
2083 | 512. | |
2084 | [This option is specific to PE targets.] | |
2085 | ||
2086 | @item --heap @var{reserve} | |
2087 | @itemx --heap @var{reserve},@var{commit} | |
2088 | Specify the number of bytes of memory to reserve (and optionally commit) | |
2089 | to be used as heap for this program. | |
2090 | [This option is specific to PE targets.] | |
2091 | ||
2092 | @item --image-base @var{value} | |
2093 | Use @var{value} as the base address of your program or dll. This is | |
2094 | the lowest memory location that will be used when your program or dll | |
2095 | is loaded. To reduce the need to relocate and improve performance of | |
2096 | your dlls, each should have a unique base address and not overlap any | |
2097 | other dlls. The default is 0x400000 for executables, and 0x10000000 | |
2098 | for dlls. | |
2099 | [This option is specific to PE targets.] | |
2100 | ||
2101 | @item --section-alignment @var{num} | |
fa463e9f N |
2102 | Sets the section alignment field in the PE header. Sections in memory |
2103 | will always begin at addresses which are a multiple of this number. | |
2104 | Defaults to 0x1000. | |
92dd4511 L |
2105 | [This option is specific to PE targets.] |
2106 | ||
2107 | @item --stack @var{reserve} | |
2108 | @itemx --stack @var{reserve},@var{commit} | |
2109 | Specify the number of bytes of memory to reserve (and optionally commit) | |
2110 | to be used as stack for this program. | |
2111 | [This option is specific to PE targets.] | |
2112 | ||
2113 | @item --subsystem @var{which} | |
2114 | @itemx --subsystem @var{which}:@var{major} | |
2115 | @itemx --subsystem @var{which}:@var{major}.@var{minor} | |
2116 | Specifies the subsystem under which your program will execute. The | |
2117 | legal values for @var{which} are @code{native}, @code{windows}, | |
2118 | @code{console}, @code{posix}, @code{efi-app}, @code{efi-bsd}, | |
d9118602 | 2119 | @code{efi-rtd}, @code{sal-rtd}, and @code{xbox}. You may optionally set |
92dd4511 L |
2120 | the subsystem version also. Numeric values are also accepted for |
2121 | @var{which}. | |
2122 | [This option is specific to PE targets.] | |
2123 | ||
d3e52d40 RS |
2124 | @item --extract-symbol |
2125 | Keep the file's section flags and symbols but remove all section data. | |
2126 | Specifically, the option: | |
2127 | ||
2128 | @itemize | |
d3e52d40 RS |
2129 | @item removes the contents of all sections; |
2130 | @item sets the size of every section to zero; and | |
2131 | @item sets the file's start address to zero. | |
2132 | @end itemize | |
c1c0eb9e | 2133 | |
d3e52d40 RS |
2134 | This option is used to build a @file{.sym} file for a VxWorks kernel. |
2135 | It can also be a useful way of reducing the size of a @option{--just-symbols} | |
2136 | linker input file. | |
2137 | ||
4a114e3e | 2138 | @item --compress-debug-sections |
19a7fe52 L |
2139 | Compress DWARF debug sections using zlib with SHF_COMPRESSED from the |
2140 | ELF ABI. Note - if compression would actually make a section | |
2141 | @emph{larger}, then it is not compressed. | |
4a114e3e | 2142 | |
151411f8 L |
2143 | @item --compress-debug-sections=none |
2144 | @itemx --compress-debug-sections=zlib | |
2145 | @itemx --compress-debug-sections=zlib-gnu | |
2146 | @itemx --compress-debug-sections=zlib-gabi | |
2147 | For ELF files, these options control how DWARF debug sections are | |
2148 | compressed. @option{--compress-debug-sections=none} is equivalent | |
96d491cf | 2149 | to @option{--decompress-debug-sections}. |
151411f8 | 2150 | @option{--compress-debug-sections=zlib} and |
19a7fe52 | 2151 | @option{--compress-debug-sections=zlib-gabi} are equivalent to |
151411f8 | 2152 | @option{--compress-debug-sections}. |
19a7fe52 L |
2153 | @option{--compress-debug-sections=zlib-gnu} compresses DWARF debug |
2154 | sections using zlib. The debug sections are renamed to begin with | |
2155 | @samp{.zdebug} instead of @samp{.debug}. Note - if compression would | |
2156 | actually make a section @emph{larger}, then it is not compressed nor | |
2157 | renamed. | |
151411f8 | 2158 | |
4a114e3e | 2159 | @item --decompress-debug-sections |
273a4985 JT |
2160 | Decompress DWARF debug sections using zlib. The original section |
2161 | names of the compressed sections are restored. | |
4a114e3e | 2162 | |
b8871f35 L |
2163 | @item --elf-stt-common=yes |
2164 | @itemx --elf-stt-common=no | |
2165 | For ELF files, these options control whether common symbols should be | |
2166 | converted to the @code{STT_COMMON} or @code{STT_OBJECT} type. | |
2167 | @option{--elf-stt-common=yes} converts common symbol type to | |
2168 | @code{STT_COMMON}. @option{--elf-stt-common=no} converts common symbol | |
2169 | type to @code{STT_OBJECT}. | |
2170 | ||
9ef920e9 | 2171 | @item --merge-notes |
1d15e434 NC |
2172 | @itemx --no-merge-notes |
2173 | For ELF files, attempt (or do not attempt) to reduce the size of any | |
2174 | SHT_NOTE type sections by removing duplicate notes. | |
9ef920e9 | 2175 | |
252b5132 RH |
2176 | @item -V |
2177 | @itemx --version | |
c7c55b78 | 2178 | Show the version number of @command{objcopy}. |
252b5132 | 2179 | |
37d0d091 JH |
2180 | @item --verilog-data-width=@var{bytes} |
2181 | For Verilog output, this options controls the number of bytes | |
2182 | converted for each output data element. The input target controls the | |
2183 | endianness of the conversion. | |
2184 | ||
252b5132 RH |
2185 | @item -v |
2186 | @itemx --verbose | |
2187 | Verbose output: list all object files modified. In the case of | |
2188 | archives, @samp{objcopy -V} lists all members of the archive. | |
2189 | ||
2190 | @item --help | |
c7c55b78 | 2191 | Show a summary of the options to @command{objcopy}. |
7c29036b NC |
2192 | |
2193 | @item --info | |
2194 | Display a list showing all architectures and object formats available. | |
252b5132 RH |
2195 | @end table |
2196 | ||
0285c67d NC |
2197 | @c man end |
2198 | ||
2199 | @ignore | |
2200 | @c man begin SEEALSO objcopy | |
2201 | ld(1), objdump(1), and the Info entries for @file{binutils}. | |
2202 | @c man end | |
2203 | @end ignore | |
2204 | ||
252b5132 RH |
2205 | @node objdump |
2206 | @chapter objdump | |
2207 | ||
2208 | @cindex object file information | |
2209 | @kindex objdump | |
2210 | ||
f927cc8f | 2211 | @c man title objdump display information from object files |
0285c67d | 2212 | |
252b5132 | 2213 | @smallexample |
0285c67d | 2214 | @c man begin SYNOPSIS objdump |
c7c55b78 NC |
2215 | objdump [@option{-a}|@option{--archive-headers}] |
2216 | [@option{-b} @var{bfdname}|@option{--target=@var{bfdname}}] | |
2217 | [@option{-C}|@option{--demangle}[=@var{style}] ] | |
d3def5d7 | 2218 | [@option{-d}|@option{--disassemble}[=@var{symbol}]] |
c7c55b78 NC |
2219 | [@option{-D}|@option{--disassemble-all}] |
2220 | [@option{-z}|@option{--disassemble-zeroes}] | |
2221 | [@option{-EB}|@option{-EL}|@option{--endian=}@{big | little @}] | |
2222 | [@option{-f}|@option{--file-headers}] | |
98ec6e72 | 2223 | [@option{-F}|@option{--file-offsets}] |
c7c55b78 NC |
2224 | [@option{--file-start-context}] |
2225 | [@option{-g}|@option{--debugging}] | |
51cdc6e0 | 2226 | [@option{-e}|@option{--debugging-tags}] |
c7c55b78 NC |
2227 | [@option{-h}|@option{--section-headers}|@option{--headers}] |
2228 | [@option{-i}|@option{--info}] | |
2229 | [@option{-j} @var{section}|@option{--section=}@var{section}] | |
2230 | [@option{-l}|@option{--line-numbers}] | |
2231 | [@option{-S}|@option{--source}] | |
a1c110a3 | 2232 | [@option{--source-comment}[=@var{text}]] |
c7c55b78 NC |
2233 | [@option{-m} @var{machine}|@option{--architecture=}@var{machine}] |
2234 | [@option{-M} @var{options}|@option{--disassembler-options=}@var{options}] | |
2235 | [@option{-p}|@option{--private-headers}] | |
6abcee90 | 2236 | [@option{-P} @var{options}|@option{--private=}@var{options}] |
c7c55b78 NC |
2237 | [@option{-r}|@option{--reloc}] |
2238 | [@option{-R}|@option{--dynamic-reloc}] | |
2239 | [@option{-s}|@option{--full-contents}] | |
c46b7066 NC |
2240 | [@option{-W[lLiaprmfFsoORtUuTgAck]}| |
2241 | @option{--dwarf}[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=str-offsets,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index,=addr,=cu_index,=links]] | |
2242 | [@option{-WK}|@option{--dwarf=follow-links}] | |
2243 | [@option{-WN}|@option{--dwarf=no-follow-links}] | |
ca0e11aa | 2244 | [@option{-L}|@option{--process-links}] |
7d9813f1 | 2245 | [@option{--ctf=}@var{section}] |
c7c55b78 NC |
2246 | [@option{-G}|@option{--stabs}] |
2247 | [@option{-t}|@option{--syms}] | |
2248 | [@option{-T}|@option{--dynamic-syms}] | |
2249 | [@option{-x}|@option{--all-headers}] | |
2250 | [@option{-w}|@option{--wide}] | |
2251 | [@option{--start-address=}@var{address}] | |
2252 | [@option{--stop-address=}@var{address}] | |
b1bc1394 | 2253 | [@option{--no-addresses}] |
c7c55b78 NC |
2254 | [@option{--prefix-addresses}] |
2255 | [@option{--[no-]show-raw-insn}] | |
2256 | [@option{--adjust-vma=}@var{offset}] | |
b2a40aa5 TG |
2257 | [@option{--dwarf-depth=@var{n}}] |
2258 | [@option{--dwarf-start=@var{n}}] | |
7d9813f1 | 2259 | [@option{--ctf-parent=}@var{section}] |
af03af8f | 2260 | [@option{--no-recurse-limit}|@option{--recurse-limit}] |
3c9458e9 | 2261 | [@option{--special-syms}] |
0dafdf3f L |
2262 | [@option{--prefix=}@var{prefix}] |
2263 | [@option{--prefix-strip=}@var{level}] | |
3dcb3fcb | 2264 | [@option{--insn-width=}@var{width}] |
1d67fe3b | 2265 | [@option{--visualize-jumps[=color|=extended-color|=off]} |
b3aa80b4 | 2266 | [@option{-U} @var{method}] [@option{--unicode=}@var{method}] |
c7c55b78 NC |
2267 | [@option{-V}|@option{--version}] |
2268 | [@option{-H}|@option{--help}] | |
252b5132 | 2269 | @var{objfile}@dots{} |
0285c67d | 2270 | @c man end |
252b5132 RH |
2271 | @end smallexample |
2272 | ||
0285c67d NC |
2273 | @c man begin DESCRIPTION objdump |
2274 | ||
c7c55b78 | 2275 | @command{objdump} displays information about one or more object files. |
252b5132 RH |
2276 | The options control what particular information to display. This |
2277 | information is mostly useful to programmers who are working on the | |
2278 | compilation tools, as opposed to programmers who just want their | |
2279 | program to compile and work. | |
2280 | ||
2281 | @var{objfile}@dots{} are the object files to be examined. When you | |
c7c55b78 | 2282 | specify archives, @command{objdump} shows information on each of the member |
252b5132 RH |
2283 | object files. |
2284 | ||
0285c67d NC |
2285 | @c man end |
2286 | ||
2287 | @c man begin OPTIONS objdump | |
2288 | ||
252b5132 | 2289 | The long and short forms of options, shown here as alternatives, are |
1dada9c5 | 2290 | equivalent. At least one option from the list |
6abcee90 | 2291 | @option{-a,-d,-D,-e,-f,-g,-G,-h,-H,-p,-P,-r,-R,-s,-S,-t,-T,-V,-x} must be given. |
252b5132 | 2292 | |
c7c55b78 | 2293 | @table @env |
252b5132 RH |
2294 | @item -a |
2295 | @itemx --archive-header | |
2296 | @cindex archive headers | |
2297 | If any of the @var{objfile} files are archives, display the archive | |
2298 | header information (in a format similar to @samp{ls -l}). Besides the | |
2299 | information you could list with @samp{ar tv}, @samp{objdump -a} shows | |
2300 | the object file format of each archive member. | |
2301 | ||
2302 | @item --adjust-vma=@var{offset} | |
2303 | @cindex section addresses in objdump | |
2304 | @cindex VMA in objdump | |
2305 | When dumping information, first add @var{offset} to all the section | |
2306 | addresses. This is useful if the section addresses do not correspond to | |
2307 | the symbol table, which can happen when putting sections at particular | |
2308 | addresses when using a format which can not represent section addresses, | |
2309 | such as a.out. | |
2310 | ||
2311 | @item -b @var{bfdname} | |
2312 | @itemx --target=@var{bfdname} | |
2313 | @cindex object code format | |
2314 | Specify that the object-code format for the object files is | |
2315 | @var{bfdname}. This option may not be necessary; @var{objdump} can | |
2316 | automatically recognize many formats. | |
2317 | ||
2318 | For example, | |
2319 | @example | |
2320 | objdump -b oasys -m vax -h fu.o | |
2321 | @end example | |
2322 | @noindent | |
c7c55b78 NC |
2323 | displays summary information from the section headers (@option{-h}) of |
2324 | @file{fu.o}, which is explicitly identified (@option{-m}) as a VAX object | |
252b5132 | 2325 | file in the format produced by Oasys compilers. You can list the |
c7c55b78 | 2326 | formats available with the @option{-i} option. |
252b5132 RH |
2327 | @xref{Target Selection}, for more information. |
2328 | ||
2329 | @item -C | |
28c309a2 | 2330 | @itemx --demangle[=@var{style}] |
252b5132 RH |
2331 | @cindex demangling in objdump |
2332 | Decode (@dfn{demangle}) low-level symbol names into user-level names. | |
2333 | Besides removing any initial underscore prepended by the system, this | |
28c309a2 | 2334 | makes C++ function names readable. Different compilers have different |
c1c0eb9e RM |
2335 | mangling styles. The optional demangling style argument can be used to |
2336 | choose an appropriate demangling style for your compiler. @xref{c++filt}, | |
28c309a2 | 2337 | for more information on demangling. |
252b5132 | 2338 | |
af03af8f NC |
2339 | @item --recurse-limit |
2340 | @itemx --no-recurse-limit | |
2341 | @itemx --recursion-limit | |
2342 | @itemx --no-recursion-limit | |
2343 | Enables or disables a limit on the amount of recursion performed | |
2344 | whilst demangling strings. Since the name mangling formats allow for | |
0cc79db2 | 2345 | an infinite level of recursion it is possible to create strings whose |
af03af8f NC |
2346 | decoding will exhaust the amount of stack space available on the host |
2347 | machine, triggering a memory fault. The limit tries to prevent this | |
69799d67 | 2348 | from happening by restricting recursion to 2048 levels of nesting. |
af03af8f NC |
2349 | |
2350 | The default is for this limit to be enabled, but disabling it may be | |
2351 | necessary in order to demangle truly complicated names. Note however | |
2352 | that if the recursion limit is disabled then stack exhaustion is | |
2353 | possible and any bug reports about such an event will be rejected. | |
2354 | ||
947ed062 NC |
2355 | @item -g |
2356 | @itemx --debugging | |
fdef3943 | 2357 | Display debugging information. This attempts to parse STABS |
b922d590 | 2358 | debugging format information stored in the file and print it out using |
83d4d556 | 2359 | a C like syntax. If no STABS debugging was found this option |
b922d590 NC |
2360 | falls back on the @option{-W} option to print any DWARF information in |
2361 | the file. | |
252b5132 | 2362 | |
51cdc6e0 NC |
2363 | @item -e |
2364 | @itemx --debugging-tags | |
2365 | Like @option{-g}, but the information is generated in a format compatible | |
2366 | with ctags tool. | |
2367 | ||
252b5132 RH |
2368 | @item -d |
2369 | @itemx --disassemble | |
d3def5d7 | 2370 | @itemx --disassemble=@var{symbol} |
252b5132 RH |
2371 | @cindex disassembling object code |
2372 | @cindex machine instructions | |
d3def5d7 MY |
2373 | Display the assembler mnemonics for the machine instructions from the |
2374 | input file. This option only disassembles those sections which are | |
2375 | expected to contain instructions. If the optional @var{symbol} | |
baae986a NC |
2376 | argument is given, then display the assembler mnemonics starting at |
2377 | @var{symbol}. If @var{symbol} is a function name then disassembly | |
2378 | will stop at the end of the function, otherwise it will stop when the | |
2379 | next symbol is encountered. If there are no matches for @var{symbol} | |
2380 | then nothing will be displayed. | |
252b5132 | 2381 | |
c46b7066 | 2382 | Note if the @option{--dwarf=follow-links} option is enabled |
39f0547e NC |
2383 | then any symbol tables in linked debug info files will be read in and |
2384 | used when disassembling. | |
2385 | ||
252b5132 RH |
2386 | @item -D |
2387 | @itemx --disassemble-all | |
c7c55b78 | 2388 | Like @option{-d}, but disassemble the contents of all sections, not just |
252b5132 RH |
2389 | those expected to contain instructions. |
2390 | ||
bdc4de1b NC |
2391 | This option also has a subtle effect on the disassembly of |
2392 | instructions in code sections. When option @option{-d} is in effect | |
2393 | objdump will assume that any symbols present in a code section occur | |
2394 | on the boundary between instructions and it will refuse to disassemble | |
2395 | across such a boundary. When option @option{-D} is in effect however | |
2396 | this assumption is supressed. This means that it is possible for the | |
2397 | output of @option{-d} and @option{-D} to differ if, for example, data | |
2398 | is stored in code sections. | |
2399 | ||
0313a2b8 NC |
2400 | If the target is an ARM architecture this switch also has the effect |
2401 | of forcing the disassembler to decode pieces of data found in code | |
2402 | sections as if they were instructions. | |
2403 | ||
c46b7066 | 2404 | Note if the @option{--dwarf=follow-links} option is enabled |
39f0547e NC |
2405 | then any symbol tables in linked debug info files will be read in and |
2406 | used when disassembling. | |
2407 | ||
b1bc1394 AM |
2408 | @item --no-addresses |
2409 | When disassembling, don't print addresses on each line or for symbols | |
937f6614 AM |
2410 | and relocation offsets. In combination with @option{--no-show-raw-insn} |
2411 | this may be useful for comparing compiler output. | |
b1bc1394 | 2412 | |
252b5132 RH |
2413 | @item --prefix-addresses |
2414 | When disassembling, print the complete address on each line. This is | |
2415 | the older disassembly format. | |
2416 | ||
252b5132 RH |
2417 | @item -EB |
2418 | @itemx -EL | |
2419 | @itemx --endian=@{big|little@} | |
2420 | @cindex endianness | |
2421 | @cindex disassembly endianness | |
2422 | Specify the endianness of the object files. This only affects | |
2423 | disassembly. This can be useful when disassembling a file format which | |
2424 | does not describe endianness information, such as S-records. | |
2425 | ||
2426 | @item -f | |
947ed062 | 2427 | @itemx --file-headers |
252b5132 RH |
2428 | @cindex object file header |
2429 | Display summary information from the overall header of | |
2430 | each of the @var{objfile} files. | |
2431 | ||
98ec6e72 NC |
2432 | @item -F |
2433 | @itemx --file-offsets | |
2434 | @cindex object file offsets | |
2435 | When disassembling sections, whenever a symbol is displayed, also | |
2436 | display the file offset of the region of data that is about to be | |
2437 | dumped. If zeroes are being skipped, then when disassembly resumes, | |
2438 | tell the user how many zeroes were skipped and the file offset of the | |
32760852 NC |
2439 | location from where the disassembly resumes. When dumping sections, |
2440 | display the file offset of the location from where the dump starts. | |
98ec6e72 | 2441 | |
f1563258 TW |
2442 | @item --file-start-context |
2443 | @cindex source code context | |
2444 | Specify that when displaying interlisted source code/disassembly | |
c7c55b78 | 2445 | (assumes @option{-S}) from a file that has not yet been displayed, extend the |
f1563258 TW |
2446 | context to the start of the file. |
2447 | ||
252b5132 | 2448 | @item -h |
947ed062 NC |
2449 | @itemx --section-headers |
2450 | @itemx --headers | |
252b5132 RH |
2451 | @cindex section headers |
2452 | Display summary information from the section headers of the | |
2453 | object file. | |
2454 | ||
2455 | File segments may be relocated to nonstandard addresses, for example by | |
c7c55b78 NC |
2456 | using the @option{-Ttext}, @option{-Tdata}, or @option{-Tbss} options to |
2457 | @command{ld}. However, some object file formats, such as a.out, do not | |
252b5132 | 2458 | store the starting address of the file segments. In those situations, |
c7c55b78 | 2459 | although @command{ld} relocates the sections correctly, using @samp{objdump |
252b5132 RH |
2460 | -h} to list the file section headers cannot show the correct addresses. |
2461 | Instead, it shows the usual addresses, which are implicit for the | |
2462 | target. | |
2463 | ||
91f68a68 MG |
2464 | Note, in some cases it is possible for a section to have both the |
2465 | READONLY and the NOREAD attributes set. In such cases the NOREAD | |
2466 | attribute takes precedence, but @command{objdump} will report both | |
2467 | since the exact setting of the flag bits might be important. | |
2468 | ||
947ed062 NC |
2469 | @item -H |
2470 | @itemx --help | |
c7c55b78 | 2471 | Print a summary of the options to @command{objdump} and exit. |
252b5132 RH |
2472 | |
2473 | @item -i | |
2474 | @itemx --info | |
2475 | @cindex architectures available | |
2476 | @cindex object formats available | |
2477 | Display a list showing all architectures and object formats available | |
c7c55b78 | 2478 | for specification with @option{-b} or @option{-m}. |
252b5132 RH |
2479 | |
2480 | @item -j @var{name} | |
2481 | @itemx --section=@var{name} | |
2482 | @cindex section information | |
2483 | Display information only for section @var{name}. | |
2484 | ||
ca0e11aa NC |
2485 | @item -L |
2486 | @itemx --process-links | |
2487 | Display the contents of non-debug sections found in separate debuginfo | |
2488 | files that are linked to the main file. This option automatically | |
2489 | implies the @option{-WK} option, and only sections requested by other | |
2490 | command line options will be displayed. | |
2491 | ||
252b5132 RH |
2492 | @item -l |
2493 | @itemx --line-numbers | |
2494 | @cindex source filenames for object files | |
2495 | Label the display (using debugging information) with the filename and | |
2496 | source line numbers corresponding to the object code or relocs shown. | |
c7c55b78 | 2497 | Only useful with @option{-d}, @option{-D}, or @option{-r}. |
252b5132 RH |
2498 | |
2499 | @item -m @var{machine} | |
2500 | @itemx --architecture=@var{machine} | |
2501 | @cindex architecture | |
2502 | @cindex disassembly architecture | |
2503 | Specify the architecture to use when disassembling object files. This | |
2504 | can be useful when disassembling object files which do not describe | |
2505 | architecture information, such as S-records. You can list the available | |
c7c55b78 | 2506 | architectures with the @option{-i} option. |
252b5132 | 2507 | |
0313a2b8 NC |
2508 | If the target is an ARM architecture then this switch has an |
2509 | additional effect. It restricts the disassembly to only those | |
2510 | instructions supported by the architecture specified by @var{machine}. | |
2511 | If it is necessary to use this switch because the input file does not | |
2512 | contain any architecture information, but it is also desired to | |
2513 | disassemble all the instructions use @option{-marm}. | |
2514 | ||
dd92f639 NC |
2515 | @item -M @var{options} |
2516 | @itemx --disassembler-options=@var{options} | |
2517 | Pass target specific information to the disassembler. Only supported on | |
31e0f3cd NC |
2518 | some targets. If it is necessary to specify more than one |
2519 | disassembler option then multiple @option{-M} options can be used or | |
2520 | can be placed together into a comma separated list. | |
dd92f639 | 2521 | |
7982a1dd NC |
2522 | For ARC, @option{dsp} controls the printing of DSP instructions, |
2523 | @option{spfp} selects the printing of FPX single precision FP | |
2524 | instructions, @option{dpfp} selects the printing of FPX double | |
2525 | precision FP instructions, @option{quarkse_em} selects the printing of | |
2526 | special QuarkSE-EM instructions, @option{fpuda} selects the printing | |
2527 | of double precision assist instructions, @option{fpus} selects the | |
2528 | printing of FPU single precision FP instructions, while @option{fpud} | |
eca4b721 | 2529 | selects the printing of FPU double precision FP instructions. |
fdddd290 | 2530 | Additionally, one can choose to have all the immediates printed in |
2531 | hexadecimal using @option{hex}. By default, the short immediates are | |
2532 | printed using the decimal representation, while the long immediate | |
2533 | values are printed as hexadecimal. | |
37fd5ef3 | 2534 | |
f9a6a8f0 | 2535 | @option{cpu=...} allows one to enforce a particular ISA when disassembling |
10045478 AK |
2536 | instructions, overriding the @option{-m} value or whatever is in the ELF file. |
2537 | This might be useful to select ARC EM or HS ISA, because architecture is same | |
2538 | for those and disassembler relies on private ELF header data to decide if code | |
2539 | is for EM or HS. This option might be specified multiple times - only the | |
2540 | latest value will be used. Valid values are same as for the assembler | |
2541 | @option{-mcpu=...} option. | |
2542 | ||
dd92f639 NC |
2543 | If the target is an ARM architecture then this switch can be used to |
2544 | select which register name set is used during disassembler. Specifying | |
9c092ace | 2545 | @option{-M reg-names-std} (the default) will select the register names as |
58efb6c0 NC |
2546 | used in ARM's instruction set documentation, but with register 13 called |
2547 | 'sp', register 14 called 'lr' and register 15 called 'pc'. Specifying | |
c7c55b78 NC |
2548 | @option{-M reg-names-apcs} will select the name set used by the ARM |
2549 | Procedure Call Standard, whilst specifying @option{-M reg-names-raw} will | |
58efb6c0 NC |
2550 | just use @samp{r} followed by the register number. |
2551 | ||
2552 | There are also two variants on the APCS register naming scheme enabled | |
c7c55b78 NC |
2553 | by @option{-M reg-names-atpcs} and @option{-M reg-names-special-atpcs} which |
2554 | use the ARM/Thumb Procedure Call Standard naming conventions. (Either | |
947ed062 | 2555 | with the normal register names or the special register names). |
dd92f639 | 2556 | |
8f915f68 | 2557 | This option can also be used for ARM architectures to force the |
c36774d6 | 2558 | disassembler to interpret all instructions as Thumb instructions by |
c7c55b78 | 2559 | using the switch @option{--disassembler-options=force-thumb}. This can be |
8f915f68 NC |
2560 | useful when attempting to disassemble thumb code produced by other |
2561 | compilers. | |
2562 | ||
7d02540a TC |
2563 | For AArch64 targets this switch can be used to set whether instructions are |
2564 | disassembled as the most general instruction using the @option{-M no-aliases} | |
2565 | option or whether instruction notes should be generated as comments in the | |
2566 | disasssembly using @option{-M notes}. | |
2567 | ||
e396998b | 2568 | For the x86, some of the options duplicate functions of the @option{-m} |
2a1bb84c | 2569 | switch, but allow finer grained control. |
c4416f30 NC |
2570 | @table @code |
2571 | @item x86-64 | |
2572 | @itemx i386 | |
2573 | @itemx i8086 | |
2574 | Select disassembly for the given architecture. | |
2575 | ||
2576 | @item intel | |
2577 | @itemx att | |
2578 | Select between intel syntax mode and AT&T syntax mode. | |
2579 | ||
5db04b09 L |
2580 | @item amd64 |
2581 | @itemx intel64 | |
2582 | Select between AMD64 ISA and Intel64 ISA. | |
2583 | ||
c4416f30 NC |
2584 | @item intel-mnemonic |
2585 | @itemx att-mnemonic | |
2586 | Select between intel mnemonic mode and AT&T mnemonic mode. | |
2587 | Note: @code{intel-mnemonic} implies @code{intel} and | |
2588 | @code{att-mnemonic} implies @code{att}. | |
2589 | ||
2590 | @item addr64 | |
2591 | @itemx addr32 | |
2592 | @itemx addr16 | |
2593 | @itemx data32 | |
2594 | @itemx data16 | |
9177214a | 2595 | Specify the default address size and operand size. These five options |
c4416f30 NC |
2596 | will be overridden if @code{x86-64}, @code{i386} or @code{i8086} |
2597 | appear later in the option string. | |
2598 | ||
2599 | @item suffix | |
2a1bb84c JB |
2600 | When in AT&T mode and also for a limited set of instructions when in Intel |
2601 | mode, instructs the disassembler to print a mnemonic suffix even when the | |
2602 | suffix could be inferred by the operands or, for certain instructions, the | |
2603 | execution mode's defaults. | |
c4416f30 | 2604 | @end table |
e396998b | 2605 | |
52be03fd AM |
2606 | For PowerPC, the @option{-M} argument @option{raw} selects |
2607 | disasssembly of hardware insns rather than aliases. For example, you | |
2608 | will see @code{rlwinm} rather than @code{clrlwi}, and @code{addi} | |
2609 | rather than @code{li}. All of the @option{-m} arguments for | |
2610 | @command{gas} that select a CPU are supported. These are: | |
2611 | @option{403}, @option{405}, @option{440}, @option{464}, @option{476}, | |
2612 | @option{601}, @option{603}, @option{604}, @option{620}, @option{7400}, | |
2613 | @option{7410}, @option{7450}, @option{7455}, @option{750cl}, | |
2614 | @option{821}, @option{850}, @option{860}, @option{a2}, @option{booke}, | |
2615 | @option{booke32}, @option{cell}, @option{com}, @option{e200z4}, | |
2616 | @option{e300}, @option{e500}, @option{e500mc}, @option{e500mc64}, | |
2617 | @option{e500x2}, @option{e5500}, @option{e6500}, @option{efs}, | |
2618 | @option{power4}, @option{power5}, @option{power6}, @option{power7}, | |
1424c35d AM |
2619 | @option{power8}, @option{power9}, @option{power10}, @option{ppc}, |
2620 | @option{ppc32}, @option{ppc64}, @option{ppc64bridge}, @option{ppcps}, | |
2621 | @option{pwr}, @option{pwr2}, @option{pwr4}, @option{pwr5}, @option{pwr5x}, | |
2622 | @option{pwr6}, @option{pwr7}, @option{pwr8}, @option{pwr9}, @option{pwr10}, | |
52be03fd AM |
2623 | @option{pwrx}, @option{titan}, and @option{vle}. |
2624 | @option{32} and @option{64} modify the default or a prior CPU | |
2625 | selection, disabling and enabling 64-bit insns respectively. In | |
2626 | addition, @option{altivec}, @option{any}, @option{htm}, @option{vsx}, | |
2627 | and @option{spe} add capabilities to a previous @emph{or later} CPU | |
2628 | selection. @option{any} will disassemble any opcode known to | |
2629 | binutils, but in cases where an opcode has two different meanings or | |
2630 | different arguments, you may not see the disassembly you expect. | |
2631 | If you disassemble without giving a CPU selection, a default will be | |
2632 | chosen from information gleaned by BFD from the object files headers, | |
2633 | but the result again may not be as you expect. | |
802a735e | 2634 | |
b45619c0 | 2635 | For MIPS, this option controls the printing of instruction mnemonic |
e39893d7 FF |
2636 | names and register names in disassembled instructions. Multiple |
2637 | selections from the following may be specified as a comma separated | |
2638 | string, and invalid options are ignored: | |
640c0ccd CD |
2639 | |
2640 | @table @code | |
e39893d7 | 2641 | @item no-aliases |
b45619c0 NC |
2642 | Print the 'raw' instruction mnemonic instead of some pseudo |
2643 | instruction mnemonic. I.e., print 'daddu' or 'or' instead of 'move', | |
e39893d7 FF |
2644 | 'sll' instead of 'nop', etc. |
2645 | ||
a9f58168 CF |
2646 | @item msa |
2647 | Disassemble MSA instructions. | |
2648 | ||
b015e599 AP |
2649 | @item virt |
2650 | Disassemble the virtualization ASE instructions. | |
2651 | ||
7d64c587 AB |
2652 | @item xpa |
2653 | Disassemble the eXtended Physical Address (XPA) ASE instructions. | |
2654 | ||
640c0ccd CD |
2655 | @item gpr-names=@var{ABI} |
2656 | Print GPR (general-purpose register) names as appropriate | |
2657 | for the specified ABI. By default, GPR names are selected according to | |
2658 | the ABI of the binary being disassembled. | |
2659 | ||
2660 | @item fpr-names=@var{ABI} | |
2661 | Print FPR (floating-point register) names as | |
2662 | appropriate for the specified ABI. By default, FPR numbers are printed | |
2663 | rather than names. | |
2664 | ||
2665 | @item cp0-names=@var{ARCH} | |
2666 | Print CP0 (system control coprocessor; coprocessor 0) register names | |
2667 | as appropriate for the CPU or architecture specified by | |
2668 | @var{ARCH}. By default, CP0 register names are selected according to | |
2669 | the architecture and CPU of the binary being disassembled. | |
2670 | ||
af7ee8bf CD |
2671 | @item hwr-names=@var{ARCH} |
2672 | Print HWR (hardware register, used by the @code{rdhwr} instruction) names | |
2673 | as appropriate for the CPU or architecture specified by | |
2674 | @var{ARCH}. By default, HWR names are selected according to | |
2675 | the architecture and CPU of the binary being disassembled. | |
2676 | ||
640c0ccd CD |
2677 | @item reg-names=@var{ABI} |
2678 | Print GPR and FPR names as appropriate for the selected ABI. | |
2679 | ||
2680 | @item reg-names=@var{ARCH} | |
af7ee8bf CD |
2681 | Print CPU-specific register names (CP0 register and HWR names) |
2682 | as appropriate for the selected CPU or architecture. | |
640c0ccd CD |
2683 | @end table |
2684 | ||
2685 | For any of the options listed above, @var{ABI} or | |
2686 | @var{ARCH} may be specified as @samp{numeric} to have numbers printed | |
2687 | rather than names, for the selected types of registers. | |
2688 | You can list the available values of @var{ABI} and @var{ARCH} using | |
2689 | the @option{--help} option. | |
2690 | ||
ec72cfe5 NC |
2691 | For VAX, you can specify function entry addresses with @option{-M |
2692 | entry:0xf00ba}. You can use this multiple times to properly | |
2693 | disassemble VAX binary files that don't contain symbol tables (like | |
2694 | ROM dumps). In these cases, the function entry mask would otherwise | |
b45619c0 | 2695 | be decoded as VAX instructions, which would probably lead the rest |
ec72cfe5 NC |
2696 | of the function being wrongly disassembled. |
2697 | ||
252b5132 RH |
2698 | @item -p |
2699 | @itemx --private-headers | |
2700 | Print information that is specific to the object file format. The exact | |
2701 | information printed depends upon the object file format. For some | |
2702 | object file formats, no additional information is printed. | |
2703 | ||
6abcee90 TG |
2704 | @item -P @var{options} |
2705 | @itemx --private=@var{options} | |
2706 | Print information that is specific to the object file format. The | |
2707 | argument @var{options} is a comma separated list that depends on the | |
2708 | format (the lists of options is displayed with the help). | |
2709 | ||
c4416f30 NC |
2710 | For XCOFF, the available options are: |
2711 | @table @code | |
2712 | @item header | |
2713 | @item aout | |
2714 | @item sections | |
2715 | @item syms | |
2716 | @item relocs | |
2717 | @item lineno, | |
2718 | @item loader | |
2719 | @item except | |
2720 | @item typchk | |
2721 | @item traceback | |
2722 | @item toc | |
2723 | @item ldinfo | |
2724 | @end table | |
2725 | ||
2726 | Not all object formats support this option. In particular the ELF | |
2727 | format does not use it. | |
6abcee90 | 2728 | |
252b5132 RH |
2729 | @item -r |
2730 | @itemx --reloc | |
2731 | @cindex relocation entries, in object file | |
c7c55b78 NC |
2732 | Print the relocation entries of the file. If used with @option{-d} or |
2733 | @option{-D}, the relocations are printed interspersed with the | |
252b5132 RH |
2734 | disassembly. |
2735 | ||
2736 | @item -R | |
2737 | @itemx --dynamic-reloc | |
2738 | @cindex dynamic relocation entries, in object file | |
2739 | Print the dynamic relocation entries of the file. This is only | |
2740 | meaningful for dynamic objects, such as certain types of shared | |
840b96a7 AM |
2741 | libraries. As for @option{-r}, if used with @option{-d} or |
2742 | @option{-D}, the relocations are printed interspersed with the | |
2743 | disassembly. | |
252b5132 RH |
2744 | |
2745 | @item -s | |
2746 | @itemx --full-contents | |
2747 | @cindex sections, full contents | |
2748 | @cindex object file sections | |
155e0d23 NC |
2749 | Display the full contents of any sections requested. By default all |
2750 | non-empty sections are displayed. | |
252b5132 RH |
2751 | |
2752 | @item -S | |
2753 | @itemx --source | |
2754 | @cindex source disassembly | |
2755 | @cindex disassembly, with source | |
2756 | Display source code intermixed with disassembly, if possible. Implies | |
c7c55b78 | 2757 | @option{-d}. |
252b5132 | 2758 | |
a1c110a3 NC |
2759 | @item --source-comment[=@var{txt}] |
2760 | @cindex source disassembly | |
2761 | @cindex disassembly, with source | |
2762 | Like the @option{-S} option, but all source code lines are displayed | |
2763 | with a prefix of @var{txt}. Typically @var{txt} will be a comment | |
2764 | string which can be used to distinguish the assembler code from the | |
2765 | source code. If @var{txt} is not provided then a default string of | |
2766 | @var{``# ``} (hash followed by a space), will be used. | |
2767 | ||
0dafdf3f L |
2768 | @item --prefix=@var{prefix} |
2769 | @cindex Add prefix to absolute paths | |
2770 | Specify @var{prefix} to add to the absolute paths when used with | |
b3364cb9 | 2771 | @option{-S}. |
0dafdf3f L |
2772 | |
2773 | @item --prefix-strip=@var{level} | |
2774 | @cindex Strip absolute paths | |
2775 | Indicate how many initial directory names to strip off the hardwired | |
2776 | absolute paths. It has no effect without @option{--prefix=}@var{prefix}. | |
2777 | ||
252b5132 RH |
2778 | @item --show-raw-insn |
2779 | When disassembling instructions, print the instruction in hex as well as | |
2780 | in symbolic form. This is the default except when | |
c7c55b78 | 2781 | @option{--prefix-addresses} is used. |
252b5132 RH |
2782 | |
2783 | @item --no-show-raw-insn | |
2784 | When disassembling instructions, do not print the instruction bytes. | |
c7c55b78 | 2785 | This is the default when @option{--prefix-addresses} is used. |
252b5132 | 2786 | |
3dcb3fcb | 2787 | @item --insn-width=@var{width} |
b3364cb9 | 2788 | @cindex Instruction width |
3dcb3fcb L |
2789 | Display @var{width} bytes on a single line when disassembling |
2790 | instructions. | |
2791 | ||
1d67fe3b TT |
2792 | @item --visualize-jumps[=color|=extended-color|=off] |
2793 | Visualize jumps that stay inside a function by drawing ASCII art between | |
2794 | the start and target addresses. The optional @option{=color} argument | |
2795 | adds color to the output using simple terminal colors. Alternatively | |
2796 | the @option{=extended-color} argument will add color using 8bit | |
2797 | colors, but these might not work on all terminals. | |
2798 | ||
2799 | If it is necessary to disable the @option{visualize-jumps} option | |
2800 | after it has previously been enabled then use | |
2801 | @option{visualize-jumps=off}. | |
2802 | ||
e4b7104b NC |
2803 | @item -W[lLiaprmfFsoORtUuTgAckK] |
2804 | @itemx --dwarf[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=str-offsets,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index,=addr,=cu_index,=links,=follow-links] | |
dda8d76d | 2805 | @include debug.options.texi |
fd2f0033 | 2806 | |
4723351a CC |
2807 | @item --dwarf-check |
2808 | Enable additional checks for consistency of Dwarf information. | |
2809 | ||
7d9813f1 NA |
2810 | @include ctf.options.texi |
2811 | ||
1dada9c5 | 2812 | @item -G |
947ed062 | 2813 | @itemx --stabs |
252b5132 RH |
2814 | @cindex stab |
2815 | @cindex .stab | |
2816 | @cindex debug symbols | |
2817 | @cindex ELF object file format | |
2818 | Display the full contents of any sections requested. Display the | |
2819 | contents of the .stab and .stab.index and .stab.excl sections from an | |
2820 | ELF file. This is only useful on systems (such as Solaris 2.0) in which | |
2821 | @code{.stab} debugging symbol-table entries are carried in an ELF | |
2822 | section. In most other file formats, debugging symbol-table entries are | |
c7c55b78 | 2823 | interleaved with linkage symbols, and are visible in the @option{--syms} |
0285c67d | 2824 | output. |
252b5132 RH |
2825 | |
2826 | @item --start-address=@var{address} | |
2827 | @cindex start-address | |
2828 | Start displaying data at the specified address. This affects the output | |
c7c55b78 | 2829 | of the @option{-d}, @option{-r} and @option{-s} options. |
252b5132 RH |
2830 | |
2831 | @item --stop-address=@var{address} | |
2832 | @cindex stop-address | |
2833 | Stop displaying data at the specified address. This affects the output | |
c7c55b78 | 2834 | of the @option{-d}, @option{-r} and @option{-s} options. |
252b5132 RH |
2835 | |
2836 | @item -t | |
2837 | @itemx --syms | |
2838 | @cindex symbol table entries, printing | |
2839 | Print the symbol table entries of the file. | |
a1039809 NC |
2840 | This is similar to the information provided by the @samp{nm} program, |
2841 | although the display format is different. The format of the output | |
2842 | depends upon the format of the file being dumped, but there are two main | |
2843 | types. One looks like this: | |
2844 | ||
2845 | @smallexample | |
2846 | [ 4](sec 3)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .bss | |
2847 | [ 6](sec 1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 fred | |
2848 | @end smallexample | |
2849 | ||
2850 | where the number inside the square brackets is the number of the entry | |
2851 | in the symbol table, the @var{sec} number is the section number, the | |
2852 | @var{fl} value are the symbol's flag bits, the @var{ty} number is the | |
2853 | symbol's type, the @var{scl} number is the symbol's storage class and | |
0cc79db2 | 2854 | the @var{nx} value is the number of auxiliary entries associated with |
a1039809 NC |
2855 | the symbol. The last two fields are the symbol's value and its name. |
2856 | ||
2857 | The other common output format, usually seen with ELF based files, | |
2858 | looks like this: | |
2859 | ||
2860 | @smallexample | |
2861 | 00000000 l d .bss 00000000 .bss | |
2862 | 00000000 g .text 00000000 fred | |
2863 | @end smallexample | |
2864 | ||
0cc79db2 | 2865 | Here the first number is the symbol's value (sometimes referred to as |
a1039809 NC |
2866 | its address). The next field is actually a set of characters and |
2867 | spaces indicating the flag bits that are set on the symbol. These | |
af3e16d9 NC |
2868 | characters are described below. Next is the section with which the |
2869 | symbol is associated or @emph{*ABS*} if the section is absolute (ie | |
2870 | not connected with any section), or @emph{*UND*} if the section is | |
2871 | referenced in the file being dumped, but not defined there. | |
2872 | ||
2873 | After the section name comes another field, a number, which for common | |
2874 | symbols is the alignment and for other symbol is the size. Finally | |
2875 | the symbol's name is displayed. | |
a1039809 NC |
2876 | |
2877 | The flag characters are divided into 7 groups as follows: | |
2878 | @table @code | |
2879 | @item l | |
2880 | @itemx g | |
3e7a7d11 | 2881 | @itemx u |
a1039809 | 2882 | @itemx ! |
3e7a7d11 NC |
2883 | The symbol is a local (l), global (g), unique global (u), neither |
2884 | global nor local (a space) or both global and local (!). A | |
928a4139 | 2885 | symbol can be neither local or global for a variety of reasons, e.g., |
a1039809 | 2886 | because it is used for debugging, but it is probably an indication of |
3e7a7d11 NC |
2887 | a bug if it is ever both local and global. Unique global symbols are |
2888 | a GNU extension to the standard set of ELF symbol bindings. For such | |
2889 | a symbol the dynamic linker will make sure that in the entire process | |
2890 | there is just one symbol with this name and type in use. | |
a1039809 NC |
2891 | |
2892 | @item w | |
2893 | The symbol is weak (w) or strong (a space). | |
2894 | ||
2895 | @item C | |
2896 | The symbol denotes a constructor (C) or an ordinary symbol (a space). | |
2897 | ||
2898 | @item W | |
2899 | The symbol is a warning (W) or a normal symbol (a space). A warning | |
2900 | symbol's name is a message to be displayed if the symbol following the | |
2901 | warning symbol is ever referenced. | |
2902 | ||
2903 | @item I | |
171191ba NC |
2904 | @item i |
2905 | The symbol is an indirect reference to another symbol (I), a function | |
2906 | to be evaluated during reloc processing (i) or a normal symbol (a | |
2907 | space). | |
a1039809 NC |
2908 | |
2909 | @item d | |
2910 | @itemx D | |
2911 | The symbol is a debugging symbol (d) or a dynamic symbol (D) or a | |
2912 | normal symbol (a space). | |
2913 | ||
2914 | @item F | |
2915 | @item f | |
2916 | @item O | |
af3e16d9 | 2917 | The symbol is the name of a function (F) or a file (f) or an object |
a1039809 NC |
2918 | (O) or just a normal symbol (a space). |
2919 | @end table | |
252b5132 RH |
2920 | |
2921 | @item -T | |
2922 | @itemx --dynamic-syms | |
2923 | @cindex dynamic symbol table entries, printing | |
2924 | Print the dynamic symbol table entries of the file. This is only | |
2925 | meaningful for dynamic objects, such as certain types of shared | |
2926 | libraries. This is similar to the information provided by the @samp{nm} | |
c7c55b78 | 2927 | program when given the @option{-D} (@option{--dynamic}) option. |
252b5132 | 2928 | |
df2c87b5 NC |
2929 | The output format is similar to that produced by the @option{--syms} |
2930 | option, except that an extra field is inserted before the symbol's | |
2931 | name, giving the version information associated with the symbol. | |
2f7d9953 NC |
2932 | If the version is the default version to be used when resolving |
2933 | unversioned references to the symbol then it's displayed as is, | |
2934 | otherwise it's put into parentheses. | |
df2c87b5 | 2935 | |
3c9458e9 NC |
2936 | @item --special-syms |
2937 | When displaying symbols include those which the target considers to be | |
2938 | special in some way and which would not normally be of interest to the | |
2939 | user. | |
2940 | ||
b3aa80b4 NC |
2941 | @item -U @var{[d|i|l|e|x|h]} |
2942 | @itemx --unicode=@var{[default|invalid|locale|escape|hex|highlight]} | |
2943 | Controls the display of UTF-8 encoded mulibyte characters in strings. | |
2944 | The default (@option{--unicode=default}) is to give them no special | |
2945 | treatment. The @option{--unicode=locale} option displays the sequence | |
2946 | in the current locale, which may or may not support them. The options | |
2947 | @option{--unicode=hex} and @option{--unicode=invalid} display them as | |
2948 | hex byte sequences enclosed by either angle brackets or curly braces. | |
2949 | ||
2950 | The @option{--unicode=escape} option displays them as escape sequences | |
2951 | (@var{\uxxxx}) and the @option{--unicode=highlight} option displays | |
2952 | them as escape sequences highlighted in red (if supported by the | |
2953 | output device). The colouring is intended to draw attention to the | |
2954 | presence of unicode sequences where they might not be expected. | |
2955 | ||
947ed062 NC |
2956 | @item -V |
2957 | @itemx --version | |
c7c55b78 | 2958 | Print the version number of @command{objdump} and exit. |
252b5132 RH |
2959 | |
2960 | @item -x | |
947ed062 | 2961 | @itemx --all-headers |
252b5132 RH |
2962 | @cindex all header information, object file |
2963 | @cindex header information, all | |
2964 | Display all available header information, including the symbol table and | |
c7c55b78 | 2965 | relocation entries. Using @option{-x} is equivalent to specifying all of |
04c34128 | 2966 | @option{-a -f -h -p -r -t}. |
252b5132 RH |
2967 | |
2968 | @item -w | |
2969 | @itemx --wide | |
2970 | @cindex wide output, printing | |
2971 | Format some lines for output devices that have more than 80 columns. | |
31104126 | 2972 | Also do not truncate symbol names when they are displayed. |
aefbdd67 BE |
2973 | |
2974 | @item -z | |
2c0c15f9 | 2975 | @itemx --disassemble-zeroes |
aefbdd67 BE |
2976 | Normally the disassembly output will skip blocks of zeroes. This |
2977 | option directs the disassembler to disassemble those blocks, just like | |
2978 | any other data. | |
252b5132 RH |
2979 | @end table |
2980 | ||
0285c67d NC |
2981 | @c man end |
2982 | ||
2983 | @ignore | |
2984 | @c man begin SEEALSO objdump | |
2985 | nm(1), readelf(1), and the Info entries for @file{binutils}. | |
2986 | @c man end | |
2987 | @end ignore | |
2988 | ||
252b5132 RH |
2989 | @node ranlib |
2990 | @chapter ranlib | |
2991 | ||
2992 | @kindex ranlib | |
2993 | @cindex archive contents | |
2994 | @cindex symbol index | |
2995 | ||
f927cc8f | 2996 | @c man title ranlib generate an index to an archive |
0285c67d | 2997 | |
252b5132 | 2998 | @smallexample |
0285c67d | 2999 | @c man begin SYNOPSIS ranlib |
36e32b27 | 3000 | ranlib [@option{--plugin} @var{name}] [@option{-DhHvVt}] @var{archive} |
0285c67d | 3001 | @c man end |
252b5132 RH |
3002 | @end smallexample |
3003 | ||
0285c67d NC |
3004 | @c man begin DESCRIPTION ranlib |
3005 | ||
c7c55b78 | 3006 | @command{ranlib} generates an index to the contents of an archive and |
252b5132 | 3007 | stores it in the archive. The index lists each symbol defined by a |
c1c0eb9e | 3008 | member of an archive that is a relocatable object file. |
252b5132 RH |
3009 | |
3010 | You may use @samp{nm -s} or @samp{nm --print-armap} to list this index. | |
3011 | ||
3012 | An archive with such an index speeds up linking to the library and | |
3013 | allows routines in the library to call each other without regard to | |
3014 | their placement in the archive. | |
3015 | ||
c7c55b78 NC |
3016 | The @sc{gnu} @command{ranlib} program is another form of @sc{gnu} @command{ar}; running |
3017 | @command{ranlib} is completely equivalent to executing @samp{ar -s}. | |
252b5132 RH |
3018 | @xref{ar}. |
3019 | ||
0285c67d NC |
3020 | @c man end |
3021 | ||
3022 | @c man begin OPTIONS ranlib | |
3023 | ||
c7c55b78 | 3024 | @table @env |
b3364cb9 RM |
3025 | @item -h |
3026 | @itemx -H | |
3027 | @itemx --help | |
3028 | Show usage information for @command{ranlib}. | |
3029 | ||
252b5132 RH |
3030 | @item -v |
3031 | @itemx -V | |
f20a759a | 3032 | @itemx --version |
c7c55b78 | 3033 | Show the version number of @command{ranlib}. |
b14f9da0 | 3034 | |
b3364cb9 RM |
3035 | @item -D |
3036 | @cindex deterministic archives | |
9cb80f72 | 3037 | @kindex --enable-deterministic-archives |
b3364cb9 RM |
3038 | Operate in @emph{deterministic} mode. The symbol map archive member's |
3039 | header will show zero for the UID, GID, and timestamp. When this | |
3040 | option is used, multiple runs will produce identical output files. | |
3041 | ||
e956b7d3 NC |
3042 | If @file{binutils} was configured with |
3043 | @option{--enable-deterministic-archives}, then this mode is on by | |
3044 | default. It can be disabled with the @samp{-U} option, described | |
3045 | below. | |
9cb80f72 | 3046 | |
b14f9da0 NC |
3047 | @item -t |
3048 | Update the timestamp of the symbol map of an archive. | |
9cb80f72 RM |
3049 | |
3050 | @item -U | |
3051 | @cindex deterministic archives | |
3052 | @kindex --enable-deterministic-archives | |
3053 | Do @emph{not} operate in @emph{deterministic} mode. This is the | |
3054 | inverse of the @samp{-D} option, above: the archive index will get | |
3055 | actual UID, GID, timestamp, and file mode values. | |
3056 | ||
e956b7d3 NC |
3057 | If @file{binutils} was configured @emph{without} |
3058 | @option{--enable-deterministic-archives}, then this mode is on by | |
3059 | default. | |
3060 | ||
252b5132 RH |
3061 | @end table |
3062 | ||
0285c67d NC |
3063 | @c man end |
3064 | ||
3065 | @ignore | |
3066 | @c man begin SEEALSO ranlib | |
3067 | ar(1), nm(1), and the Info entries for @file{binutils}. | |
3068 | @c man end | |
3069 | @end ignore | |
3070 | ||
252b5132 RH |
3071 | @node size |
3072 | @chapter size | |
3073 | ||
3074 | @kindex size | |
3075 | @cindex section sizes | |
3076 | ||
f927cc8f | 3077 | @c man title size list section sizes and total size of binary files |
0285c67d | 3078 | |
252b5132 | 3079 | @smallexample |
0285c67d | 3080 | @c man begin SYNOPSIS size |
46cbf38d | 3081 | size [@option{-A}|@option{-B}|@option{-G}|@option{--format=}@var{compatibility}] |
15c82623 NC |
3082 | [@option{--help}] |
3083 | [@option{-d}|@option{-o}|@option{-x}|@option{--radix=}@var{number}] | |
29422971 | 3084 | [@option{--common}] |
15c82623 | 3085 | [@option{-t}|@option{--totals}] |
c1c0eb9e | 3086 | [@option{--target=}@var{bfdname}] [@option{-V}|@option{--version}] |
c7c55b78 | 3087 | [@var{objfile}@dots{}] |
0285c67d | 3088 | @c man end |
252b5132 RH |
3089 | @end smallexample |
3090 | ||
0285c67d NC |
3091 | @c man begin DESCRIPTION size |
3092 | ||
f927cc8f NC |
3093 | The @sc{gnu} @command{size} utility lists the section sizes and the total |
3094 | size for each of the binary files @var{objfile} on its argument list. | |
3095 | By default, one line of output is generated for each file or each | |
3096 | module if the file is an archive. | |
252b5132 | 3097 | |
f927cc8f NC |
3098 | @var{objfile}@dots{} are the files to be examined. If none are |
3099 | specified, the file @code{a.out} will be used instead. | |
252b5132 | 3100 | |
0285c67d NC |
3101 | @c man end |
3102 | ||
3103 | @c man begin OPTIONS size | |
3104 | ||
a05a5b64 | 3105 | The command-line options have the following meanings: |
252b5132 | 3106 | |
c7c55b78 | 3107 | @table @env |
252b5132 RH |
3108 | @item -A |
3109 | @itemx -B | |
46cbf38d | 3110 | @itemx -G |
252b5132 | 3111 | @itemx --format=@var{compatibility} |
c7c55b78 | 3112 | @cindex @command{size} display format |
252b5132 | 3113 | Using one of these options, you can choose whether the output from @sc{gnu} |
c7c55b78 NC |
3114 | @command{size} resembles output from System V @command{size} (using @option{-A}, |
3115 | or @option{--format=sysv}), or Berkeley @command{size} (using @option{-B}, or | |
3116 | @option{--format=berkeley}). The default is the one-line format similar to | |
46cbf38d AB |
3117 | Berkeley's. Alternatively, you can choose the GNU format output |
3118 | (using @option{-G}, or @option{--format=gnu}), this is similar to | |
3119 | Berkeley's output format, but sizes are counted differently. | |
252b5132 RH |
3120 | @c Bonus for doc-source readers: you can also say --format=strange (or |
3121 | @c anything else that starts with 's') for sysv, and --format=boring (or | |
3122 | @c anything else that starts with 'b') for Berkeley. | |
3123 | ||
3124 | Here is an example of the Berkeley (default) format of output from | |
c1c0eb9e | 3125 | @command{size}: |
252b5132 | 3126 | @smallexample |
f20a759a | 3127 | $ size --format=Berkeley ranlib size |
96fd92af AB |
3128 | text data bss dec hex filename |
3129 | 294880 81920 11592 388392 5ed28 ranlib | |
3130 | 294880 81920 11888 388688 5ee50 size | |
252b5132 RH |
3131 | @end smallexample |
3132 | ||
46cbf38d AB |
3133 | The Berkeley style output counts read only data in the @code{text} |
3134 | column, not in the @code{data} column, the @code{dec} and @code{hex} | |
3135 | columns both display the sum of the @code{text}, @code{data}, and | |
3136 | @code{bss} columns in decimal and hexadecimal respectively. | |
3137 | ||
3138 | The GNU format counts read only data in the @code{data} column, not | |
3139 | the @code{text} column, and only displays the sum of the @code{text}, | |
3140 | @code{data}, and @code{bss} columns once, in the @code{total} column. | |
3141 | The @option{--radix} option can be used to change the number base for | |
3142 | all columns. Here is the same data displayed with GNU conventions: | |
3143 | ||
3144 | @smallexample | |
3145 | $ size --format=GNU ranlib size | |
3146 | text data bss total filename | |
3147 | 279880 96920 11592 388392 ranlib | |
3148 | 279880 96920 11888 388688 size | |
3149 | @end smallexample | |
3150 | ||
252b5132 RH |
3151 | @noindent |
3152 | This is the same data, but displayed closer to System V conventions: | |
3153 | ||
3154 | @smallexample | |
f20a759a | 3155 | $ size --format=SysV ranlib size |
252b5132 RH |
3156 | ranlib : |
3157 | section size addr | |
c1c0eb9e RM |
3158 | .text 294880 8192 |
3159 | .data 81920 303104 | |
3160 | .bss 11592 385024 | |
3161 | Total 388392 | |
252b5132 RH |
3162 | |
3163 | ||
3164 | size : | |
3165 | section size addr | |
c1c0eb9e RM |
3166 | .text 294880 8192 |
3167 | .data 81920 303104 | |
3168 | .bss 11888 385024 | |
3169 | Total 388688 | |
252b5132 RH |
3170 | @end smallexample |
3171 | ||
3172 | @item --help | |
3173 | Show a summary of acceptable arguments and options. | |
3174 | ||
3175 | @item -d | |
3176 | @itemx -o | |
3177 | @itemx -x | |
3178 | @itemx --radix=@var{number} | |
c7c55b78 | 3179 | @cindex @command{size} number format |
252b5132 RH |
3180 | @cindex radix for section sizes |
3181 | Using one of these options, you can control whether the size of each | |
c7c55b78 NC |
3182 | section is given in decimal (@option{-d}, or @option{--radix=10}); octal |
3183 | (@option{-o}, or @option{--radix=8}); or hexadecimal (@option{-x}, or | |
3184 | @option{--radix=16}). In @option{--radix=@var{number}}, only the three | |
252b5132 | 3185 | values (8, 10, 16) are supported. The total size is always given in two |
c7c55b78 NC |
3186 | radices; decimal and hexadecimal for @option{-d} or @option{-x} output, or |
3187 | octal and hexadecimal if you're using @option{-o}. | |
252b5132 | 3188 | |
29422971 AM |
3189 | @item --common |
3190 | Print total size of common symbols in each file. When using Berkeley | |
46cbf38d | 3191 | or GNU format these are included in the bss size. |
29422971 | 3192 | |
15c82623 NC |
3193 | @item -t |
3194 | @itemx --totals | |
46cbf38d | 3195 | Show totals of all objects listed (Berkeley or GNU format mode only). |
15c82623 | 3196 | |
252b5132 RH |
3197 | @item --target=@var{bfdname} |
3198 | @cindex object code format | |
3199 | Specify that the object-code format for @var{objfile} is | |
c7c55b78 | 3200 | @var{bfdname}. This option may not be necessary; @command{size} can |
252b5132 RH |
3201 | automatically recognize many formats. |
3202 | @xref{Target Selection}, for more information. | |
3203 | ||
3204 | @item -V | |
3205 | @itemx --version | |
c7c55b78 | 3206 | Display the version number of @command{size}. |
252b5132 RH |
3207 | @end table |
3208 | ||
0285c67d NC |
3209 | @c man end |
3210 | ||
3211 | @ignore | |
3212 | @c man begin SEEALSO size | |
3213 | ar(1), objdump(1), readelf(1), and the Info entries for @file{binutils}. | |
3214 | @c man end | |
3215 | @end ignore | |
3216 | ||
252b5132 RH |
3217 | @node strings |
3218 | @chapter strings | |
3219 | @kindex strings | |
3220 | @cindex listings strings | |
3221 | @cindex printing strings | |
3222 | @cindex strings, printing | |
3223 | ||
f927cc8f | 3224 | @c man title strings print the sequences of printable characters in files |
0285c67d | 3225 | |
252b5132 | 3226 | @smallexample |
0285c67d | 3227 | @c man begin SYNOPSIS strings |
ffbe5983 | 3228 | strings [@option{-afovV}] [@option{-}@var{min-len}] |
d132876a NC |
3229 | [@option{-n} @var{min-len}] [@option{--bytes=}@var{min-len}] |
3230 | [@option{-t} @var{radix}] [@option{--radix=}@var{radix}] | |
3231 | [@option{-e} @var{encoding}] [@option{--encoding=}@var{encoding}] | |
b3aa80b4 | 3232 | [@option{-U} @var{method}] [@option{--unicode=}@var{method}] |
d132876a | 3233 | [@option{-}] [@option{--all}] [@option{--print-file-name}] |
3bf31ec9 | 3234 | [@option{-T} @var{bfdname}] [@option{--target=}@var{bfdname}] |
334ac421 | 3235 | [@option{-w}] [@option{--include-all-whitespace}] |
55edd97b | 3236 | [@option{-s}] [@option{--output-separator}@var{sep_string}] |
c7c55b78 | 3237 | [@option{--help}] [@option{--version}] @var{file}@dots{} |
0285c67d | 3238 | @c man end |
252b5132 RH |
3239 | @end smallexample |
3240 | ||
0285c67d NC |
3241 | @c man begin DESCRIPTION strings |
3242 | ||
7fac9594 NC |
3243 | For each @var{file} given, @sc{gnu} @command{strings} prints the |
3244 | printable character sequences that are at least 4 characters long (or | |
3245 | the number given with the options below) and are followed by an | |
3246 | unprintable character. | |
252b5132 | 3247 | |
7fac9594 NC |
3248 | Depending upon how the strings program was configured it will default |
3249 | to either displaying all the printable sequences that it can find in | |
3250 | each file, or only those sequences that are in loadable, initialized | |
b37a7714 | 3251 | data sections. If the file type is unrecognizable, or if strings is |
7fac9594 NC |
3252 | reading from stdin then it will always display all of the printable |
3253 | sequences that it can find. | |
3254 | ||
a05a5b64 | 3255 | For backwards compatibility any file that occurs after a command-line |
7fac9594 | 3256 | option of just @option{-} will also be scanned in full, regardless of |
37d0d091 | 3257 | the presence of any @option{-d} option. |
7fac9594 NC |
3258 | |
3259 | @command{strings} is mainly useful for determining the contents of | |
3260 | non-text files. | |
252b5132 | 3261 | |
0285c67d NC |
3262 | @c man end |
3263 | ||
3264 | @c man begin OPTIONS strings | |
3265 | ||
c7c55b78 | 3266 | @table @env |
252b5132 RH |
3267 | @item -a |
3268 | @itemx --all | |
3269 | @itemx - | |
7fac9594 NC |
3270 | Scan the whole file, regardless of what sections it contains or |
3271 | whether those sections are loaded or initialized. Normally this is | |
3272 | the default behaviour, but strings can be configured so that the | |
3273 | @option{-d} is the default instead. | |
3274 | ||
3275 | The @option{-} option is position dependent and forces strings to | |
3276 | perform full scans of any file that is mentioned after the @option{-} | |
3277 | on the command line, even if the @option{-d} option has been | |
3278 | specified. | |
3279 | ||
3280 | @item -d | |
3281 | @itemx --data | |
3282 | Only print strings from initialized, loaded data sections in the | |
3283 | file. This may reduce the amount of garbage in the output, but it | |
3284 | also exposes the strings program to any security flaws that may be | |
3285 | present in the BFD library used to scan and load sections. Strings | |
3286 | can be configured so that this option is the default behaviour. In | |
3287 | such cases the @option{-a} option can be used to avoid using the BFD | |
3288 | library and instead just print all of the strings found in the file. | |
252b5132 RH |
3289 | |
3290 | @item -f | |
3291 | @itemx --print-file-name | |
3292 | Print the name of the file before each string. | |
3293 | ||
3294 | @item --help | |
3295 | Print a summary of the program usage on the standard output and exit. | |
3296 | ||
3297 | @item -@var{min-len} | |
3298 | @itemx -n @var{min-len} | |
3299 | @itemx --bytes=@var{min-len} | |
3300 | Print sequences of characters that are at least @var{min-len} characters | |
3301 | long, instead of the default 4. | |
3302 | ||
3303 | @item -o | |
c7c55b78 | 3304 | Like @samp{-t o}. Some other versions of @command{strings} have @option{-o} |
252b5132 RH |
3305 | act like @samp{-t d} instead. Since we can not be compatible with both |
3306 | ways, we simply chose one. | |
3307 | ||
3308 | @item -t @var{radix} | |
3309 | @itemx --radix=@var{radix} | |
3310 | Print the offset within the file before each string. The single | |
3311 | character argument specifies the radix of the offset---@samp{o} for | |
3312 | octal, @samp{x} for hexadecimal, or @samp{d} for decimal. | |
3313 | ||
d132876a NC |
3314 | @item -e @var{encoding} |
3315 | @itemx --encoding=@var{encoding} | |
3316 | Select the character encoding of the strings that are to be found. | |
8745eafa NC |
3317 | Possible values for @var{encoding} are: @samp{s} = single-7-bit-byte |
3318 | characters (ASCII, ISO 8859, etc., default), @samp{S} = | |
3319 | single-8-bit-byte characters, @samp{b} = 16-bit bigendian, @samp{l} = | |
3320 | 16-bit littleendian, @samp{B} = 32-bit bigendian, @samp{L} = 32-bit | |
830bf75c NC |
3321 | littleendian. Useful for finding wide character strings. (@samp{l} |
3322 | and @samp{b} apply to, for example, Unicode UTF-16/UCS-2 encodings). | |
d132876a | 3323 | |
b3aa80b4 NC |
3324 | @item -U @var{[d|i|l|e|x|h]} |
3325 | @itemx --unicode=@var{[default|invalid|locale|escape|hex|highlight]} | |
3326 | Controls the display of UTF-8 encoded mulibyte characters in strings. | |
3327 | The default (@option{--unicode=default}) is to give them no special | |
3328 | treatment, and instead rely upon the setting of the | |
3329 | @option{--encoding} option. The other values for this option | |
3330 | automatically enable @option{--encoding=S}. | |
3331 | ||
3332 | The @option{--unicode=invalid} option treats them as non-graphic | |
3333 | characters and hence not part of a valid string. All the remaining | |
3334 | options treat them as valid string characters. | |
3335 | ||
3336 | The @option{--unicode=locale} option displays them in the current | |
3337 | locale, which may or may not support UTF-8 encoding. The | |
3338 | @option{--unicode=hex} option displays them as hex byte sequences | |
3339 | enclosed between @var{<>} characters. The @option{--unicode=escape} | |
3340 | option displays them as escape sequences (@var{\uxxxx}) and the | |
3341 | @option{--unicode=highlight} option displays them as escape sequences | |
3342 | highlighted in red (if supported by the output device). The colouring | |
3343 | is intended to draw attention to the presence of unicode sequences | |
3344 | where they might not be expected. | |
3345 | ||
3bf31ec9 NC |
3346 | @item -T @var{bfdname} |
3347 | @itemx --target=@var{bfdname} | |
252b5132 RH |
3348 | @cindex object code format |
3349 | Specify an object code format other than your system's default format. | |
3350 | @xref{Target Selection}, for more information. | |
3351 | ||
3352 | @item -v | |
ffbe5983 | 3353 | @itemx -V |
252b5132 RH |
3354 | @itemx --version |
3355 | Print the program version number on the standard output and exit. | |
334ac421 EA |
3356 | |
3357 | @item -w | |
3358 | @itemx --include-all-whitespace | |
3359 | By default tab and space characters are included in the strings that | |
3360 | are displayed, but other whitespace characters, such a newlines and | |
3361 | carriage returns, are not. The @option{-w} option changes this so | |
3362 | that all whitespace characters are considered to be part of a string. | |
55edd97b EA |
3363 | |
3364 | @item -s | |
3365 | @itemx --output-separator | |
3366 | By default, output strings are delimited by a new-line. This option | |
3367 | allows you to supply any string to be used as the output record | |
3368 | separator. Useful with --include-all-whitespace where strings | |
3369 | may contain new-lines internally. | |
252b5132 RH |
3370 | @end table |
3371 | ||
0285c67d NC |
3372 | @c man end |
3373 | ||
3374 | @ignore | |
3375 | @c man begin SEEALSO strings | |
3376 | ar(1), nm(1), objdump(1), ranlib(1), readelf(1) | |
3377 | and the Info entries for @file{binutils}. | |
3378 | @c man end | |
3379 | @end ignore | |
3380 | ||
252b5132 RH |
3381 | @node strip |
3382 | @chapter strip | |
3383 | ||
3384 | @kindex strip | |
3385 | @cindex removing symbols | |
3386 | @cindex discarding symbols | |
3387 | @cindex symbols, discarding | |
3388 | ||
f927cc8f | 3389 | @c man title strip discard symbols and other data from object files |
0285c67d | 3390 | |
252b5132 | 3391 | @smallexample |
0285c67d | 3392 | @c man begin SYNOPSIS strip |
2593f09a NC |
3393 | strip [@option{-F} @var{bfdname} |@option{--target=}@var{bfdname}] |
3394 | [@option{-I} @var{bfdname} |@option{--input-target=}@var{bfdname}] | |
3395 | [@option{-O} @var{bfdname} |@option{--output-target=}@var{bfdname}] | |
3396 | [@option{-s}|@option{--strip-all}] | |
3397 | [@option{-S}|@option{-g}|@option{-d}|@option{--strip-debug}] | |
96109726 | 3398 | [@option{--strip-dwo}] |
1d15e434 NC |
3399 | [@option{-K} @var{symbolname}|@option{--keep-symbol=}@var{symbolname}] |
3400 | [@option{-M}|@option{--merge-notes}][@option{--no-merge-notes}] | |
2593f09a | 3401 | [@option{-N} @var{symbolname} |@option{--strip-symbol=}@var{symbolname}] |
5fe11841 | 3402 | [@option{-w}|@option{--wildcard}] |
2593f09a NC |
3403 | [@option{-x}|@option{--discard-all}] [@option{-X} |@option{--discard-locals}] |
3404 | [@option{-R} @var{sectionname} |@option{--remove-section=}@var{sectionname}] | |
64f52b3e | 3405 | [@option{--keep-section=}@var{sectionpattern}] |
d3e5f6c8 | 3406 | [@option{--remove-relocations=}@var{sectionpattern}] |
2593f09a | 3407 | [@option{-o} @var{file}] [@option{-p}|@option{--preserve-dates}] |
2e30cb57 | 3408 | [@option{-D}|@option{--enable-deterministic-archives}] |
955d0b3b | 3409 | [@option{-U}|@option{--disable-deterministic-archives}] |
ca0e11aa | 3410 | [@option{--keep-section-symbols}] |
1637cd90 | 3411 | [@option{--keep-file-symbols}] |
ed1653a7 | 3412 | [@option{--only-keep-debug}] |
7c29036b NC |
3413 | [@option{-v} |@option{--verbose}] [@option{-V}|@option{--version}] |
3414 | [@option{--help}] [@option{--info}] | |
252b5132 | 3415 | @var{objfile}@dots{} |
0285c67d | 3416 | @c man end |
252b5132 RH |
3417 | @end smallexample |
3418 | ||
0285c67d NC |
3419 | @c man begin DESCRIPTION strip |
3420 | ||
c7c55b78 | 3421 | @sc{gnu} @command{strip} discards all symbols from object files |
252b5132 RH |
3422 | @var{objfile}. The list of object files may include archives. |
3423 | At least one object file must be given. | |
3424 | ||
c7c55b78 | 3425 | @command{strip} modifies the files named in its argument, |
252b5132 RH |
3426 | rather than writing modified copies under different names. |
3427 | ||
0285c67d NC |
3428 | @c man end |
3429 | ||
3430 | @c man begin OPTIONS strip | |
3431 | ||
c7c55b78 | 3432 | @table @env |
252b5132 RH |
3433 | @item -F @var{bfdname} |
3434 | @itemx --target=@var{bfdname} | |
3435 | Treat the original @var{objfile} as a file with the object | |
3436 | code format @var{bfdname}, and rewrite it in the same format. | |
3437 | @xref{Target Selection}, for more information. | |
3438 | ||
3439 | @item --help | |
c7c55b78 | 3440 | Show a summary of the options to @command{strip} and exit. |
252b5132 | 3441 | |
7c29036b NC |
3442 | @item --info |
3443 | Display a list showing all architectures and object formats available. | |
3444 | ||
947ed062 | 3445 | @item -I @var{bfdname} |
252b5132 RH |
3446 | @itemx --input-target=@var{bfdname} |
3447 | Treat the original @var{objfile} as a file with the object | |
3448 | code format @var{bfdname}. | |
3449 | @xref{Target Selection}, for more information. | |
3450 | ||
3451 | @item -O @var{bfdname} | |
3452 | @itemx --output-target=@var{bfdname} | |
3453 | Replace @var{objfile} with a file in the output format @var{bfdname}. | |
3454 | @xref{Target Selection}, for more information. | |
3455 | ||
3456 | @item -R @var{sectionname} | |
3457 | @itemx --remove-section=@var{sectionname} | |
805b1c8b AS |
3458 | Remove any section named @var{sectionname} from the output file, in |
3459 | addition to whatever sections would otherwise be removed. This | |
252b5132 | 3460 | option may be given more than once. Note that using this option |
2e62b721 NC |
3461 | inappropriately may make the output file unusable. The wildcard |
3462 | character @samp{*} may be given at the end of @var{sectionname}. If | |
3463 | so, then any section starting with @var{sectionname} will be removed. | |
252b5132 | 3464 | |
e511c9b1 AB |
3465 | If the first character of @var{sectionpattern} is the exclamation |
3466 | point (!) then matching sections will not be removed even if an | |
3467 | earlier use of @option{--remove-section} on the same command line | |
3468 | would otherwise remove it. For example: | |
3469 | ||
3470 | @smallexample | |
3471 | --remove-section=.text.* --remove-section=!.text.foo | |
3472 | @end smallexample | |
3473 | ||
3474 | will remove all sections matching the pattern '.text.*', but will not | |
3475 | remove the section '.text.foo'. | |
3476 | ||
64f52b3e FS |
3477 | @item --keep-section=@var{sectionpattern} |
3478 | When removing sections from the output file, keep sections that match | |
3479 | @var{sectionpattern}. | |
3480 | ||
d3e5f6c8 AB |
3481 | @item --remove-relocations=@var{sectionpattern} |
3482 | Remove relocations from the output file for any section matching | |
3483 | @var{sectionpattern}. This option may be given more than once. Note | |
3484 | that using this option inappropriately may make the output file | |
3485 | unusable. Wildcard characters are accepted in @var{sectionpattern}. | |
3486 | For example: | |
3487 | ||
3488 | @smallexample | |
3489 | --remove-relocations=.text.* | |
3490 | @end smallexample | |
3491 | ||
3492 | will remove the relocations for all sections matching the patter | |
3493 | '.text.*'. | |
3494 | ||
3495 | If the first character of @var{sectionpattern} is the exclamation | |
3496 | point (!) then matching sections will not have their relocation | |
3497 | removed even if an earlier use of @option{--remove-relocations} on the | |
3498 | same command line would otherwise cause the relocations to be removed. | |
3499 | For example: | |
3500 | ||
3501 | @smallexample | |
3502 | --remove-relocations=.text.* --remove-relocations=!.text.foo | |
3503 | @end smallexample | |
3504 | ||
3505 | will remove all relocations for sections matching the pattern | |
3506 | '.text.*', but will not remove relocations for the section | |
3507 | '.text.foo'. | |
3508 | ||
252b5132 RH |
3509 | @item -s |
3510 | @itemx --strip-all | |
3511 | Remove all symbols. | |
3512 | ||
3513 | @item -g | |
3514 | @itemx -S | |
15c82623 | 3515 | @itemx -d |
252b5132 RH |
3516 | @itemx --strip-debug |
3517 | Remove debugging symbols only. | |
96109726 CC |
3518 | |
3519 | @item --strip-dwo | |
3520 | Remove the contents of all DWARF .dwo sections, leaving the | |
3521 | remaining debugging sections and all symbols intact. | |
3522 | See the description of this option in the @command{objcopy} section | |
3523 | for more information. | |
252b5132 RH |
3524 | |
3525 | @item --strip-unneeded | |
427234c7 LC |
3526 | Remove all symbols that are not needed for relocation processing in |
3527 | addition to debugging symbols and sections stripped by | |
3528 | @option{--strip-debug}. | |
252b5132 RH |
3529 | |
3530 | @item -K @var{symbolname} | |
3531 | @itemx --keep-symbol=@var{symbolname} | |
e7f918ad NC |
3532 | When stripping symbols, keep symbol @var{symbolname} even if it would |
3533 | normally be stripped. This option may be given more than once. | |
252b5132 | 3534 | |
1d15e434 NC |
3535 | @item -M |
3536 | @itemx --merge-notes | |
3537 | @itemx --no-merge-notes | |
3538 | For ELF files, attempt (or do not attempt) to reduce the size of any | |
3539 | SHT_NOTE type sections by removing duplicate notes. The default is to | |
1b8dd643 | 3540 | attempt this reduction unless stripping debug or DWO information. |
1d15e434 | 3541 | |
252b5132 RH |
3542 | @item -N @var{symbolname} |
3543 | @itemx --strip-symbol=@var{symbolname} | |
3544 | Remove symbol @var{symbolname} from the source file. This option may be | |
3545 | given more than once, and may be combined with strip options other than | |
c7c55b78 | 3546 | @option{-K}. |
252b5132 RH |
3547 | |
3548 | @item -o @var{file} | |
3549 | Put the stripped output in @var{file}, rather than replacing the | |
3550 | existing file. When this argument is used, only one @var{objfile} | |
3551 | argument may be specified. | |
3552 | ||
3553 | @item -p | |
3554 | @itemx --preserve-dates | |
3555 | Preserve the access and modification dates of the file. | |
3556 | ||
2e30cb57 CC |
3557 | @item -D |
3558 | @itemx --enable-deterministic-archives | |
955d0b3b RM |
3559 | @cindex deterministic archives |
3560 | @kindex --enable-deterministic-archives | |
2e30cb57 CC |
3561 | Operate in @emph{deterministic} mode. When copying archive members |
3562 | and writing the archive index, use zero for UIDs, GIDs, timestamps, | |
3563 | and use consistent file modes for all files. | |
3564 | ||
955d0b3b RM |
3565 | If @file{binutils} was configured with |
3566 | @option{--enable-deterministic-archives}, then this mode is on by default. | |
3567 | It can be disabled with the @samp{-U} option, below. | |
3568 | ||
3569 | @item -U | |
3570 | @itemx --disable-deterministic-archives | |
3571 | @cindex deterministic archives | |
3572 | @kindex --enable-deterministic-archives | |
3573 | Do @emph{not} operate in @emph{deterministic} mode. This is the | |
3574 | inverse of the @option{-D} option, above: when copying archive members | |
3575 | and writing the archive index, use their actual UID, GID, timestamp, | |
3576 | and file mode values. | |
3577 | ||
3578 | This is the default unless @file{binutils} was configured with | |
3579 | @option{--enable-deterministic-archives}. | |
3580 | ||
5fe11841 NC |
3581 | @item -w |
3582 | @itemx --wildcard | |
3583 | Permit regular expressions in @var{symbolname}s used in other command | |
3584 | line options. The question mark (?), asterisk (*), backslash (\) and | |
3585 | square brackets ([]) operators can be used anywhere in the symbol | |
3586 | name. If the first character of the symbol name is the exclamation | |
3587 | point (!) then the sense of the switch is reversed for that symbol. | |
3588 | For example: | |
3589 | ||
3590 | @smallexample | |
3591 | -w -K !foo -K fo* | |
3592 | @end smallexample | |
3593 | ||
3594 | would cause strip to only keep symbols that start with the letters | |
3595 | ``fo'', but to discard the symbol ``foo''. | |
3596 | ||
252b5132 RH |
3597 | @item -x |
3598 | @itemx --discard-all | |
3599 | Remove non-global symbols. | |
3600 | ||
3601 | @item -X | |
3602 | @itemx --discard-locals | |
3603 | Remove compiler-generated local symbols. | |
3604 | (These usually start with @samp{L} or @samp{.}.) | |
3605 | ||
ca0e11aa NC |
3606 | @item --keep-section-symbols |
3607 | When stripping a file, perhaps with @option{--strip-debug} or | |
3608 | @option{--strip-unneeded}, retain any symbols specifying section names, | |
3609 | which would otherwise get stripped. | |
3610 | ||
1637cd90 JB |
3611 | @item --keep-file-symbols |
3612 | When stripping a file, perhaps with @option{--strip-debug} or | |
3613 | @option{--strip-unneeded}, retain any symbols specifying source file names, | |
3614 | which would otherwise get stripped. | |
3615 | ||
ed1653a7 | 3616 | @item --only-keep-debug |
63b9bbb7 | 3617 | Strip a file, emptying the contents of any sections that would not be |
c1c0eb9e | 3618 | stripped by @option{--strip-debug} and leaving the debugging sections |
63b9bbb7 NC |
3619 | intact. In ELF files, this preserves all the note sections in the |
3620 | output as well. | |
3621 | ||
3622 | Note - the section headers of the stripped sections are preserved, | |
3623 | including their sizes, but the contents of the section are discarded. | |
3624 | The section headers are preserved so that other tools can match up the | |
3625 | debuginfo file with the real executable, even if that executable has | |
3626 | been relocated to a different address space. | |
ed1653a7 NC |
3627 | |
3628 | The intention is that this option will be used in conjunction with | |
3629 | @option{--add-gnu-debuglink} to create a two part executable. One a | |
3630 | stripped binary which will occupy less space in RAM and in a | |
3631 | distribution and the second a debugging information file which is only | |
3632 | needed if debugging abilities are required. The suggested procedure | |
3633 | to create these files is as follows: | |
3634 | ||
3635 | @enumerate | |
eca4b721 | 3636 | @item Link the executable as normal. Assuming that it is called |
ed1653a7 NC |
3637 | @code{foo} then... |
3638 | @item Run @code{objcopy --only-keep-debug foo foo.dbg} to | |
3639 | create a file containing the debugging info. | |
3640 | @item Run @code{objcopy --strip-debug foo} to create a | |
3641 | stripped executable. | |
3642 | @item Run @code{objcopy --add-gnu-debuglink=foo.dbg foo} | |
3643 | to add a link to the debugging info into the stripped executable. | |
3644 | @end enumerate | |
3645 | ||
928a4139 | 3646 | Note---the choice of @code{.dbg} as an extension for the debug info |
ed1653a7 NC |
3647 | file is arbitrary. Also the @code{--only-keep-debug} step is |
3648 | optional. You could instead do this: | |
3649 | ||
3650 | @enumerate | |
3651 | @item Link the executable as normal. | |
928a4139 | 3652 | @item Copy @code{foo} to @code{foo.full} |
ed1653a7 NC |
3653 | @item Run @code{strip --strip-debug foo} |
3654 | @item Run @code{objcopy --add-gnu-debuglink=foo.full foo} | |
3655 | @end enumerate | |
3656 | ||
928a4139 | 3657 | i.e., the file pointed to by the @option{--add-gnu-debuglink} can be the |
ed1653a7 NC |
3658 | full executable. It does not have to be a file created by the |
3659 | @option{--only-keep-debug} switch. | |
3660 | ||
928a4139 | 3661 | Note---this switch is only intended for use on fully linked files. It |
91bb255c NC |
3662 | does not make sense to use it on object files where the debugging |
3663 | information may be incomplete. Besides the gnu_debuglink feature | |
3664 | currently only supports the presence of one filename containing | |
3665 | debugging information, not multiple filenames on a one-per-object-file | |
3666 | basis. | |
3667 | ||
252b5132 RH |
3668 | @item -V |
3669 | @itemx --version | |
c7c55b78 | 3670 | Show the version number for @command{strip}. |
252b5132 RH |
3671 | |
3672 | @item -v | |
3673 | @itemx --verbose | |
3674 | Verbose output: list all object files modified. In the case of | |
3675 | archives, @samp{strip -v} lists all members of the archive. | |
3676 | @end table | |
3677 | ||
0285c67d NC |
3678 | @c man end |
3679 | ||
3680 | @ignore | |
3681 | @c man begin SEEALSO strip | |
3682 | the Info entries for @file{binutils}. | |
3683 | @c man end | |
3684 | @end ignore | |
3685 | ||
7ca01ed9 | 3686 | @node c++filt, addr2line, strip, Top |
252b5132 RH |
3687 | @chapter c++filt |
3688 | ||
3689 | @kindex c++filt | |
3690 | @cindex demangling C++ symbols | |
3691 | ||
f927cc8f | 3692 | @c man title cxxfilt demangle C++ and Java symbols |
0285c67d | 3693 | |
252b5132 | 3694 | @smallexample |
0285c67d | 3695 | @c man begin SYNOPSIS cxxfilt |
ae9ab7c0 NC |
3696 | c++filt [@option{-_}|@option{--strip-underscore}] |
3697 | [@option{-n}|@option{--no-strip-underscore}] | |
4e48c9dd | 3698 | [@option{-p}|@option{--no-params}] |
ec948987 | 3699 | [@option{-t}|@option{--types}] |
cbf1f5df | 3700 | [@option{-i}|@option{--no-verbose}] |
af03af8f NC |
3701 | [@option{-r}|@option{--no-recurse-limit}] |
3702 | [@option{-R}|@option{--recurse-limit}] | |
c7c55b78 NC |
3703 | [@option{-s} @var{format}|@option{--format=}@var{format}] |
3704 | [@option{--help}] [@option{--version}] [@var{symbol}@dots{}] | |
0285c67d | 3705 | @c man end |
252b5132 RH |
3706 | @end smallexample |
3707 | ||
0285c67d NC |
3708 | @c man begin DESCRIPTION cxxfilt |
3709 | ||
9d51cc66 | 3710 | @kindex cxxfilt |
ec948987 NC |
3711 | The C++ and Java languages provide function overloading, which means |
3712 | that you can write many functions with the same name, providing that | |
3713 | each function takes parameters of different types. In order to be | |
3714 | able to distinguish these similarly named functions C++ and Java | |
3715 | encode them into a low-level assembler name which uniquely identifies | |
3716 | each different version. This process is known as @dfn{mangling}. The | |
3717 | @command{c++filt} | |
c1c0eb9e | 3718 | @footnote{MS-DOS does not allow @kbd{+} characters in file names, so on |
195a97ce | 3719 | MS-DOS this program is named @command{CXXFILT}.} |
9d51cc66 | 3720 | program does the inverse mapping: it decodes (@dfn{demangles}) low-level |
ec948987 | 3721 | names into user-level names so that they can be read. |
252b5132 RH |
3722 | |
3723 | Every alphanumeric word (consisting of letters, digits, underscores, | |
cbf1f5df NC |
3724 | dollars, or periods) seen in the input is a potential mangled name. |
3725 | If the name decodes into a C++ name, the C++ name replaces the | |
ec948987 NC |
3726 | low-level name in the output, otherwise the original word is output. |
3727 | In this way you can pass an entire assembler source file, containing | |
3728 | mangled names, through @command{c++filt} and see the same source file | |
3729 | containing demangled names. | |
252b5132 | 3730 | |
ec948987 NC |
3731 | You can also use @command{c++filt} to decipher individual symbols by |
3732 | passing them on the command line: | |
252b5132 RH |
3733 | |
3734 | @example | |
3735 | c++filt @var{symbol} | |
3736 | @end example | |
3737 | ||
c7c55b78 | 3738 | If no @var{symbol} arguments are given, @command{c++filt} reads symbol |
ec948987 NC |
3739 | names from the standard input instead. All the results are printed on |
3740 | the standard output. The difference between reading names from the | |
3741 | command line versus reading names from the standard input is that | |
a05a5b64 | 3742 | command-line arguments are expected to be just mangled names and no |
b45619c0 | 3743 | checking is performed to separate them from surrounding text. Thus |
ec948987 NC |
3744 | for example: |
3745 | ||
3746 | @smallexample | |
3747 | c++filt -n _Z1fv | |
3748 | @end smallexample | |
3749 | ||
3750 | will work and demangle the name to ``f()'' whereas: | |
3751 | ||
3752 | @smallexample | |
3753 | c++filt -n _Z1fv, | |
3754 | @end smallexample | |
3755 | ||
3756 | will not work. (Note the extra comma at the end of the mangled | |
3757 | name which makes it invalid). This command however will work: | |
3758 | ||
3759 | @smallexample | |
3760 | echo _Z1fv, | c++filt -n | |
3761 | @end smallexample | |
3762 | ||
928a4139 | 3763 | and will display ``f(),'', i.e., the demangled name followed by a |
ec948987 NC |
3764 | trailing comma. This behaviour is because when the names are read |
3765 | from the standard input it is expected that they might be part of an | |
3766 | assembler source file where there might be extra, extraneous | |
928a4139 | 3767 | characters trailing after a mangled name. For example: |
ec948987 NC |
3768 | |
3769 | @smallexample | |
3770 | .type _Z1fv, @@function | |
3771 | @end smallexample | |
252b5132 | 3772 | |
0285c67d NC |
3773 | @c man end |
3774 | ||
3775 | @c man begin OPTIONS cxxfilt | |
3776 | ||
c7c55b78 | 3777 | @table @env |
252b5132 | 3778 | @item -_ |
ae9ab7c0 | 3779 | @itemx --strip-underscore |
252b5132 RH |
3780 | On some systems, both the C and C++ compilers put an underscore in front |
3781 | of every name. For example, the C name @code{foo} gets the low-level | |
3782 | name @code{_foo}. This option removes the initial underscore. Whether | |
c7c55b78 | 3783 | @command{c++filt} removes the underscore by default is target dependent. |
252b5132 | 3784 | |
252b5132 | 3785 | @item -n |
ae9ab7c0 | 3786 | @itemx --no-strip-underscore |
252b5132 RH |
3787 | Do not remove the initial underscore. |
3788 | ||
4e48c9dd ILT |
3789 | @item -p |
3790 | @itemx --no-params | |
3791 | When demangling the name of a function, do not display the types of | |
3792 | the function's parameters. | |
3793 | ||
cbf1f5df | 3794 | @item -t |
ec948987 NC |
3795 | @itemx --types |
3796 | Attempt to demangle types as well as function names. This is disabled | |
3797 | by default since mangled types are normally only used internally in | |
928a4139 | 3798 | the compiler, and they can be confused with non-mangled names. For example, |
ec948987 NC |
3799 | a function called ``a'' treated as a mangled type name would be |
3800 | demangled to ``signed char''. | |
cbf1f5df NC |
3801 | |
3802 | @item -i | |
3803 | @itemx --no-verbose | |
3804 | Do not include implementation details (if any) in the demangled | |
3805 | output. | |
3806 | ||
af03af8f NC |
3807 | @item -r |
3808 | @itemx -R | |
3809 | @itemx --recurse-limit | |
3810 | @itemx --no-recurse-limit | |
3811 | @itemx --recursion-limit | |
3812 | @itemx --no-recursion-limit | |
3813 | Enables or disables a limit on the amount of recursion performed | |
3814 | whilst demangling strings. Since the name mangling formats allow for | |
0cc79db2 | 3815 | an infinite level of recursion it is possible to create strings whose |
af03af8f NC |
3816 | decoding will exhaust the amount of stack space available on the host |
3817 | machine, triggering a memory fault. The limit tries to prevent this | |
69799d67 | 3818 | from happening by restricting recursion to 2048 levels of nesting. |
af03af8f NC |
3819 | |
3820 | The default is for this limit to be enabled, but disabling it may be | |
3821 | necessary in order to demangle truly complicated names. Note however | |
3822 | that if the recursion limit is disabled then stack exhaustion is | |
3823 | possible and any bug reports about such an event will be rejected. | |
3824 | ||
3825 | The @option{-r} option is a synonym for the | |
3826 | @option{--no-recurse-limit} option. The @option{-R} option is a | |
3827 | synonym for the @option{--recurse-limit} option. | |
3828 | ||
252b5132 RH |
3829 | @item -s @var{format} |
3830 | @itemx --format=@var{format} | |
947ed062 NC |
3831 | @command{c++filt} can decode various methods of mangling, used by |
3832 | different compilers. The argument to this option selects which | |
252b5132 RH |
3833 | method it uses: |
3834 | ||
3835 | @table @code | |
947ed062 NC |
3836 | @item auto |
3837 | Automatic selection based on executable (the default method) | |
252b5132 | 3838 | @item gnu |
947ed062 | 3839 | the one used by the @sc{gnu} C++ compiler (g++) |
252b5132 | 3840 | @item lucid |
947ed062 | 3841 | the one used by the Lucid compiler (lcc) |
252b5132 RH |
3842 | @item arm |
3843 | the one specified by the C++ Annotated Reference Manual | |
3844 | @item hp | |
947ed062 | 3845 | the one used by the HP compiler (aCC) |
252b5132 RH |
3846 | @item edg |
3847 | the one used by the EDG compiler | |
b5e2a4f3 | 3848 | @item gnu-v3 |
947ed062 NC |
3849 | the one used by the @sc{gnu} C++ compiler (g++) with the V3 ABI. |
3850 | @item java | |
3851 | the one used by the @sc{gnu} Java compiler (gcj) | |
3852 | @item gnat | |
3853 | the one used by the @sc{gnu} Ada compiler (GNAT). | |
252b5132 RH |
3854 | @end table |
3855 | ||
3856 | @item --help | |
c7c55b78 | 3857 | Print a summary of the options to @command{c++filt} and exit. |
252b5132 RH |
3858 | |
3859 | @item --version | |
c7c55b78 | 3860 | Print the version number of @command{c++filt} and exit. |
252b5132 RH |
3861 | @end table |
3862 | ||
0285c67d NC |
3863 | @c man end |
3864 | ||
3865 | @ignore | |
3866 | @c man begin SEEALSO cxxfilt | |
3867 | the Info entries for @file{binutils}. | |
3868 | @c man end | |
3869 | @end ignore | |
3870 | ||
252b5132 | 3871 | @quotation |
c7c55b78 | 3872 | @emph{Warning:} @command{c++filt} is a new utility, and the details of its |
252b5132 | 3873 | user interface are subject to change in future releases. In particular, |
b45619c0 | 3874 | a command-line option may be required in the future to decode a name |
c1c0eb9e | 3875 | passed as an argument on the command line; in other words, |
252b5132 RH |
3876 | |
3877 | @example | |
3878 | c++filt @var{symbol} | |
3879 | @end example | |
3880 | ||
3881 | @noindent | |
3882 | may in a future release become | |
3883 | ||
3884 | @example | |
3885 | c++filt @var{option} @var{symbol} | |
3886 | @end example | |
3887 | @end quotation | |
3888 | ||
3889 | @node addr2line | |
3890 | @chapter addr2line | |
3891 | ||
3892 | @kindex addr2line | |
3893 | @cindex address to file name and line number | |
3894 | ||
f927cc8f | 3895 | @c man title addr2line convert addresses into file names and line numbers |
0285c67d | 3896 | |
252b5132 | 3897 | @smallexample |
0285c67d | 3898 | @c man begin SYNOPSIS addr2line |
be6f6493 TG |
3899 | addr2line [@option{-a}|@option{--addresses}] |
3900 | [@option{-b} @var{bfdname}|@option{--target=}@var{bfdname}] | |
bf44dd74 | 3901 | [@option{-C}|@option{--demangle}[=@var{style}]] |
af03af8f NC |
3902 | [@option{-r}|@option{--no-recurse-limit}] |
3903 | [@option{-R}|@option{--recurse-limit}] | |
c7c55b78 NC |
3904 | [@option{-e} @var{filename}|@option{--exe=}@var{filename}] |
3905 | [@option{-f}|@option{--functions}] [@option{-s}|@option{--basename}] | |
0c552dc1 | 3906 | [@option{-i}|@option{--inlines}] |
68cdf72f | 3907 | [@option{-p}|@option{--pretty-print}] |
c5f8c388 | 3908 | [@option{-j}|@option{--section=}@var{name}] |
c7c55b78 NC |
3909 | [@option{-H}|@option{--help}] [@option{-V}|@option{--version}] |
3910 | [addr addr @dots{}] | |
0285c67d | 3911 | @c man end |
252b5132 RH |
3912 | @end smallexample |
3913 | ||
0285c67d NC |
3914 | @c man begin DESCRIPTION addr2line |
3915 | ||
c5f8c388 EB |
3916 | @command{addr2line} translates addresses into file names and line numbers. |
3917 | Given an address in an executable or an offset in a section of a relocatable | |
3918 | object, it uses the debugging information to figure out which file name and | |
3919 | line number are associated with it. | |
252b5132 | 3920 | |
c5f8c388 EB |
3921 | The executable or relocatable object to use is specified with the @option{-e} |
3922 | option. The default is the file @file{a.out}. The section in the relocatable | |
3923 | object to use is specified with the @option{-j} option. | |
252b5132 | 3924 | |
c7c55b78 | 3925 | @command{addr2line} has two modes of operation. |
252b5132 RH |
3926 | |
3927 | In the first, hexadecimal addresses are specified on the command line, | |
c7c55b78 | 3928 | and @command{addr2line} displays the file name and line number for each |
252b5132 RH |
3929 | address. |
3930 | ||
c7c55b78 | 3931 | In the second, @command{addr2line} reads hexadecimal addresses from |
252b5132 | 3932 | standard input, and prints the file name and line number for each |
c7c55b78 | 3933 | address on standard output. In this mode, @command{addr2line} may be used |
252b5132 RH |
3934 | in a pipe to convert dynamically chosen addresses. |
3935 | ||
8d112f9e TG |
3936 | The format of the output is @samp{FILENAME:LINENO}. By default |
3937 | each input address generates one line of output. | |
9cf03b7e | 3938 | |
8d112f9e TG |
3939 | Two options can generate additional lines before each |
3940 | @samp{FILENAME:LINENO} line (in that order). | |
3941 | ||
3942 | If the @option{-a} option is used then a line with the input address | |
3943 | is displayed. | |
3944 | ||
3945 | If the @option{-f} option is used, then a line with the | |
3946 | @samp{FUNCTIONNAME} is displayed. This is the name of the function | |
3947 | containing the address. | |
3948 | ||
3949 | One option can generate additional lines after the | |
3950 | @samp{FILENAME:LINENO} line. | |
9cf03b7e NC |
3951 | |
3952 | If the @option{-i} option is used and the code at the given address is | |
8d112f9e TG |
3953 | present there because of inlining by the compiler then additional |
3954 | lines are displayed afterwards. One or two extra lines (if the | |
3955 | @option{-f} option is used) are displayed for each inlined function. | |
3956 | ||
3957 | Alternatively if the @option{-p} option is used then each input | |
3958 | address generates a single, long, output line containing the address, | |
3959 | the function name, the file name and the line number. If the | |
3960 | @option{-i} option has also been used then any inlined functions will | |
3961 | be displayed in the same manner, but on separate lines, and prefixed | |
3962 | by the text @samp{(inlined by)}. | |
252b5132 RH |
3963 | |
3964 | If the file name or function name can not be determined, | |
c7c55b78 NC |
3965 | @command{addr2line} will print two question marks in their place. If the |
3966 | line number can not be determined, @command{addr2line} will print 0. | |
252b5132 | 3967 | |
0285c67d NC |
3968 | @c man end |
3969 | ||
3970 | @c man begin OPTIONS addr2line | |
3971 | ||
252b5132 RH |
3972 | The long and short forms of options, shown here as alternatives, are |
3973 | equivalent. | |
3974 | ||
c7c55b78 | 3975 | @table @env |
be6f6493 TG |
3976 | @item -a |
3977 | @itemx --addresses | |
9cf03b7e | 3978 | Display the address before the function name, file and line number |
be6f6493 TG |
3979 | information. The address is printed with a @samp{0x} prefix to easily |
3980 | identify it. | |
3981 | ||
252b5132 RH |
3982 | @item -b @var{bfdname} |
3983 | @itemx --target=@var{bfdname} | |
3984 | @cindex object code format | |
3985 | Specify that the object-code format for the object files is | |
3986 | @var{bfdname}. | |
3987 | ||
3988 | @item -C | |
28c309a2 | 3989 | @itemx --demangle[=@var{style}] |
252b5132 RH |
3990 | @cindex demangling in objdump |
3991 | Decode (@dfn{demangle}) low-level symbol names into user-level names. | |
3992 | Besides removing any initial underscore prepended by the system, this | |
28c309a2 | 3993 | makes C++ function names readable. Different compilers have different |
c1c0eb9e RM |
3994 | mangling styles. The optional demangling style argument can be used to |
3995 | choose an appropriate demangling style for your compiler. @xref{c++filt}, | |
28c309a2 | 3996 | for more information on demangling. |
252b5132 RH |
3997 | |
3998 | @item -e @var{filename} | |
3999 | @itemx --exe=@var{filename} | |
4000 | Specify the name of the executable for which addresses should be | |
4001 | translated. The default file is @file{a.out}. | |
4002 | ||
4003 | @item -f | |
4004 | @itemx --functions | |
4005 | Display function names as well as file and line number information. | |
4006 | ||
4007 | @item -s | |
4008 | @itemx --basenames | |
4009 | Display only the base of each file name. | |
0c552dc1 FF |
4010 | |
4011 | @item -i | |
4012 | @itemx --inlines | |
4013 | If the address belongs to a function that was inlined, the source | |
4014 | information for all enclosing scopes back to the first non-inlined | |
4015 | function will also be printed. For example, if @code{main} inlines | |
4016 | @code{callee1} which inlines @code{callee2}, and address is from | |
4017 | @code{callee2}, the source information for @code{callee1} and @code{main} | |
4018 | will also be printed. | |
c5f8c388 EB |
4019 | |
4020 | @item -j | |
4021 | @itemx --section | |
4022 | Read offsets relative to the specified section instead of absolute addresses. | |
68cdf72f TG |
4023 | |
4024 | @item -p | |
4025 | @itemx --pretty-print | |
4026 | Make the output more human friendly: each location are printed on one line. | |
4027 | If option @option{-i} is specified, lines for all enclosing scopes are | |
4028 | prefixed with @samp{(inlined by)}. | |
af03af8f NC |
4029 | |
4030 | @item -r | |
4031 | @itemx -R | |
4032 | @itemx --recurse-limit | |
4033 | @itemx --no-recurse-limit | |
4034 | @itemx --recursion-limit | |
4035 | @itemx --no-recursion-limit | |
4036 | Enables or disables a limit on the amount of recursion performed | |
4037 | whilst demangling strings. Since the name mangling formats allow for | |
0cc79db2 | 4038 | an infinite level of recursion it is possible to create strings whose |
af03af8f NC |
4039 | decoding will exhaust the amount of stack space available on the host |
4040 | machine, triggering a memory fault. The limit tries to prevent this | |
69799d67 | 4041 | from happening by restricting recursion to 2048 levels of nesting. |
af03af8f NC |
4042 | |
4043 | The default is for this limit to be enabled, but disabling it may be | |
4044 | necessary in order to demangle truly complicated names. Note however | |
4045 | that if the recursion limit is disabled then stack exhaustion is | |
4046 | possible and any bug reports about such an event will be rejected. | |
4047 | ||
4048 | The @option{-r} option is a synonym for the | |
4049 | @option{--no-recurse-limit} option. The @option{-R} option is a | |
4050 | synonym for the @option{--recurse-limit} option. | |
4051 | ||
4052 | Note this option is only effective if the @option{-C} or | |
4053 | @option{--demangle} option has been enabled. | |
4054 | ||
e107c42f | 4055 | @end table |
252b5132 | 4056 | |
0285c67d NC |
4057 | @c man end |
4058 | ||
4059 | @ignore | |
4060 | @c man begin SEEALSO addr2line | |
4061 | Info entries for @file{binutils}. | |
4062 | @c man end | |
4063 | @end ignore | |
4064 | ||
692ed3e7 NC |
4065 | @node windmc |
4066 | @chapter windmc | |
4067 | ||
4068 | @command{windmc} may be used to generator Windows message resources. | |
4069 | ||
4070 | @quotation | |
4071 | @emph{Warning:} @command{windmc} is not always built as part of the binary | |
4072 | utilities, since it is only useful for Windows targets. | |
4073 | @end quotation | |
4074 | ||
f927cc8f | 4075 | @c man title windmc generates Windows message resources |
692ed3e7 NC |
4076 | |
4077 | @smallexample | |
826fec2f | 4078 | @c man begin SYNOPSIS windmc |
692ed3e7 NC |
4079 | windmc [options] input-file |
4080 | @c man end | |
4081 | @end smallexample | |
4082 | ||
4083 | @c man begin DESCRIPTION windmc | |
4084 | ||
4085 | @command{windmc} reads message definitions from an input file (.mc) and | |
4086 | translate them into a set of output files. The output files may be of | |
4087 | four kinds: | |
4088 | ||
4089 | @table @code | |
4090 | @item h | |
4091 | A C header file containing the message definitions. | |
4092 | ||
4093 | @item rc | |
4094 | A resource file compilable by the @command{windres} tool. | |
4095 | ||
4096 | @item bin | |
4097 | One or more binary files containing the resource data for a specific | |
4098 | message language. | |
4099 | ||
4100 | @item dbg | |
4101 | A C include file that maps message id's to their symbolic name. | |
4102 | @end table | |
4103 | ||
4104 | The exact description of these different formats is available in | |
4105 | documentation from Microsoft. | |
4106 | ||
4107 | When @command{windmc} converts from the @code{mc} format to the @code{bin} | |
4108 | format, @code{rc}, @code{h}, and optional @code{dbg} it is acting like the | |
4109 | Windows Message Compiler. | |
4110 | ||
4111 | @c man end | |
4112 | ||
4113 | @c man begin OPTIONS windmc | |
4114 | ||
4115 | @table @env | |
4116 | @item -a | |
4117 | @itemx --ascii_in | |
826fec2f | 4118 | Specifies that the input file specified is ASCII. This is the default |
692ed3e7 NC |
4119 | behaviour. |
4120 | ||
4121 | @item -A | |
4122 | @itemx --ascii_out | |
826fec2f | 4123 | Specifies that messages in the output @code{bin} files should be in ASCII |
692ed3e7 NC |
4124 | format. |
4125 | ||
4126 | @item -b | |
4127 | @itemx --binprefix | |
4128 | Specifies that @code{bin} filenames should have to be prefixed by the | |
4129 | basename of the source file. | |
4130 | ||
4131 | @item -c | |
4132 | @itemx --customflag | |
4133 | Sets the customer bit in all message id's. | |
4134 | ||
4135 | @item -C @var{codepage} | |
4136 | @itemx --codepage_in @var{codepage} | |
4137 | Sets the default codepage to be used to convert input file to UTF16. The | |
4138 | default is ocdepage 1252. | |
4139 | ||
4140 | @item -d | |
4141 | @itemx --decimal_values | |
4142 | Outputs the constants in the header file in decimal. Default is using | |
4143 | hexadecimal output. | |
4144 | ||
4145 | @item -e @var{ext} | |
4146 | @itemx --extension @var{ext} | |
4147 | The extension for the header file. The default is .h extension. | |
4148 | ||
4149 | @item -F @var{target} | |
4150 | @itemx --target @var{target} | |
4151 | Specify the BFD format to use for a bin file as output. This | |
4152 | is a BFD target name; you can use the @option{--help} option to see a list | |
4153 | of supported targets. Normally @command{windmc} will use the default | |
4154 | format, which is the first one listed by the @option{--help} option. | |
4155 | @ifclear man | |
4156 | @ref{Target Selection}. | |
4157 | @end ifclear | |
4158 | ||
4159 | @item -h @var{path} | |
4160 | @itemx --headerdir @var{path} | |
4161 | The target directory of the generated header file. The default is the | |
4162 | current directory. | |
4163 | ||
4164 | @item -H | |
4165 | @itemx --help | |
a05a5b64 | 4166 | Displays a list of command-line options and then exits. |
692ed3e7 NC |
4167 | |
4168 | @item -m @var{characters} | |
4169 | @itemx --maxlength @var{characters} | |
4170 | Instructs @command{windmc} to generate a warning if the length | |
4171 | of any message exceeds the number specified. | |
4172 | ||
4173 | @item -n | |
4174 | @itemx --nullterminate | |
4175 | Terminate message text in @code{bin} files by zero. By default they are | |
4176 | terminated by CR/LF. | |
4177 | ||
4178 | @item -o | |
4179 | @itemx --hresult_use | |
4180 | Not yet implemented. Instructs @code{windmc} to generate an OLE2 header | |
4181 | file, using HRESULT definitions. Status codes are used if the flag is not | |
4182 | specified. | |
4183 | ||
4184 | @item -O @var{codepage} | |
4185 | @itemx --codepage_out @var{codepage} | |
4186 | Sets the default codepage to be used to output text files. The default | |
4187 | is ocdepage 1252. | |
4188 | ||
4189 | @item -r @var{path} | |
4190 | @itemx --rcdir @var{path} | |
4191 | The target directory for the generated @code{rc} script and the generated | |
4192 | @code{bin} files that the resource compiler script includes. The default | |
4193 | is the current directory. | |
4194 | ||
4195 | @item -u | |
4196 | @itemx --unicode_in | |
4197 | Specifies that the input file is UTF16. | |
4198 | ||
4199 | @item -U | |
4200 | @itemx --unicode_out | |
4201 | Specifies that messages in the output @code{bin} file should be in UTF16 | |
4202 | format. This is the default behaviour. | |
4203 | ||
4204 | @item -v | |
4205 | @item --verbose | |
bd37ed49 | 4206 | Enable verbose mode. |
692ed3e7 NC |
4207 | |
4208 | @item -V | |
4209 | @item --version | |
bd37ed49 | 4210 | Prints the version number for @command{windmc}. |
692ed3e7 NC |
4211 | |
4212 | @item -x @var{path} | |
4213 | @itemx --xdgb @var{path} | |
4214 | The path of the @code{dbg} C include file that maps message id's to the | |
4215 | symbolic name. No such file is generated without specifying the switch. | |
4216 | @end table | |
4217 | ||
4218 | @c man end | |
4219 | ||
4220 | @ignore | |
4221 | @c man begin SEEALSO windmc | |
4222 | the Info entries for @file{binutils}. | |
0285c67d NC |
4223 | @c man end |
4224 | @end ignore | |
4225 | ||
252b5132 RH |
4226 | @node windres |
4227 | @chapter windres | |
4228 | ||
c7c55b78 | 4229 | @command{windres} may be used to manipulate Windows resources. |
252b5132 RH |
4230 | |
4231 | @quotation | |
c7c55b78 | 4232 | @emph{Warning:} @command{windres} is not always built as part of the binary |
252b5132 RH |
4233 | utilities, since it is only useful for Windows targets. |
4234 | @end quotation | |
4235 | ||
f927cc8f | 4236 | @c man title windres manipulate Windows resources |
0285c67d | 4237 | |
252b5132 | 4238 | @smallexample |
0285c67d | 4239 | @c man begin SYNOPSIS windres |
252b5132 | 4240 | windres [options] [input-file] [output-file] |
0285c67d | 4241 | @c man end |
252b5132 RH |
4242 | @end smallexample |
4243 | ||
0285c67d NC |
4244 | @c man begin DESCRIPTION windres |
4245 | ||
c7c55b78 | 4246 | @command{windres} reads resources from an input file and copies them into |
252b5132 RH |
4247 | an output file. Either file may be in one of three formats: |
4248 | ||
4249 | @table @code | |
4250 | @item rc | |
4251 | A text format read by the Resource Compiler. | |
4252 | ||
4253 | @item res | |
4254 | A binary format generated by the Resource Compiler. | |
4255 | ||
4256 | @item coff | |
4257 | A COFF object or executable. | |
4258 | @end table | |
4259 | ||
4260 | The exact description of these different formats is available in | |
4261 | documentation from Microsoft. | |
4262 | ||
c7c55b78 | 4263 | When @command{windres} converts from the @code{rc} format to the @code{res} |
252b5132 | 4264 | format, it is acting like the Windows Resource Compiler. When |
c7c55b78 | 4265 | @command{windres} converts from the @code{res} format to the @code{coff} |
252b5132 RH |
4266 | format, it is acting like the Windows @code{CVTRES} program. |
4267 | ||
c7c55b78 | 4268 | When @command{windres} generates an @code{rc} file, the output is similar |
252b5132 RH |
4269 | but not identical to the format expected for the input. When an input |
4270 | @code{rc} file refers to an external filename, an output @code{rc} file | |
4271 | will instead include the file contents. | |
4272 | ||
c7c55b78 | 4273 | If the input or output format is not specified, @command{windres} will |
252b5132 RH |
4274 | guess based on the file name, or, for the input file, the file contents. |
4275 | A file with an extension of @file{.rc} will be treated as an @code{rc} | |
4276 | file, a file with an extension of @file{.res} will be treated as a | |
4277 | @code{res} file, and a file with an extension of @file{.o} or | |
4278 | @file{.exe} will be treated as a @code{coff} file. | |
4279 | ||
c7c55b78 | 4280 | If no output file is specified, @command{windres} will print the resources |
252b5132 RH |
4281 | in @code{rc} format to standard output. |
4282 | ||
c7c55b78 | 4283 | The normal use is for you to write an @code{rc} file, use @command{windres} |
252b5132 RH |
4284 | to convert it to a COFF object file, and then link the COFF file into |
4285 | your application. This will make the resources described in the | |
4286 | @code{rc} file available to Windows. | |
4287 | ||
0285c67d NC |
4288 | @c man end |
4289 | ||
4290 | @c man begin OPTIONS windres | |
4291 | ||
c7c55b78 | 4292 | @table @env |
252b5132 RH |
4293 | @item -i @var{filename} |
4294 | @itemx --input @var{filename} | |
4295 | The name of the input file. If this option is not used, then | |
c7c55b78 NC |
4296 | @command{windres} will use the first non-option argument as the input file |
4297 | name. If there are no non-option arguments, then @command{windres} will | |
4298 | read from standard input. @command{windres} can not read a COFF file from | |
edbedb71 | 4299 | standard input. |
252b5132 RH |
4300 | |
4301 | @item -o @var{filename} | |
4302 | @itemx --output @var{filename} | |
4303 | The name of the output file. If this option is not used, then | |
c7c55b78 | 4304 | @command{windres} will use the first non-option argument, after any used |
252b5132 | 4305 | for the input file name, as the output file name. If there is no |
c7c55b78 | 4306 | non-option argument, then @command{windres} will write to standard output. |
edbedb71 | 4307 | @command{windres} can not write a COFF file to standard output. Note, |
b45619c0 | 4308 | for compatibility with @command{rc} the option @option{-fo} is also |
edbedb71 | 4309 | accepted, but its use is not recommended. |
252b5132 | 4310 | |
85eb5110 | 4311 | @item -J @var{format} |
252b5132 RH |
4312 | @itemx --input-format @var{format} |
4313 | The input format to read. @var{format} may be @samp{res}, @samp{rc}, or | |
c7c55b78 | 4314 | @samp{coff}. If no input format is specified, @command{windres} will |
252b5132 RH |
4315 | guess, as described above. |
4316 | ||
4317 | @item -O @var{format} | |
4318 | @itemx --output-format @var{format} | |
4319 | The output format to generate. @var{format} may be @samp{res}, | |
4320 | @samp{rc}, or @samp{coff}. If no output format is specified, | |
c7c55b78 | 4321 | @command{windres} will guess, as described above. |
252b5132 RH |
4322 | |
4323 | @item -F @var{target} | |
4324 | @itemx --target @var{target} | |
4325 | Specify the BFD format to use for a COFF file as input or output. This | |
c7c55b78 NC |
4326 | is a BFD target name; you can use the @option{--help} option to see a list |
4327 | of supported targets. Normally @command{windres} will use the default | |
4328 | format, which is the first one listed by the @option{--help} option. | |
4329 | @ifclear man | |
252b5132 | 4330 | @ref{Target Selection}. |
c7c55b78 | 4331 | @end ifclear |
252b5132 RH |
4332 | |
4333 | @item --preprocessor @var{program} | |
c7c55b78 | 4334 | When @command{windres} reads an @code{rc} file, it runs it through the C |
252b5132 | 4335 | preprocessor first. This option may be used to specify the preprocessor |
749c7002 | 4336 | to use. The default preprocessor is @code{gcc}. |
252b5132 | 4337 | |
ec25acb3 NC |
4338 | @item --preprocessor-arg @var{option} |
4339 | When @command{windres} reads an @code{rc} file, it runs it through | |
4340 | the C preprocessor first. This option may be used to specify additional | |
4341 | text to be passed to preprocessor on its command line. | |
4342 | This option can be used multiple times to add multiple options to the | |
4343 | preprocessor command line. | |
5edb8e3f NC |
4344 | If the @option{--preprocessor} option has not been specified then a |
4345 | default set of preprocessor arguments will be used, with any | |
4346 | @option{--preprocessor-arg} options being placed after them on the | |
749c7002 TW |
4347 | command line. These default arguments are @code{-E}, |
4348 | @code{-xc-header} and @code{-DRC_INVOKED}. | |
ec25acb3 | 4349 | |
85eb5110 NC |
4350 | @item -I @var{directory} |
4351 | @itemx --include-dir @var{directory} | |
252b5132 | 4352 | Specify an include directory to use when reading an @code{rc} file. |
c7c55b78 NC |
4353 | @command{windres} will pass this to the preprocessor as an @option{-I} |
4354 | option. @command{windres} will also search this directory when looking for | |
85eb5110 | 4355 | files named in the @code{rc} file. If the argument passed to this command |
c1c0eb9e | 4356 | matches any of the supported @var{formats} (as described in the @option{-J} |
85eb5110 NC |
4357 | option), it will issue a deprecation warning, and behave just like the |
4358 | @option{-J} option. New programs should not use this behaviour. If a | |
4359 | directory happens to match a @var{format}, simple prefix it with @samp{./} | |
4360 | to disable the backward compatibility. | |
252b5132 | 4361 | |
751d21b5 | 4362 | @item -D @var{target} |
ad0481cd | 4363 | @itemx --define @var{sym}[=@var{val}] |
c7c55b78 | 4364 | Specify a @option{-D} option to pass to the preprocessor when reading an |
252b5132 RH |
4365 | @code{rc} file. |
4366 | ||
29b058f1 NC |
4367 | @item -U @var{target} |
4368 | @itemx --undefine @var{sym} | |
4369 | Specify a @option{-U} option to pass to the preprocessor when reading an | |
4370 | @code{rc} file. | |
4371 | ||
3126d709 CF |
4372 | @item -r |
4373 | Ignored for compatibility with rc. | |
4374 | ||
751d21b5 DD |
4375 | @item -v |
4376 | Enable verbose mode. This tells you what the preprocessor is if you | |
4377 | didn't specify one. | |
4378 | ||
30ff741f NC |
4379 | @item -c @var{val} |
4380 | @item --codepage @var{val} | |
4381 | Specify the default codepage to use when reading an @code{rc} file. | |
4382 | @var{val} should be a hexadecimal prefixed by @samp{0x} or decimal | |
4383 | codepage code. The valid range is from zero up to 0xffff, but the | |
4384 | validity of the codepage is host and configuration dependent. | |
4385 | ||
3077f5d8 | 4386 | @item -l @var{val} |
252b5132 RH |
4387 | @item --language @var{val} |
4388 | Specify the default language to use when reading an @code{rc} file. | |
4389 | @var{val} should be a hexadecimal language code. The low eight bits are | |
4390 | the language, and the high eight bits are the sublanguage. | |
4391 | ||
5a298d2d NC |
4392 | @item --use-temp-file |
4393 | Use a temporary file to instead of using popen to read the output of | |
c1c0eb9e RM |
4394 | the preprocessor. Use this option if the popen implementation is buggy |
4395 | on the host (eg., certain non-English language versions of Windows 95 and | |
5a298d2d NC |
4396 | Windows 98 are known to have buggy popen where the output will instead |
4397 | go the console). | |
4398 | ||
4399 | @item --no-use-temp-file | |
4400 | Use popen, not a temporary file, to read the output of the preprocessor. | |
4401 | This is the default behaviour. | |
4402 | ||
3077f5d8 | 4403 | @item -h |
252b5132 RH |
4404 | @item --help |
4405 | Prints a usage summary. | |
4406 | ||
3077f5d8 | 4407 | @item -V |
252b5132 | 4408 | @item --version |
c7c55b78 | 4409 | Prints the version number for @command{windres}. |
252b5132 RH |
4410 | |
4411 | @item --yydebug | |
c7c55b78 | 4412 | If @command{windres} is compiled with @code{YYDEBUG} defined as @code{1}, |
252b5132 RH |
4413 | this will turn on parser debugging. |
4414 | @end table | |
4415 | ||
0285c67d NC |
4416 | @c man end |
4417 | ||
4418 | @ignore | |
4419 | @c man begin SEEALSO windres | |
4420 | the Info entries for @file{binutils}. | |
4421 | @c man end | |
4422 | @end ignore | |
252b5132 RH |
4423 | |
4424 | @node dlltool | |
2aa9814e | 4425 | @chapter dlltool |
252b5132 RH |
4426 | @cindex DLL |
4427 | @kindex dlltool | |
4428 | ||
2aa9814e BE |
4429 | @command{dlltool} is used to create the files needed to create dynamic |
4430 | link libraries (DLLs) on systems which understand PE format image | |
4431 | files such as Windows. A DLL contains an export table which contains | |
4432 | information that the runtime loader needs to resolve references from a | |
4433 | referencing program. | |
4434 | ||
4435 | The export table is generated by this program by reading in a | |
4436 | @file{.def} file or scanning the @file{.a} and @file{.o} files which | |
4437 | will be in the DLL. A @file{.o} file can contain information in | |
4438 | special @samp{.drectve} sections with export information. | |
252b5132 RH |
4439 | |
4440 | @quotation | |
2aa9814e BE |
4441 | @emph{Note:} @command{dlltool} is not always built as part of the |
4442 | binary utilities, since it is only useful for those targets which | |
4443 | support DLLs. | |
252b5132 RH |
4444 | @end quotation |
4445 | ||
f927cc8f | 4446 | @c man title dlltool create files needed to build and use DLLs |
0285c67d | 4447 | |
252b5132 | 4448 | @smallexample |
0285c67d | 4449 | @c man begin SYNOPSIS dlltool |
c7c55b78 NC |
4450 | dlltool [@option{-d}|@option{--input-def} @var{def-file-name}] |
4451 | [@option{-b}|@option{--base-file} @var{base-file-name}] | |
4452 | [@option{-e}|@option{--output-exp} @var{exports-file-name}] | |
4453 | [@option{-z}|@option{--output-def} @var{def-file-name}] | |
c1c0eb9e | 4454 | [@option{-l}|@option{--output-lib} @var{library-file-name}] |
10e636d2 | 4455 | [@option{-y}|@option{--output-delaylib} @var{library-file-name}] |
c7c55b78 NC |
4456 | [@option{--export-all-symbols}] [@option{--no-export-all-symbols}] |
4457 | [@option{--exclude-symbols} @var{list}] | |
4458 | [@option{--no-default-excludes}] | |
4459 | [@option{-S}|@option{--as} @var{path-to-assembler}] [@option{-f}|@option{--as-flags} @var{options}] | |
4460 | [@option{-D}|@option{--dllname} @var{name}] [@option{-m}|@option{--machine} @var{machine}] | |
14288fdc DS |
4461 | [@option{-a}|@option{--add-indirect}] |
4462 | [@option{-U}|@option{--add-underscore}] [@option{--add-stdcall-underscore}] | |
4463 | [@option{-k}|@option{--kill-at}] [@option{-A}|@option{--add-stdcall-alias}] | |
607dea97 | 4464 | [@option{-p}|@option{--ext-prefix-alias} @var{prefix}] |
d4732f7c | 4465 | [@option{-x}|@option{--no-idata4}] [@option{-c}|@option{--no-idata5}] |
e77b97d4 | 4466 | [@option{--use-nul-prefixed-import-tables}] |
71c57c16 NC |
4467 | [@option{-I}|@option{--identify} @var{library-file-name}] [@option{--identify-strict}] |
4468 | [@option{-i}|@option{--interwork}] | |
f9346411 | 4469 | [@option{-n}|@option{--nodelete}] [@option{-t}|@option{--temp-prefix} @var{prefix}] |
c1c0eb9e | 4470 | [@option{-v}|@option{--verbose}] |
c7c55b78 | 4471 | [@option{-h}|@option{--help}] [@option{-V}|@option{--version}] |
36d21de5 | 4472 | [@option{--no-leading-underscore}] [@option{--leading-underscore}] |
252b5132 | 4473 | [object-file @dots{}] |
0285c67d | 4474 | @c man end |
252b5132 RH |
4475 | @end smallexample |
4476 | ||
0285c67d NC |
4477 | @c man begin DESCRIPTION dlltool |
4478 | ||
c7c55b78 NC |
4479 | @command{dlltool} reads its inputs, which can come from the @option{-d} and |
4480 | @option{-b} options as well as object files specified on the command | |
4481 | line. It then processes these inputs and if the @option{-e} option has | |
4482 | been specified it creates a exports file. If the @option{-l} option | |
4483 | has been specified it creates a library file and if the @option{-z} option | |
c1c0eb9e RM |
4484 | has been specified it creates a def file. Any or all of the @option{-e}, |
4485 | @option{-l} and @option{-z} options can be present in one invocation of | |
c7c55b78 | 4486 | dlltool. |
252b5132 RH |
4487 | |
4488 | When creating a DLL, along with the source for the DLL, it is necessary | |
c7c55b78 | 4489 | to have three other files. @command{dlltool} can help with the creation of |
252b5132 RH |
4490 | these files. |
4491 | ||
2aa9814e | 4492 | The first file is a @file{.def} file which specifies which functions are |
252b5132 | 4493 | exported from the DLL, which functions the DLL imports, and so on. This |
c7c55b78 NC |
4494 | is a text file and can be created by hand, or @command{dlltool} can be used |
4495 | to create it using the @option{-z} option. In this case @command{dlltool} | |
252b5132 RH |
4496 | will scan the object files specified on its command line looking for |
4497 | those functions which have been specially marked as being exported and | |
2aa9814e | 4498 | put entries for them in the @file{.def} file it creates. |
252b5132 RH |
4499 | |
4500 | In order to mark a function as being exported from a DLL, it needs to | |
c7c55b78 | 4501 | have an @option{-export:<name_of_function>} entry in the @samp{.drectve} |
252b5132 RH |
4502 | section of the object file. This can be done in C by using the |
4503 | asm() operator: | |
4504 | ||
4505 | @smallexample | |
c1c0eb9e | 4506 | asm (".section .drectve"); |
252b5132 RH |
4507 | asm (".ascii \"-export:my_func\""); |
4508 | ||
4509 | int my_func (void) @{ @dots{} @} | |
4510 | @end smallexample | |
4511 | ||
4512 | The second file needed for DLL creation is an exports file. This file | |
4513 | is linked with the object files that make up the body of the DLL and it | |
4514 | handles the interface between the DLL and the outside world. This is a | |
c7c55b78 | 4515 | binary file and it can be created by giving the @option{-e} option to |
c1c0eb9e | 4516 | @command{dlltool} when it is creating or reading in a @file{.def} file. |
252b5132 RH |
4517 | |
4518 | The third file needed for DLL creation is the library file that programs | |
d4732f7c CW |
4519 | will link with in order to access the functions in the DLL (an `import |
4520 | library'). This file can be created by giving the @option{-l} option to | |
4521 | dlltool when it is creating or reading in a @file{.def} file. | |
252b5132 | 4522 | |
10e636d2 DK |
4523 | If the @option{-y} option is specified, dlltool generates a delay-import |
4524 | library that can be used instead of the normal import library to allow | |
4525 | a program to link to the dll only as soon as an imported function is | |
4526 | called for the first time. The resulting executable will need to be | |
4527 | linked to the static delayimp library containing __delayLoadHelper2(), | |
4528 | which in turn will import LoadLibraryA and GetProcAddress from kernel32. | |
4529 | ||
c7c55b78 | 4530 | @command{dlltool} builds the library file by hand, but it builds the |
252b5132 | 4531 | exports file by creating temporary files containing assembler statements |
a05a5b64 | 4532 | and then assembling these. The @option{-S} command-line option can be |
252b5132 | 4533 | used to specify the path to the assembler that dlltool will use, |
c7c55b78 NC |
4534 | and the @option{-f} option can be used to pass specific flags to that |
4535 | assembler. The @option{-n} can be used to prevent dlltool from deleting | |
4536 | these temporary assembler files when it is done, and if @option{-n} is | |
252b5132 RH |
4537 | specified twice then this will prevent dlltool from deleting the |
4538 | temporary object files it used to build the library. | |
4539 | ||
4540 | Here is an example of creating a DLL from a source file @samp{dll.c} and | |
4541 | also creating a program (from an object file called @samp{program.o}) | |
4542 | that uses that DLL: | |
4543 | ||
4544 | @smallexample | |
4545 | gcc -c dll.c | |
4546 | dlltool -e exports.o -l dll.lib dll.o | |
4547 | gcc dll.o exports.o -o dll.dll | |
4548 | gcc program.o dll.lib -o program | |
4549 | @end smallexample | |
4550 | ||
d4732f7c CW |
4551 | |
4552 | @command{dlltool} may also be used to query an existing import library | |
b3364cb9 | 4553 | to determine the name of the DLL to which it is associated. See the |
d4732f7c | 4554 | description of the @option{-I} or @option{--identify} option. |
b3364cb9 | 4555 | |
0285c67d NC |
4556 | @c man end |
4557 | ||
4558 | @c man begin OPTIONS dlltool | |
4559 | ||
a05a5b64 | 4560 | The command-line options have the following meanings: |
252b5132 | 4561 | |
c7c55b78 | 4562 | @table @env |
252b5132 RH |
4563 | |
4564 | @item -d @var{filename} | |
4565 | @itemx --input-def @var{filename} | |
4566 | @cindex input .def file | |
2aa9814e | 4567 | Specifies the name of a @file{.def} file to be read in and processed. |
252b5132 RH |
4568 | |
4569 | @item -b @var{filename} | |
4570 | @itemx --base-file @var{filename} | |
4571 | @cindex base files | |
4572 | Specifies the name of a base file to be read in and processed. The | |
4573 | contents of this file will be added to the relocation section in the | |
4574 | exports file generated by dlltool. | |
4575 | ||
4576 | @item -e @var{filename} | |
4577 | @itemx --output-exp @var{filename} | |
4578 | Specifies the name of the export file to be created by dlltool. | |
4579 | ||
4580 | @item -z @var{filename} | |
4581 | @itemx --output-def @var{filename} | |
2aa9814e | 4582 | Specifies the name of the @file{.def} file to be created by dlltool. |
252b5132 RH |
4583 | |
4584 | @item -l @var{filename} | |
4585 | @itemx --output-lib @var{filename} | |
4586 | Specifies the name of the library file to be created by dlltool. | |
4587 | ||
10e636d2 DK |
4588 | @item -y @var{filename} |
4589 | @itemx --output-delaylib @var{filename} | |
4590 | Specifies the name of the delay-import library file to be created by dlltool. | |
4591 | ||
252b5132 RH |
4592 | @item --export-all-symbols |
4593 | Treat all global and weak defined symbols found in the input object | |
4594 | files as symbols to be exported. There is a small list of symbols which | |
c7c55b78 | 4595 | are not exported by default; see the @option{--no-default-excludes} |
252b5132 | 4596 | option. You may add to the list of symbols to not export by using the |
c7c55b78 | 4597 | @option{--exclude-symbols} option. |
252b5132 RH |
4598 | |
4599 | @item --no-export-all-symbols | |
2aa9814e | 4600 | Only export symbols explicitly listed in an input @file{.def} file or in |
252b5132 RH |
4601 | @samp{.drectve} sections in the input object files. This is the default |
4602 | behaviour. The @samp{.drectve} sections are created by @samp{dllexport} | |
4603 | attributes in the source code. | |
4604 | ||
4605 | @item --exclude-symbols @var{list} | |
4606 | Do not export the symbols in @var{list}. This is a list of symbol names | |
4607 | separated by comma or colon characters. The symbol names should not | |
4608 | contain a leading underscore. This is only meaningful when | |
c7c55b78 | 4609 | @option{--export-all-symbols} is used. |
252b5132 RH |
4610 | |
4611 | @item --no-default-excludes | |
c7c55b78 | 4612 | When @option{--export-all-symbols} is used, it will by default avoid |
252b5132 RH |
4613 | exporting certain special symbols. The current list of symbols to avoid |
4614 | exporting is @samp{DllMain@@12}, @samp{DllEntryPoint@@0}, | |
c7c55b78 | 4615 | @samp{impure_ptr}. You may use the @option{--no-default-excludes} option |
252b5132 | 4616 | to go ahead and export these special symbols. This is only meaningful |
c7c55b78 | 4617 | when @option{--export-all-symbols} is used. |
252b5132 RH |
4618 | |
4619 | @item -S @var{path} | |
4620 | @itemx --as @var{path} | |
4621 | Specifies the path, including the filename, of the assembler to be used | |
4622 | to create the exports file. | |
4623 | ||
6364e0b4 NC |
4624 | @item -f @var{options} |
4625 | @itemx --as-flags @var{options} | |
a05a5b64 | 4626 | Specifies any specific command-line options to be passed to the |
252b5132 | 4627 | assembler when building the exports file. This option will work even if |
c7c55b78 | 4628 | the @option{-S} option is not used. This option only takes one argument, |
252b5132 RH |
4629 | and if it occurs more than once on the command line, then later |
4630 | occurrences will override earlier occurrences. So if it is necessary to | |
6364e0b4 | 4631 | pass multiple options to the assembler they should be enclosed in |
252b5132 RH |
4632 | double quotes. |
4633 | ||
4634 | @item -D @var{name} | |
4635 | @itemx --dll-name @var{name} | |
2aa9814e BE |
4636 | Specifies the name to be stored in the @file{.def} file as the name of |
4637 | the DLL when the @option{-e} option is used. If this option is not | |
4638 | present, then the filename given to the @option{-e} option will be | |
4639 | used as the name of the DLL. | |
252b5132 RH |
4640 | |
4641 | @item -m @var{machine} | |
4642 | @itemx -machine @var{machine} | |
4643 | Specifies the type of machine for which the library file should be | |
c7c55b78 | 4644 | built. @command{dlltool} has a built in default type, depending upon how |
252b5132 RH |
4645 | it was created, but this option can be used to override that. This is |
4646 | normally only useful when creating DLLs for an ARM processor, when the | |
c36774d6 | 4647 | contents of the DLL are actually encode using Thumb instructions. |
252b5132 RH |
4648 | |
4649 | @item -a | |
4650 | @itemx --add-indirect | |
c7c55b78 | 4651 | Specifies that when @command{dlltool} is creating the exports file it |
252b5132 RH |
4652 | should add a section which allows the exported functions to be |
4653 | referenced without using the import library. Whatever the hell that | |
c1c0eb9e | 4654 | means! |
252b5132 RH |
4655 | |
4656 | @item -U | |
4657 | @itemx --add-underscore | |
c7c55b78 | 4658 | Specifies that when @command{dlltool} is creating the exports file it |
c1c0eb9e | 4659 | should prepend an underscore to the names of @emph{all} exported symbols. |
14288fdc | 4660 | |
36d21de5 KT |
4661 | @item --no-leading-underscore |
4662 | @item --leading-underscore | |
4663 | Specifies whether standard symbol should be forced to be prefixed, or | |
4664 | not. | |
4665 | ||
14288fdc DS |
4666 | @item --add-stdcall-underscore |
4667 | Specifies that when @command{dlltool} is creating the exports file it | |
4668 | should prepend an underscore to the names of exported @emph{stdcall} | |
4669 | functions. Variable names and non-stdcall function names are not modified. | |
4670 | This option is useful when creating GNU-compatible import libs for third | |
4671 | party DLLs that were built with MS-Windows tools. | |
252b5132 RH |
4672 | |
4673 | @item -k | |
4674 | @itemx --kill-at | |
c1724c7f DK |
4675 | Specifies that @samp{@@<number>} suffixes should be omitted from the names |
4676 | of stdcall functions that will be imported from the DLL. This is | |
4677 | useful when creating an import library for a DLL which exports stdcall | |
4678 | functions but without the usual @samp{@@<number>} symbol name suffix. | |
4679 | ||
4680 | This does not change the naming of symbols provided by the import library | |
4681 | to programs linked against it, but only the entries in the import table | |
4682 | (ie the .idata section). | |
252b5132 RH |
4683 | |
4684 | @item -A | |
4685 | @itemx --add-stdcall-alias | |
c7c55b78 | 4686 | Specifies that when @command{dlltool} is creating the exports file it |
252b5132 RH |
4687 | should add aliases for stdcall symbols without @samp{@@ <number>} |
4688 | in addition to the symbols with @samp{@@ <number>}. | |
4689 | ||
607dea97 NC |
4690 | @item -p |
4691 | @itemx --ext-prefix-alias @var{prefix} | |
4692 | Causes @command{dlltool} to create external aliases for all DLL | |
4693 | imports with the specified prefix. The aliases are created for both | |
4694 | external and import symbols with no leading underscore. | |
4695 | ||
252b5132 RH |
4696 | @item -x |
4697 | @itemx --no-idata4 | |
c7c55b78 NC |
4698 | Specifies that when @command{dlltool} is creating the exports and library |
4699 | files it should omit the @code{.idata4} section. This is for compatibility | |
252b5132 RH |
4700 | with certain operating systems. |
4701 | ||
e77b97d4 KT |
4702 | @item --use-nul-prefixed-import-tables |
4703 | Specifies that when @command{dlltool} is creating the exports and library | |
4704 | files it should prefix the @code{.idata4} and @code{.idata5} by zero an | |
4705 | element. This emulates old gnu import library generation of | |
4706 | @code{dlltool}. By default this option is turned off. | |
4707 | ||
252b5132 RH |
4708 | @item -c |
4709 | @itemx --no-idata5 | |
c7c55b78 NC |
4710 | Specifies that when @command{dlltool} is creating the exports and library |
4711 | files it should omit the @code{.idata5} section. This is for compatibility | |
252b5132 RH |
4712 | with certain operating systems. |
4713 | ||
d4732f7c CW |
4714 | @item -I @var{filename} |
4715 | @itemx --identify @var{filename} | |
4716 | Specifies that @command{dlltool} should inspect the import library | |
71c57c16 NC |
4717 | indicated by @var{filename} and report, on @code{stdout}, the name(s) |
4718 | of the associated DLL(s). This can be performed in addition to any | |
4719 | other operations indicated by the other options and arguments. | |
4720 | @command{dlltool} fails if the import library does not exist or is not | |
4721 | actually an import library. See also @option{--identify-strict}. | |
4722 | ||
4723 | @item --identify-strict | |
4724 | Modifies the behavior of the @option{--identify} option, such | |
4725 | that an error is reported if @var{filename} is associated with | |
4726 | more than one DLL. | |
d4732f7c | 4727 | |
252b5132 RH |
4728 | @item -i |
4729 | @itemx --interwork | |
c7c55b78 | 4730 | Specifies that @command{dlltool} should mark the objects in the library |
252b5132 | 4731 | file and exports file that it produces as supporting interworking |
c36774d6 | 4732 | between ARM and Thumb code. |
252b5132 RH |
4733 | |
4734 | @item -n | |
4735 | @itemx --nodelete | |
c7c55b78 | 4736 | Makes @command{dlltool} preserve the temporary assembler files it used to |
252b5132 RH |
4737 | create the exports file. If this option is repeated then dlltool will |
4738 | also preserve the temporary object files it uses to create the library | |
f9346411 DS |
4739 | file. |
4740 | ||
4741 | @item -t @var{prefix} | |
4742 | @itemx --temp-prefix @var{prefix} | |
4743 | Makes @command{dlltool} use @var{prefix} when constructing the names of | |
4744 | temporary assembler and object files. By default, the temp file prefix | |
c1c0eb9e | 4745 | is generated from the pid. |
252b5132 RH |
4746 | |
4747 | @item -v | |
4748 | @itemx --verbose | |
4749 | Make dlltool describe what it is doing. | |
4750 | ||
4751 | @item -h | |
4752 | @itemx --help | |
a05a5b64 | 4753 | Displays a list of command-line options and then exits. |
252b5132 RH |
4754 | |
4755 | @item -V | |
4756 | @itemx --version | |
4757 | Displays dlltool's version number and then exits. | |
4758 | ||
4759 | @end table | |
4760 | ||
0285c67d NC |
4761 | @c man end |
4762 | ||
2aa9814e BE |
4763 | @menu |
4764 | * def file format:: The format of the dlltool @file{.def} file | |
4765 | @end menu | |
4766 | ||
4767 | @node def file format | |
4768 | @section The format of the @command{dlltool} @file{.def} file | |
4769 | ||
4770 | A @file{.def} file contains any number of the following commands: | |
4771 | ||
4772 | @table @asis | |
4773 | ||
4774 | @item @code{NAME} @var{name} @code{[ ,} @var{base} @code{]} | |
4775 | The result is going to be named @var{name}@code{.exe}. | |
4776 | ||
4777 | @item @code{LIBRARY} @var{name} @code{[ ,} @var{base} @code{]} | |
4778 | The result is going to be named @var{name}@code{.dll}. | |
5b3d386e KT |
4779 | Note: If you want to use LIBRARY as name then you need to quote. Otherwise |
4780 | this will fail due a necessary hack for libtool (see PR binutils/13710 for more | |
4781 | details). | |
2aa9814e | 4782 | |
bf201fdd | 4783 | @item @code{EXPORTS ( ( (} @var{name1} @code{[ = } @var{name2} @code{] ) | ( } @var{name1} @code{=} @var{module-name} @code{.} @var{external-name} @code{) ) [ == } @var{its_name} @code{]} |
2aa9814e BE |
4784 | @item @code{[} @var{integer} @code{] [ NONAME ] [ CONSTANT ] [ DATA ] [ PRIVATE ] ) *} |
4785 | Declares @var{name1} as an exported symbol from the DLL, with optional | |
4786 | ordinal number @var{integer}, or declares @var{name1} as an alias | |
bf201fdd KT |
4787 | (forward) of the function @var{external-name} in the DLL. |
4788 | If @var{its_name} is specified, this name is used as string in export table. | |
2aa9814e | 4789 | @var{module-name}. |
5b3d386e KT |
4790 | Note: The @code{EXPORTS} has to be the last command in .def file, as keywords |
4791 | are treated - beside @code{LIBRARY} - as simple name-identifiers. | |
4792 | If you want to use LIBRARY as name then you need to quote it. | |
2aa9814e | 4793 | |
bf201fdd | 4794 | @item @code{IMPORTS ( (} @var{internal-name} @code{=} @var{module-name} @code{.} @var{integer} @code{) | [} @var{internal-name} @code{= ]} @var{module-name} @code{.} @var{external-name} @code{) [ == ) @var{its_name} @code{]} *} |
2aa9814e BE |
4795 | Declares that @var{external-name} or the exported function whose |
4796 | ordinal number is @var{integer} is to be imported from the file | |
4797 | @var{module-name}. If @var{internal-name} is specified then this is | |
4798 | the name that the imported function will be referred to in the body of | |
4799 | the DLL. | |
bf201fdd | 4800 | If @var{its_name} is specified, this name is used as string in import table. |
5b3d386e KT |
4801 | Note: The @code{IMPORTS} has to be the last command in .def file, as keywords |
4802 | are treated - beside @code{LIBRARY} - as simple name-identifiers. | |
4803 | If you want to use LIBRARY as name then you need to quote it. | |
2aa9814e BE |
4804 | |
4805 | @item @code{DESCRIPTION} @var{string} | |
4806 | Puts @var{string} into the output @file{.exp} file in the | |
4807 | @code{.rdata} section. | |
4808 | ||
4809 | @item @code{STACKSIZE} @var{number-reserve} @code{[, } @var{number-commit} @code{]} | |
4810 | @item @code{HEAPSIZE} @var{number-reserve} @code{[, } @var{number-commit} @code{]} | |
4811 | Generates @code{--stack} or @code{--heap} | |
4812 | @var{number-reserve},@var{number-commit} in the output @code{.drectve} | |
4813 | section. The linker will see this and act upon it. | |
4814 | ||
4815 | @item @code{CODE} @var{attr} @code{+} | |
4816 | @item @code{DATA} @var{attr} @code{+} | |
4817 | @item @code{SECTIONS (} @var{section-name} @var{attr}@code{ + ) *} | |
4818 | Generates @code{--attr} @var{section-name} @var{attr} in the output | |
4819 | @code{.drectve} section, where @var{attr} is one of @code{READ}, | |
4820 | @code{WRITE}, @code{EXECUTE} or @code{SHARED}. The linker will see | |
4821 | this and act upon it. | |
4822 | ||
4823 | @end table | |
4824 | ||
0285c67d NC |
4825 | @ignore |
4826 | @c man begin SEEALSO dlltool | |
2aa9814e | 4827 | The Info pages for @file{binutils}. |
0285c67d NC |
4828 | @c man end |
4829 | @end ignore | |
4830 | ||
252b5132 RH |
4831 | @node readelf |
4832 | @chapter readelf | |
4833 | ||
4834 | @cindex ELF file information | |
4835 | @kindex readelf | |
4836 | ||
f927cc8f | 4837 | @c man title readelf display information about ELF files |
0285c67d | 4838 | |
252b5132 | 4839 | @smallexample |
0285c67d | 4840 | @c man begin SYNOPSIS readelf |
c1c0eb9e | 4841 | readelf [@option{-a}|@option{--all}] |
c7c55b78 NC |
4842 | [@option{-h}|@option{--file-header}] |
4843 | [@option{-l}|@option{--program-headers}|@option{--segments}] | |
4844 | [@option{-S}|@option{--section-headers}|@option{--sections}] | |
81fc812e | 4845 | [@option{-g}|@option{--section-groups}] |
5477e8a0 | 4846 | [@option{-t}|@option{--section-details}] |
c7c55b78 NC |
4847 | [@option{-e}|@option{--headers}] |
4848 | [@option{-s}|@option{--syms}|@option{--symbols}] | |
0f03783c | 4849 | [@option{--dyn-syms}|@option{--lto-syms}] |
047c3dbf | 4850 | [@option{--sym-base=[0|8|10|16]}] |
79bc120c | 4851 | [@option{--demangle@var{=style}}|@option{--no-demangle}] |
7fe1b138 | 4852 | [@option{--quiet}] |
79bc120c | 4853 | [@option{--recurse-limit}|@option{--no-recurse-limit}] |
b3aa80b4 | 4854 | [@option{-U} @var{method}|@option{--unicode=}@var{method}] |
c7c55b78 NC |
4855 | [@option{-n}|@option{--notes}] |
4856 | [@option{-r}|@option{--relocs}] | |
4857 | [@option{-u}|@option{--unwind}] | |
4858 | [@option{-d}|@option{--dynamic}] | |
4859 | [@option{-V}|@option{--version-info}] | |
947ed062 | 4860 | [@option{-A}|@option{--arch-specific}] |
c7c55b78 | 4861 | [@option{-D}|@option{--use-dynamic}] |
1b513401 | 4862 | [@option{-L}|@option{--lint}|@option{--enable-checks}] |
aef1f6d0 | 4863 | [@option{-x} <number or name>|@option{--hex-dump=}<number or name>] |
09c11c86 | 4864 | [@option{-p} <number or name>|@option{--string-dump=}<number or name>] |
cf13d699 | 4865 | [@option{-R} <number or name>|@option{--relocated-dump=}<number or name>] |
0e602686 | 4866 | [@option{-z}|@option{--decompress}] |
4145f1d5 | 4867 | [@option{-c}|@option{--archive-index}] |
c46b7066 NC |
4868 | [@option{-w[lLiaprmfFsoORtUuTgAck]}| |
4869 | @option{--debug-dump}[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=str-offsets,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index,=addr,=cu_index,=links]] | |
4870 | [@option{-wK}|@option{--debug-dump=follow-links}] | |
4871 | [@option{-wN}|@option{--debug-dump=no-follow-links}] | |
ca0e11aa | 4872 | [@option{-P}|@option{--process-links}] |
fd2f0033 TT |
4873 | [@option{--dwarf-depth=@var{n}}] |
4874 | [@option{--dwarf-start=@var{n}}] | |
7d9813f1 NA |
4875 | [@option{--ctf=}@var{section}] |
4876 | [@option{--ctf-parent=}@var{section}] | |
4877 | [@option{--ctf-symbols=}@var{section}] | |
4878 | [@option{--ctf-strings=}@var{section}] | |
ed22650e | 4879 | [@option{-I}|@option{--histogram}] |
c7c55b78 | 4880 | [@option{-v}|@option{--version}] |
d974e256 | 4881 | [@option{-W}|@option{--wide}] |
0942c7ab | 4882 | [@option{-T}|@option{--silent-truncation}] |
c7c55b78 | 4883 | [@option{-H}|@option{--help}] |
252b5132 | 4884 | @var{elffile}@dots{} |
0285c67d | 4885 | @c man end |
252b5132 RH |
4886 | @end smallexample |
4887 | ||
0285c67d NC |
4888 | @c man begin DESCRIPTION readelf |
4889 | ||
c7c55b78 | 4890 | @command{readelf} displays information about one or more ELF format object |
252b5132 RH |
4891 | files. The options control what particular information to display. |
4892 | ||
fb52b2f4 NC |
4893 | @var{elffile}@dots{} are the object files to be examined. 32-bit and |
4894 | 64-bit ELF files are supported, as are archives containing ELF files. | |
252b5132 | 4895 | |
9eb20dd8 NC |
4896 | This program performs a similar function to @command{objdump} but it |
4897 | goes into more detail and it exists independently of the @sc{bfd} | |
4898 | library, so if there is a bug in @sc{bfd} then readelf will not be | |
4899 | affected. | |
4900 | ||
0285c67d NC |
4901 | @c man end |
4902 | ||
4903 | @c man begin OPTIONS readelf | |
4904 | ||
252b5132 RH |
4905 | The long and short forms of options, shown here as alternatives, are |
4906 | equivalent. At least one option besides @samp{-v} or @samp{-H} must be | |
c1c0eb9e | 4907 | given. |
252b5132 | 4908 | |
c7c55b78 | 4909 | @table @env |
252b5132 RH |
4910 | @item -a |
4911 | @itemx --all | |
d95ef3ab | 4912 | Equivalent to specifying @option{--file-header}, |
c7c55b78 | 4913 | @option{--program-headers}, @option{--sections}, @option{--symbols}, |
ee357486 NC |
4914 | @option{--relocs}, @option{--dynamic}, @option{--notes}, |
4915 | @option{--version-info}, @option{--arch-specific}, @option{--unwind}, | |
4916 | @option{--section-groups} and @option{--histogram}. | |
4917 | ||
4918 | Note - this option does not enable @option{--use-dynamic} itself, so | |
4919 | if that option is not present on the command line then dynamic symbols | |
4920 | and dynamic relocs will not be displayed. | |
252b5132 RH |
4921 | |
4922 | @item -h | |
4923 | @itemx --file-header | |
4924 | @cindex ELF file header information | |
4925 | Displays the information contained in the ELF header at the start of the | |
4926 | file. | |
4927 | ||
4928 | @item -l | |
4929 | @itemx --program-headers | |
4930 | @itemx --segments | |
4931 | @cindex ELF program header information | |
4932 | @cindex ELF segment information | |
4933 | Displays the information contained in the file's segment headers, if it | |
4934 | has any. | |
4935 | ||
7fe1b138 FS |
4936 | @item --quiet |
4937 | @cindex quiet | |
4938 | Suppress "no symbols" diagnostic. | |
4939 | ||
252b5132 RH |
4940 | @item -S |
4941 | @itemx --sections | |
4942 | @itemx --section-headers | |
4943 | @cindex ELF section information | |
4944 | Displays the information contained in the file's section headers, if it | |
4945 | has any. | |
4946 | ||
81fc812e L |
4947 | @item -g |
4948 | @itemx --section-groups | |
4949 | @cindex ELF section group information | |
4950 | Displays the information contained in the file's section groups, if it | |
4951 | has any. | |
4952 | ||
5477e8a0 L |
4953 | @item -t |
4954 | @itemx --section-details | |
4955 | @cindex ELF section information | |
4956 | Displays the detailed section information. Implies @option{-S}. | |
81fc812e | 4957 | |
252b5132 RH |
4958 | @item -s |
4959 | @itemx --symbols | |
4960 | @itemx --syms | |
4961 | @cindex ELF symbol table information | |
4962 | Displays the entries in symbol table section of the file, if it has one. | |
df2c87b5 NC |
4963 | If a symbol has version information associated with it then this is |
4964 | displayed as well. The version string is displayed as a suffix to the | |
608d61c2 | 4965 | symbol name, preceded by an @@ character. For example |
df2c87b5 NC |
4966 | @samp{foo@@VER_1}. If the version is the default version to be used |
4967 | when resolving unversioned references to the symbol then it is | |
608d61c2 | 4968 | displayed as a suffix preceded by two @@ characters. For example |
df2c87b5 | 4969 | @samp{foo@@@@VER_2}. |
252b5132 | 4970 | |
2c610e4b L |
4971 | @item --dyn-syms |
4972 | @cindex ELF dynamic symbol table information | |
4973 | Displays the entries in dynamic symbol table section of the file, if it | |
df2c87b5 NC |
4974 | has one. The output format is the same as the format used by the |
4975 | @option{--syms} option. | |
2c610e4b | 4976 | |
0f03783c NC |
4977 | @item --lto-syms |
4978 | @cindex LTO symbol table | |
4979 | Displays the contents of any LTO symbol tables in the file. | |
4980 | ||
047c3dbf NL |
4981 | @item --sym-base=[0|8|10|16] |
4982 | @cindex symbol table size base | |
4983 | Forces the size field of the symbol table to use the given base. Any | |
4984 | unrecognized options will be treated as @samp{0}. @option{--sym-base=0} | |
4985 | represents the default and legacy behaviour. This will output sizes as decimal | |
4986 | for numbers less than 100000. For sizes 100000 and greater hexadecimal notation | |
4987 | will be used with a 0x prefix. | |
4988 | @option{--sym-base=8} will give the symbol sizes in octal. | |
4989 | @option{--sym-base=10} will always give the symbol sizes in decimal. | |
4990 | @option{--sym-base=16} will always give the symbol sizes in hexadecimal with a | |
4991 | 0x prefix. | |
4992 | ||
79bc120c NC |
4993 | @item -C |
4994 | @itemx --demangle[=@var{style}] | |
4995 | @cindex demangling in nm | |
4996 | Decode (@dfn{demangle}) low-level symbol names into user-level names. | |
4997 | This makes C++ function names readable. Different compilers have | |
4998 | different mangling styles. The optional demangling style argument can | |
4999 | be used to choose an appropriate demangling style for your | |
5000 | compiler. @xref{c++filt}, for more information on demangling. | |
5001 | ||
5002 | @item --no-demangle | |
5003 | Do not demangle low-level symbol names. This is the default. | |
5004 | ||
5005 | @item --recurse-limit | |
5006 | @itemx --no-recurse-limit | |
5007 | @itemx --recursion-limit | |
5008 | @itemx --no-recursion-limit | |
5009 | Enables or disables a limit on the amount of recursion performed | |
5010 | whilst demangling strings. Since the name mangling formats allow for | |
0cc79db2 | 5011 | an infinite level of recursion it is possible to create strings whose |
79bc120c NC |
5012 | decoding will exhaust the amount of stack space available on the host |
5013 | machine, triggering a memory fault. The limit tries to prevent this | |
5014 | from happening by restricting recursion to 2048 levels of nesting. | |
5015 | ||
5016 | The default is for this limit to be enabled, but disabling it may be | |
5017 | necessary in order to demangle truly complicated names. Note however | |
5018 | that if the recursion limit is disabled then stack exhaustion is | |
5019 | possible and any bug reports about such an event will be rejected. | |
5020 | ||
b3aa80b4 NC |
5021 | @item -U @var{[d|i|l|e|x|h]} |
5022 | @itemx --unicode=[default|invalid|locale|escape|hex|highlight] | |
5023 | Controls the display of non-ASCII characters in identifier names. | |
5024 | The default (@option{--unicode=locale} or @option{--unicode=default}) is | |
5025 | to treat them as multibyte characters and display them in the current | |
5026 | locale. All other versions of this option treat the bytes as UTF-8 | |
5027 | encoded values and attempt to interpret them. If they cannot be | |
5028 | interpreted or if the @option{--unicode=invalid} option is used then | |
5029 | they are displayed as a sequence of hex bytes, encloses in curly | |
5030 | parethesis characters. | |
5031 | ||
5032 | Using the @option{--unicode=escape} option will display the characters | |
5033 | as as unicode escape sequences (@var{\uxxxx}). Using the | |
5034 | @option{--unicode=hex} will display the characters as hex byte | |
5035 | sequences enclosed between angle brackets. | |
5036 | ||
5037 | Using the @option{--unicode=highlight} will display the characters as | |
5038 | unicode escape sequences but it will also highlighted them in red, | |
5039 | assuming that colouring is supported by the output device. The | |
5040 | colouring is intended to draw attention to the presence of unicode | |
5041 | sequences when they might not be expected. | |
5042 | ||
252b5132 RH |
5043 | @item -e |
5044 | @itemx --headers | |
c7c55b78 | 5045 | Display all the headers in the file. Equivalent to @option{-h -l -S}. |
252b5132 | 5046 | |
779fe533 NC |
5047 | @item -n |
5048 | @itemx --notes | |
1ec5cd37 NC |
5049 | @cindex ELF notes |
5050 | Displays the contents of the NOTE segments and/or sections, if any. | |
779fe533 | 5051 | |
252b5132 RH |
5052 | @item -r |
5053 | @itemx --relocs | |
5054 | @cindex ELF reloc information | |
f5e21966 NC |
5055 | Displays the contents of the file's relocation section, if it has one. |
5056 | ||
5057 | @item -u | |
5058 | @itemx --unwind | |
5059 | @cindex unwind information | |
5060 | Displays the contents of the file's unwind section, if it has one. Only | |
ba7f2642 | 5061 | the unwind sections for IA64 ELF files, as well as ARM unwind tables |
f63085d1 NC |
5062 | (@code{.ARM.exidx} / @code{.ARM.extab}) are currently supported. If |
5063 | support is not yet implemented for your architecture you could try | |
5064 | dumping the contents of the @var{.eh_frames} section using the | |
5065 | @option{--debug-dump=frames} or @option{--debug-dump=frames-interp} | |
5066 | options. | |
252b5132 RH |
5067 | |
5068 | @item -d | |
5069 | @itemx --dynamic | |
5070 | @cindex ELF dynamic section information | |
5071 | Displays the contents of the file's dynamic section, if it has one. | |
5072 | ||
5073 | @item -V | |
5074 | @itemx --version-info | |
a8685210 | 5075 | @cindex ELF version sections information |
252b5132 RH |
5076 | Displays the contents of the version sections in the file, it they |
5077 | exist. | |
5078 | ||
947ed062 NC |
5079 | @item -A |
5080 | @itemx --arch-specific | |
5081 | Displays architecture-specific information in the file, if there | |
5082 | is any. | |
5083 | ||
252b5132 RH |
5084 | @item -D |
5085 | @itemx --use-dynamic | |
c7c55b78 | 5086 | When displaying symbols, this option makes @command{readelf} use the |
2c610e4b L |
5087 | symbol hash tables in the file's dynamic section, rather than the |
5088 | symbol table sections. | |
252b5132 | 5089 | |
ee357486 NC |
5090 | When displaying relocations, this option makes @command{readelf} |
5091 | display the dynamic relocations rather than the static relocations. | |
5092 | ||
1b513401 NC |
5093 | @item -L |
5094 | @itemx --lint | |
5095 | @itemx --enable-checks | |
5096 | Displays warning messages about possible problems with the file(s) | |
5097 | being examined. If used on its own then all of the contents of the | |
5098 | file(s) will be examined. If used with one of the dumping options | |
5099 | then the warning messages will only be produced for the things being | |
5100 | displayed. | |
5101 | ||
aef1f6d0 DJ |
5102 | @item -x <number or name> |
5103 | @itemx --hex-dump=<number or name> | |
cf13d699 | 5104 | Displays the contents of the indicated section as a hexadecimal bytes. |
aef1f6d0 DJ |
5105 | A number identifies a particular section by index in the section table; |
5106 | any other string identifies all sections with that name in the object file. | |
252b5132 | 5107 | |
cf13d699 NC |
5108 | @item -R <number or name> |
5109 | @itemx --relocated-dump=<number or name> | |
5110 | Displays the contents of the indicated section as a hexadecimal | |
5111 | bytes. A number identifies a particular section by index in the | |
5112 | section table; any other string identifies all sections with that name | |
5113 | in the object file. The contents of the section will be relocated | |
5114 | before they are displayed. | |
5115 | ||
09c11c86 NC |
5116 | @item -p <number or name> |
5117 | @itemx --string-dump=<number or name> | |
5118 | Displays the contents of the indicated section as printable strings. | |
5119 | A number identifies a particular section by index in the section table; | |
5120 | any other string identifies all sections with that name in the object file. | |
5121 | ||
0e602686 NC |
5122 | @item -z |
5123 | @itemx --decompress | |
5124 | Requests that the section(s) being dumped by @option{x}, @option{R} or | |
5125 | @option{p} options are decompressed before being displayed. If the | |
5126 | section(s) are not compressed then they are displayed as is. | |
5127 | ||
4145f1d5 NC |
5128 | @item -c |
5129 | @itemx --archive-index | |
5130 | @cindex Archive file symbol index information | |
a8685210 | 5131 | Displays the file symbol index information contained in the header part |
4145f1d5 NC |
5132 | of binary archives. Performs the same function as the @option{t} |
5133 | command to @command{ar}, but without using the BFD library. @xref{ar}. | |
5134 | ||
e4b7104b NC |
5135 | @item -w[lLiaprmfFsOoRtUuTgAckK] |
5136 | @itemx --debug-dump[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=str-offsets,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index,=addr,=cu_index,=links,=follow-links] | |
dda8d76d | 5137 | @include debug.options.texi |
fd2f0033 | 5138 | |
ca0e11aa NC |
5139 | @item -P |
5140 | @itemx --process-links | |
5141 | Display the contents of non-debug sections found in separate debuginfo | |
5142 | files that are linked to the main file. This option automatically | |
5143 | implies the @option{-wK} option, and only sections requested by other | |
5144 | command line options will be displayed. | |
5145 | ||
7d9813f1 NA |
5146 | @include ctf.options.texi |
5147 | @item --ctf-symbols=@var{section} | |
5148 | @item --ctf-strings=@var{section} | |
5149 | Specify the name of another section from which the CTF file can inherit | |
616febde NA |
5150 | strings and symbols. By default, the @code{.symtab} and its linked |
5151 | string table are used. | |
7d9813f1 NA |
5152 | |
5153 | If either of @option{--ctf-symbols} or @option{--ctf-strings} is specified, the | |
5154 | other must be specified as well. | |
5155 | ||
947ed062 NC |
5156 | @item -I |
5157 | @itemx --histogram | |
252b5132 RH |
5158 | Display a histogram of bucket list lengths when displaying the contents |
5159 | of the symbol tables. | |
5160 | ||
5161 | @item -v | |
5162 | @itemx --version | |
5163 | Display the version number of readelf. | |
5164 | ||
d974e256 JJ |
5165 | @item -W |
5166 | @itemx --wide | |
5167 | Don't break output lines to fit into 80 columns. By default | |
5168 | @command{readelf} breaks section header and segment listing lines for | |
5169 | 64-bit ELF files, so that they fit into 80 columns. This option causes | |
5170 | @command{readelf} to print each section header resp. each segment one a | |
5171 | single line, which is far more readable on terminals wider than 80 columns. | |
5172 | ||
0942c7ab NC |
5173 | @item -T |
5174 | @itemx --silent-truncation | |
5175 | Normally when readelf is displaying a symbol name, and it has to | |
5176 | truncate the name to fit into an 80 column display, it will add a | |
5177 | suffix of @code{[...]} to the name. This command line option | |
5178 | disables this behaviour, allowing 5 more characters of the name to be | |
5179 | displayed and restoring the old behaviour of readelf (prior to release | |
5180 | 2.35). | |
5181 | ||
252b5132 RH |
5182 | @item -H |
5183 | @itemx --help | |
a05a5b64 | 5184 | Display the command-line options understood by @command{readelf}. |
252b5132 RH |
5185 | |
5186 | @end table | |
5187 | ||
0285c67d NC |
5188 | @c man end |
5189 | ||
5190 | @ignore | |
5191 | @c man begin SEEALSO readelf | |
5192 | objdump(1), and the Info entries for @file{binutils}. | |
5193 | @c man end | |
5194 | @end ignore | |
252b5132 | 5195 | |
30fd33bb L |
5196 | @node elfedit |
5197 | @chapter elfedit | |
5198 | ||
5199 | @cindex Update ELF header | |
5200 | @kindex elfedit | |
5201 | ||
f927cc8f | 5202 | @c man title elfedit update ELF header and program property of ELF files |
30fd33bb L |
5203 | |
5204 | @smallexample | |
5205 | @c man begin SYNOPSIS elfedit | |
5206 | elfedit [@option{--input-mach=}@var{machine}] | |
dd35de74 | 5207 | [@option{--input-type=}@var{type}] |
08ebfb8c | 5208 | [@option{--input-osabi=}@var{osabi}] |
c7a795f8 | 5209 | @option{--output-mach=}@var{machine} |
dd35de74 | 5210 | @option{--output-type=}@var{type} |
08ebfb8c | 5211 | @option{--output-osabi=}@var{osabi} |
8a6b075b L |
5212 | @option{--enable-x86-feature=}@var{feature} |
5213 | @option{--disable-x86-feature=}@var{feature} | |
30fd33bb L |
5214 | [@option{-v}|@option{--version}] |
5215 | [@option{-h}|@option{--help}] | |
5216 | @var{elffile}@dots{} | |
5217 | @c man end | |
5218 | @end smallexample | |
5219 | ||
5220 | @c man begin DESCRIPTION elfedit | |
5221 | ||
8a6b075b L |
5222 | @command{elfedit} updates the ELF header and program property of ELF |
5223 | files which have the matching ELF machine and file types. The options | |
5224 | control how and which fields in the ELF header and program property | |
5225 | should be updated. | |
30fd33bb L |
5226 | |
5227 | @var{elffile}@dots{} are the ELF files to be updated. 32-bit and | |
5228 | 64-bit ELF files are supported, as are archives containing ELF files. | |
5229 | @c man end | |
5230 | ||
5231 | @c man begin OPTIONS elfedit | |
5232 | ||
5233 | The long and short forms of options, shown here as alternatives, are | |
d0514c49 | 5234 | equivalent. At least one of the @option{--output-mach}, |
8a6b075b L |
5235 | @option{--output-type}, @option{--output-osabi}, |
5236 | @option{--enable-x86-feature} and @option{--disable-x86-feature} | |
5237 | options must be given. | |
30fd33bb L |
5238 | |
5239 | @table @env | |
5240 | ||
574b25e8 | 5241 | @item --input-mach=@var{machine} |
dd35de74 L |
5242 | Set the matching input ELF machine type to @var{machine}. If |
5243 | @option{--input-mach} isn't specified, it will match any ELF | |
5244 | machine types. | |
30fd33bb | 5245 | |
6c14750f L |
5246 | The supported ELF machine types are, @var{i386}, @var{IAMCU}, @var{L1OM}, |
5247 | @var{K1OM} and @var{x86-64}. | |
30fd33bb | 5248 | |
574b25e8 | 5249 | @item --output-mach=@var{machine} |
30fd33bb L |
5250 | Change the ELF machine type in the ELF header to @var{machine}. The |
5251 | supported ELF machine types are the same as @option{--input-mach}. | |
5252 | ||
574b25e8 | 5253 | @item --input-type=@var{type} |
dd35de74 L |
5254 | Set the matching input ELF file type to @var{type}. If |
5255 | @option{--input-type} isn't specified, it will match any ELF file types. | |
5256 | ||
5257 | The supported ELF file types are, @var{rel}, @var{exec} and @var{dyn}. | |
5258 | ||
574b25e8 | 5259 | @item --output-type=@var{type} |
dd35de74 L |
5260 | Change the ELF file type in the ELF header to @var{type}. The |
5261 | supported ELF types are the same as @option{--input-type}. | |
5262 | ||
574b25e8 | 5263 | @item --input-osabi=@var{osabi} |
08ebfb8c | 5264 | Set the matching input ELF file OSABI to @var{osabi}. If |
d0514c49 L |
5265 | @option{--input-osabi} isn't specified, it will match any ELF OSABIs. |
5266 | ||
5267 | The supported ELF OSABIs are, @var{none}, @var{HPUX}, @var{NetBSD}, | |
9c55345c TS |
5268 | @var{GNU}, @var{Linux} (alias for @var{GNU}), |
5269 | @var{Solaris}, @var{AIX}, @var{Irix}, | |
d0514c49 L |
5270 | @var{FreeBSD}, @var{TRU64}, @var{Modesto}, @var{OpenBSD}, @var{OpenVMS}, |
5271 | @var{NSK}, @var{AROS} and @var{FenixOS}. | |
5272 | ||
574b25e8 | 5273 | @item --output-osabi=@var{osabi} |
08ebfb8c | 5274 | Change the ELF OSABI in the ELF header to @var{osabi}. The |
d0514c49 L |
5275 | supported ELF OSABI are the same as @option{--input-osabi}. |
5276 | ||
8a6b075b L |
5277 | @item --enable-x86-feature=@var{feature} |
5278 | Set the @var{feature} bit in program property in @var{exec} or @var{dyn} | |
5279 | ELF files with machine types of @var{i386} or @var{x86-64}. The | |
279d901e L |
5280 | supported features are, @var{ibt}, @var{shstk}, @var{lam_u48} and |
5281 | @var{lam_u57}. | |
8a6b075b L |
5282 | |
5283 | @item --disable-x86-feature=@var{feature} | |
5284 | Clear the @var{feature} bit in program property in @var{exec} or | |
5285 | @var{dyn} ELF files with machine types of @var{i386} or @var{x86-64}. | |
5286 | The supported features are the same as @option{--enable-x86-feature}. | |
5287 | ||
5288 | Note: @option{--enable-x86-feature} and @option{--disable-x86-feature} | |
5289 | are available only on hosts with @samp{mmap} support. | |
5290 | ||
30fd33bb L |
5291 | @item -v |
5292 | @itemx --version | |
5293 | Display the version number of @command{elfedit}. | |
5294 | ||
5295 | @item -h | |
5296 | @itemx --help | |
a05a5b64 | 5297 | Display the command-line options understood by @command{elfedit}. |
30fd33bb L |
5298 | |
5299 | @end table | |
5300 | ||
5301 | @c man end | |
5302 | ||
5303 | @ignore | |
5304 | @c man begin SEEALSO elfedit | |
5305 | readelf(1), and the Info entries for @file{binutils}. | |
5306 | @c man end | |
5307 | @end ignore | |
5308 | ||
07012eee MM |
5309 | @node Common Options |
5310 | @chapter Common Options | |
5311 | ||
5312 | The following command-line options are supported by all of the | |
5313 | programs described in this manual. | |
5314 | ||
dff70155 | 5315 | @c man begin OPTIONS |
07012eee | 5316 | @table @env |
38fc1cb1 | 5317 | @include at-file.texi |
dff70155 | 5318 | @c man end |
07012eee MM |
5319 | |
5320 | @item --help | |
5321 | Display the command-line options supported by the program. | |
5322 | ||
5323 | @item --version | |
5324 | Display the version number of the program. | |
5325 | ||
dff70155 | 5326 | @c man begin OPTIONS |
07012eee | 5327 | @end table |
dff70155 | 5328 | @c man end |
07012eee | 5329 | |
fff279a7 | 5330 | @node Selecting the Target System |
947ed062 | 5331 | @chapter Selecting the Target System |
252b5132 | 5332 | |
947ed062 | 5333 | You can specify two aspects of the target system to the @sc{gnu} |
252b5132 RH |
5334 | binary file utilities, each in several ways: |
5335 | ||
5336 | @itemize @bullet | |
5337 | @item | |
5338 | the target | |
5339 | ||
5340 | @item | |
5341 | the architecture | |
252b5132 RH |
5342 | @end itemize |
5343 | ||
5344 | In the following summaries, the lists of ways to specify values are in | |
5345 | order of decreasing precedence. The ways listed first override those | |
5346 | listed later. | |
5347 | ||
5348 | The commands to list valid values only list the values for which the | |
5349 | programs you are running were configured. If they were configured with | |
c7c55b78 | 5350 | @option{--enable-targets=all}, the commands list most of the available |
252b5132 RH |
5351 | values, but a few are left out; not all targets can be configured in at |
5352 | once because some of them can only be configured @dfn{native} (on hosts | |
5353 | with the same type as the target system). | |
5354 | ||
5355 | @menu | |
c1c0eb9e RM |
5356 | * Target Selection:: |
5357 | * Architecture Selection:: | |
252b5132 RH |
5358 | @end menu |
5359 | ||
5360 | @node Target Selection | |
5361 | @section Target Selection | |
5362 | ||
5363 | A @dfn{target} is an object file format. A given target may be | |
5364 | supported for multiple architectures (@pxref{Architecture Selection}). | |
5365 | A target selection may also have variations for different operating | |
5366 | systems or architectures. | |
5367 | ||
5368 | The command to list valid target values is @samp{objdump -i} | |
5369 | (the first column of output contains the relevant information). | |
5370 | ||
5371 | Some sample values are: @samp{a.out-hp300bsd}, @samp{ecoff-littlemips}, | |
5372 | @samp{a.out-sunos-big}. | |
5373 | ||
5374 | You can also specify a target using a configuration triplet. This is | |
f20a759a ILT |
5375 | the same sort of name that is passed to @file{configure} to specify a |
5376 | target. When you use a configuration triplet as an argument, it must be | |
5377 | fully canonicalized. You can see the canonical version of a triplet by | |
252b5132 RH |
5378 | running the shell script @file{config.sub} which is included with the |
5379 | sources. | |
5380 | ||
5381 | Some sample configuration triplets are: @samp{m68k-hp-bsd}, | |
5382 | @samp{mips-dec-ultrix}, @samp{sparc-sun-sunos}. | |
5383 | ||
c7c55b78 | 5384 | @subheading @command{objdump} Target |
252b5132 RH |
5385 | |
5386 | Ways to specify: | |
5387 | ||
5388 | @enumerate | |
5389 | @item | |
a05a5b64 | 5390 | command-line option: @option{-b} or @option{--target} |
252b5132 RH |
5391 | |
5392 | @item | |
5393 | environment variable @code{GNUTARGET} | |
5394 | ||
5395 | @item | |
5396 | deduced from the input file | |
5397 | @end enumerate | |
5398 | ||
c7c55b78 | 5399 | @subheading @command{objcopy} and @command{strip} Input Target |
252b5132 RH |
5400 | |
5401 | Ways to specify: | |
5402 | ||
5403 | @enumerate | |
5404 | @item | |
a05a5b64 | 5405 | command-line options: @option{-I} or @option{--input-target}, or @option{-F} or @option{--target} |
252b5132 RH |
5406 | |
5407 | @item | |
5408 | environment variable @code{GNUTARGET} | |
5409 | ||
5410 | @item | |
5411 | deduced from the input file | |
5412 | @end enumerate | |
5413 | ||
c7c55b78 | 5414 | @subheading @command{objcopy} and @command{strip} Output Target |
252b5132 RH |
5415 | |
5416 | Ways to specify: | |
5417 | ||
5418 | @enumerate | |
5419 | @item | |
a05a5b64 | 5420 | command-line options: @option{-O} or @option{--output-target}, or @option{-F} or @option{--target} |
252b5132 RH |
5421 | |
5422 | @item | |
c7c55b78 | 5423 | the input target (see ``@command{objcopy} and @command{strip} Input Target'' above) |
252b5132 RH |
5424 | |
5425 | @item | |
5426 | environment variable @code{GNUTARGET} | |
5427 | ||
5428 | @item | |
5429 | deduced from the input file | |
5430 | @end enumerate | |
5431 | ||
c7c55b78 | 5432 | @subheading @command{nm}, @command{size}, and @command{strings} Target |
252b5132 RH |
5433 | |
5434 | Ways to specify: | |
5435 | ||
5436 | @enumerate | |
5437 | @item | |
a05a5b64 | 5438 | command-line option: @option{--target} |
252b5132 RH |
5439 | |
5440 | @item | |
5441 | environment variable @code{GNUTARGET} | |
5442 | ||
5443 | @item | |
5444 | deduced from the input file | |
5445 | @end enumerate | |
5446 | ||
252b5132 | 5447 | @node Architecture Selection |
947ed062 | 5448 | @section Architecture Selection |
252b5132 RH |
5449 | |
5450 | An @dfn{architecture} is a type of @sc{cpu} on which an object file is | |
5451 | to run. Its name may contain a colon, separating the name of the | |
5452 | processor family from the name of the particular @sc{cpu}. | |
5453 | ||
5454 | The command to list valid architecture values is @samp{objdump -i} (the | |
5455 | second column contains the relevant information). | |
5456 | ||
5457 | Sample values: @samp{m68k:68020}, @samp{mips:3000}, @samp{sparc}. | |
5458 | ||
c7c55b78 | 5459 | @subheading @command{objdump} Architecture |
252b5132 RH |
5460 | |
5461 | Ways to specify: | |
5462 | ||
5463 | @enumerate | |
5464 | @item | |
a05a5b64 | 5465 | command-line option: @option{-m} or @option{--architecture} |
252b5132 RH |
5466 | |
5467 | @item | |
5468 | deduced from the input file | |
5469 | @end enumerate | |
5470 | ||
c7c55b78 | 5471 | @subheading @command{objcopy}, @command{nm}, @command{size}, @command{strings} Architecture |
252b5132 RH |
5472 | |
5473 | Ways to specify: | |
5474 | ||
5475 | @enumerate | |
5476 | @item | |
5477 | deduced from the input file | |
5478 | @end enumerate | |
5479 | ||
301a9420 AM |
5480 | @node debuginfod |
5481 | @chapter debuginfod | |
5482 | @cindex separate debug files | |
5483 | ||
5484 | debuginfod is a web service that indexes ELF/DWARF debugging resources | |
5485 | by build-id and serves them over HTTP. | |
5486 | ||
5487 | Binutils can be built with the debuginfod client library | |
5488 | @code{libdebuginfod} using the @option{--with-debuginfod} configure option. | |
5489 | This option is enabled by default if @code{libdebuginfod} is installed | |
5490 | and found at configure time. This allows @command{objdump} and | |
5491 | @command{readelf} to automatically query debuginfod servers for | |
5492 | separate debug files when the files are otherwise not found. | |
5493 | ||
5494 | debuginfod is packaged with elfutils, starting with version 0.178. | |
5495 | You can get the latest version from `https://sourceware.org/elfutils/'. | |
5496 | ||
252b5132 RH |
5497 | @node Reporting Bugs |
5498 | @chapter Reporting Bugs | |
5499 | @cindex bugs | |
5500 | @cindex reporting bugs | |
5501 | ||
5502 | Your bug reports play an essential role in making the binary utilities | |
5503 | reliable. | |
5504 | ||
5505 | Reporting a bug may help you by bringing a solution to your problem, or | |
5506 | it may not. But in any case the principal function of a bug report is | |
5507 | to help the entire community by making the next version of the binary | |
5508 | utilities work better. Bug reports are your contribution to their | |
5509 | maintenance. | |
5510 | ||
5511 | In order for a bug report to serve its purpose, you must include the | |
5512 | information that enables us to fix the bug. | |
5513 | ||
5514 | @menu | |
5515 | * Bug Criteria:: Have you found a bug? | |
5516 | * Bug Reporting:: How to report bugs | |
5517 | @end menu | |
5518 | ||
5519 | @node Bug Criteria | |
947ed062 | 5520 | @section Have You Found a Bug? |
252b5132 RH |
5521 | @cindex bug criteria |
5522 | ||
5523 | If you are not sure whether you have found a bug, here are some guidelines: | |
5524 | ||
5525 | @itemize @bullet | |
5526 | @cindex fatal signal | |
5527 | @cindex crash | |
5528 | @item | |
5529 | If a binary utility gets a fatal signal, for any input whatever, that is | |
5530 | a bug. Reliable utilities never crash. | |
5531 | ||
5532 | @cindex error on valid input | |
5533 | @item | |
5534 | If a binary utility produces an error message for valid input, that is a | |
5535 | bug. | |
5536 | ||
5537 | @item | |
5538 | If you are an experienced user of binary utilities, your suggestions for | |
5539 | improvement are welcome in any case. | |
5540 | @end itemize | |
5541 | ||
5542 | @node Bug Reporting | |
947ed062 | 5543 | @section How to Report Bugs |
252b5132 RH |
5544 | @cindex bug reports |
5545 | @cindex bugs, reporting | |
5546 | ||
5547 | A number of companies and individuals offer support for @sc{gnu} | |
5548 | products. If you obtained the binary utilities from a support | |
5549 | organization, we recommend you contact that organization first. | |
5550 | ||
5551 | You can find contact information for many support companies and | |
5552 | individuals in the file @file{etc/SERVICE} in the @sc{gnu} Emacs | |
5553 | distribution. | |
5554 | ||
ad22bfe8 | 5555 | @ifset BUGURL |
252b5132 | 5556 | In any event, we also recommend that you send bug reports for the binary |
ad22bfe8 JM |
5557 | utilities to @value{BUGURL}. |
5558 | @end ifset | |
252b5132 RH |
5559 | |
5560 | The fundamental principle of reporting bugs usefully is this: | |
5561 | @strong{report all the facts}. If you are not sure whether to state a | |
5562 | fact or leave it out, state it! | |
5563 | ||
5564 | Often people omit facts because they think they know what causes the | |
5565 | problem and assume that some details do not matter. Thus, you might | |
5566 | assume that the name of a file you use in an example does not matter. | |
5567 | Well, probably it does not, but one cannot be sure. Perhaps the bug is | |
5568 | a stray memory reference which happens to fetch from the location where | |
5569 | that pathname is stored in memory; perhaps, if the pathname were | |
5570 | different, the contents of that location would fool the utility into | |
5571 | doing the right thing despite the bug. Play it safe and give a | |
5572 | specific, complete example. That is the easiest thing for you to do, | |
5573 | and the most helpful. | |
5574 | ||
5575 | Keep in mind that the purpose of a bug report is to enable us to fix the bug if | |
5576 | it is new to us. Therefore, always write your bug reports on the assumption | |
5577 | that the bug has not been reported previously. | |
5578 | ||
5579 | Sometimes people give a few sketchy facts and ask, ``Does this ring a | |
947ed062 NC |
5580 | bell?'' This cannot help us fix a bug, so it is basically useless. We |
5581 | respond by asking for enough details to enable us to investigate. | |
5582 | You might as well expedite matters by sending them to begin with. | |
252b5132 RH |
5583 | |
5584 | To enable us to fix the bug, you should include all these things: | |
5585 | ||
5586 | @itemize @bullet | |
5587 | @item | |
5588 | The version of the utility. Each utility announces it if you start it | |
c7c55b78 | 5589 | with the @option{--version} argument. |
252b5132 RH |
5590 | |
5591 | Without this, we will not know whether there is any point in looking for | |
5592 | the bug in the current version of the binary utilities. | |
5593 | ||
5594 | @item | |
5595 | Any patches you may have applied to the source, including any patches | |
5596 | made to the @code{BFD} library. | |
5597 | ||
5598 | @item | |
5599 | The type of machine you are using, and the operating system name and | |
5600 | version number. | |
5601 | ||
5602 | @item | |
5603 | What compiler (and its version) was used to compile the utilities---e.g. | |
5604 | ``@code{gcc-2.7}''. | |
5605 | ||
5606 | @item | |
5607 | The command arguments you gave the utility to observe the bug. To | |
5608 | guarantee you will not omit something important, list them all. A copy | |
5609 | of the Makefile (or the output from make) is sufficient. | |
5610 | ||
5611 | If we were to try to guess the arguments, we would probably guess wrong | |
5612 | and then we might not encounter the bug. | |
5613 | ||
5614 | @item | |
5615 | A complete input file, or set of input files, that will reproduce the | |
5616 | bug. If the utility is reading an object file or files, then it is | |
ad22bfe8 | 5617 | generally most helpful to send the actual object files. |
252b5132 RH |
5618 | |
5619 | If the source files were produced exclusively using @sc{gnu} programs | |
c7c55b78 | 5620 | (e.g., @command{gcc}, @command{gas}, and/or the @sc{gnu} @command{ld}), then it |
252b5132 | 5621 | may be OK to send the source files rather than the object files. In |
c7c55b78 | 5622 | this case, be sure to say exactly what version of @command{gcc}, or |
252b5132 | 5623 | whatever, was used to produce the object files. Also say how |
c7c55b78 | 5624 | @command{gcc}, or whatever, was configured. |
252b5132 RH |
5625 | |
5626 | @item | |
5627 | A description of what behavior you observe that you believe is | |
5628 | incorrect. For example, ``It gets a fatal signal.'' | |
5629 | ||
5630 | Of course, if the bug is that the utility gets a fatal signal, then we | |
5631 | will certainly notice it. But if the bug is incorrect output, we might | |
5632 | not notice unless it is glaringly wrong. You might as well not give us | |
5633 | a chance to make a mistake. | |
5634 | ||
5635 | Even if the problem you experience is a fatal signal, you should still | |
f20a759a | 5636 | say so explicitly. Suppose something strange is going on, such as your |
b45619c0 | 5637 | copy of the utility is out of sync, or you have encountered a bug in |
252b5132 RH |
5638 | the C library on your system. (This has happened!) Your copy might |
5639 | crash and ours would not. If you told us to expect a crash, then when | |
5640 | ours fails to crash, we would know that the bug was not happening for | |
5641 | us. If you had not told us to expect a crash, then we would not be able | |
5642 | to draw any conclusion from our observations. | |
5643 | ||
5644 | @item | |
5645 | If you wish to suggest changes to the source, send us context diffs, as | |
c7c55b78 | 5646 | generated by @command{diff} with the @option{-u}, @option{-c}, or @option{-p} |
252b5132 | 5647 | option. Always send diffs from the old file to the new file. If you |
c7c55b78 | 5648 | wish to discuss something in the @command{ld} source, refer to it by |
f20a759a | 5649 | context, not by line number. |
252b5132 RH |
5650 | |
5651 | The line numbers in our development sources will not match those in your | |
5652 | sources. Your line numbers would convey no useful information to us. | |
5653 | @end itemize | |
5654 | ||
5655 | Here are some things that are not necessary: | |
5656 | ||
5657 | @itemize @bullet | |
5658 | @item | |
5659 | A description of the envelope of the bug. | |
5660 | ||
5661 | Often people who encounter a bug spend a lot of time investigating | |
5662 | which changes to the input file will make the bug go away and which | |
5663 | changes will not affect it. | |
5664 | ||
5665 | This is often time consuming and not very useful, because the way we | |
5666 | will find the bug is by running a single example under the debugger | |
5667 | with breakpoints, not by pure deduction from a series of examples. | |
5668 | We recommend that you save your time for something else. | |
5669 | ||
5670 | Of course, if you can find a simpler example to report @emph{instead} | |
5671 | of the original one, that is a convenience for us. Errors in the | |
5672 | output will be easier to spot, running under the debugger will take | |
5673 | less time, and so on. | |
5674 | ||
5675 | However, simplification is not vital; if you do not want to do this, | |
5676 | report the bug anyway and send us the entire test case you used. | |
5677 | ||
5678 | @item | |
5679 | A patch for the bug. | |
5680 | ||
5681 | A patch for the bug does help us if it is a good one. But do not omit | |
5682 | the necessary information, such as the test case, on the assumption that | |
5683 | a patch is all we need. We might see problems with your patch and decide | |
5684 | to fix the problem another way, or we might not understand it at all. | |
5685 | ||
5686 | Sometimes with programs as complicated as the binary utilities it is | |
5687 | very hard to construct an example that will make the program follow a | |
5688 | certain path through the code. If you do not send us the example, we | |
5689 | will not be able to construct one, so we will not be able to verify that | |
5690 | the bug is fixed. | |
5691 | ||
5692 | And if we cannot understand what bug you are trying to fix, or why your | |
5693 | patch should be an improvement, we will not install it. A test case will | |
5694 | help us to understand. | |
5695 | ||
5696 | @item | |
5697 | A guess about what the bug is or what it depends on. | |
5698 | ||
5699 | Such guesses are usually wrong. Even we cannot guess right about such | |
5700 | things without first using the debugger to find the facts. | |
5701 | @end itemize | |
5702 | ||
fff279a7 NC |
5703 | @node GNU Free Documentation License |
5704 | @appendix GNU Free Documentation License | |
b3364cb9 | 5705 | |
947ed062 | 5706 | @include fdl.texi |
cf055d54 | 5707 | |
fa0d8a3e NC |
5708 | @node Binutils Index |
5709 | @unnumbered Binutils Index | |
252b5132 RH |
5710 | |
5711 | @printindex cp | |
5712 | ||
252b5132 | 5713 | @bye |