]>
Commit | Line | Data |
---|---|---|
252b5132 RH |
1 | \input texinfo @c -*- Texinfo -*- |
2 | @setfilename binutils.info | |
3 | @include config.texi | |
4 | ||
5 | @ifinfo | |
6 | @format | |
7 | START-INFO-DIR-ENTRY | |
ad0481cd AS |
8 | * Binutils: (binutils). The GNU binary utilities. |
9 | * ar: (binutils)ar. Create, modify, and extract from archives | |
10 | * nm: (binutils)nm. List symbols from object files | |
11 | * objcopy: (binutils)objcopy. Copy and translate object files | |
12 | * objdump: (binutils)objdump. Display information from object files | |
13 | * ranlib: (binutils)ranlib. Generate index to archive contents | |
14 | * readelf: (binutils)readelf. Display the contents of ELF format files. | |
15 | * size: (binutils)size. List section sizes and total size | |
16 | * strings: (binutils)strings. List printable strings from files | |
17 | * strip: (binutils)strip. Discard symbols | |
18 | * c++filt: (binutils)c++filt. Filter to demangle encoded C++ symbols | |
19 | * cxxfilt: (binutils)c++filt. MS-DOS name for c++filt | |
20 | * addr2line: (binutils)addr2line. Convert addresses to file and line | |
21 | * nlmconv: (binutils)nlmconv. Converts object code into an NLM | |
22 | * windres: (binutils)windres. Manipulate Windows resources | |
23 | * dlltool: (binutils)dlltool. Create files needed to build and use DLLs | |
252b5132 RH |
24 | END-INFO-DIR-ENTRY |
25 | @end format | |
26 | @end ifinfo | |
27 | ||
28 | @ifinfo | |
8f915f68 | 29 | Copyright @copyright{} 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. |
252b5132 RH |
30 | |
31 | Permission is granted to make and distribute verbatim copies of | |
32 | this manual provided the copyright notice and this permission notice | |
33 | are preserved on all copies. | |
34 | ||
35 | @ignore | |
36 | Permission is granted to process this file through TeX and print the | |
37 | results, provided the printed document carries a copying permission | |
38 | notice identical to this one except for the removal of this paragraph | |
39 | (this paragraph not being relevant to the printed manual). | |
40 | ||
41 | @end ignore | |
42 | ||
43 | Permission is granted to copy and distribute modified versions of this | |
44 | manual under the conditions for verbatim copying, provided also that | |
45 | the entire resulting derived work is distributed under the terms of a | |
46 | permission notice identical to this one. | |
47 | ||
48 | Permission is granted to copy and distribute translations of this manual | |
49 | into another language, under the above conditions for modified versions. | |
50 | @end ifinfo | |
51 | ||
52 | @synindex ky cp | |
53 | @c | |
54 | @c This file documents the GNU binary utilities "ar", "ld", "objcopy", | |
55 | @c "objdump", "nm", "size", "strings", "strip", "readelf" and "ranlib". | |
56 | @c | |
8f915f68 | 57 | @c Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. |
252b5132 RH |
58 | @c |
59 | @c This text may be freely distributed under the terms of the GNU | |
60 | @c General Public License. | |
61 | @c | |
62 | ||
63 | @setchapternewpage odd | |
64 | @settitle @sc{gnu} Binary Utilities | |
65 | @titlepage | |
66 | @finalout | |
67 | @title The @sc{gnu} Binary Utilities | |
68 | @subtitle Version @value{VERSION} | |
69 | @sp 1 | |
70 | @subtitle May 1993 | |
71 | @author Roland H. Pesch | |
72 | @author Jeffrey M. Osier | |
73 | @author Cygnus Support | |
74 | @page | |
75 | ||
76 | @tex | |
77 | {\parskip=0pt \hfill Cygnus Support\par \hfill | |
78 | \TeX{}info \texinfoversion\par } | |
79 | @end tex | |
80 | ||
81 | @vskip 0pt plus 1filll | |
82 | Copyright @copyright{} 1991, 92, 93, 94, 95, 96, 97, 1998 Free Software Foundation, Inc. | |
83 | ||
84 | Permission is granted to make and distribute verbatim copies of | |
85 | this manual provided the copyright notice and this permission notice | |
86 | are preserved on all copies. | |
87 | ||
88 | Permission is granted to copy and distribute modified versions of this | |
89 | manual under the conditions for verbatim copying, provided also that | |
90 | the entire resulting derived work is distributed under the terms of a | |
91 | permission notice identical to this one. | |
92 | ||
93 | Permission is granted to copy and distribute translations of this manual | |
94 | into another language, under the above conditions for modified versions. | |
95 | @end titlepage | |
96 | ||
97 | @node Top | |
98 | @top Introduction | |
99 | ||
100 | @cindex version | |
101 | This brief manual contains preliminary documentation for the @sc{gnu} binary | |
102 | utilities (collectively version @value{VERSION}): | |
103 | ||
104 | @iftex | |
105 | @table @code | |
106 | @item ar | |
107 | Create, modify, and extract from archives | |
108 | ||
109 | @item nm | |
110 | List symbols from object files | |
111 | ||
112 | @item objcopy | |
113 | Copy and translate object files | |
114 | ||
115 | @item objdump | |
116 | Display information from object files | |
117 | ||
118 | @item ranlib | |
119 | Generate index to archive contents | |
120 | ||
121 | @item readelf | |
122 | Display the contents of ELF format files. | |
123 | ||
124 | @item size | |
125 | List file section sizes and total size | |
126 | ||
127 | @item strings | |
128 | List printable strings from files | |
129 | ||
130 | @item strip | |
131 | Discard symbols | |
132 | ||
133 | @item c++filt | |
9d51cc66 ILT |
134 | Demangle encoded C++ symbols (on MS-DOS, this program is named |
135 | @code{cxxfilt}) | |
252b5132 RH |
136 | |
137 | @item addr2line | |
138 | Convert addresses into file names and line numbers | |
139 | ||
140 | @item nlmconv | |
141 | Convert object code into a Netware Loadable Module | |
142 | ||
143 | @item windres | |
144 | Manipulate Windows resources | |
145 | ||
146 | @item dlltool | |
147 | Create the files needed to build and use Dynamic Link Libraries | |
148 | @end table | |
149 | @end iftex | |
150 | ||
151 | @menu | |
152 | * ar:: Create, modify, and extract from archives | |
153 | * nm:: List symbols from object files | |
154 | * objcopy:: Copy and translate object files | |
155 | * objdump:: Display information from object files | |
156 | * ranlib:: Generate index to archive contents | |
157 | * readelf:: Display the contents of ELF format files. | |
158 | * size:: List section sizes and total size | |
159 | * strings:: List printable strings from files | |
160 | * strip:: Discard symbols | |
161 | * c++filt:: Filter to demangle encoded C++ symbols | |
9d51cc66 | 162 | * cxxfilt: c++filt. MS-DOS name for c++filt |
252b5132 RH |
163 | * addr2line:: Convert addresses to file and line |
164 | * nlmconv:: Converts object code into an NLM | |
165 | * windres:: Manipulate Windows resources | |
166 | * dlltool:: Create files needed to build and use DLLs | |
167 | * Selecting The Target System:: How these utilities determine the target. | |
168 | * Reporting Bugs:: Reporting Bugs | |
169 | * Index:: Index | |
170 | @end menu | |
171 | ||
172 | @node ar | |
173 | @chapter ar | |
174 | ||
175 | @kindex ar | |
176 | @cindex archives | |
177 | @cindex collections of files | |
178 | @smallexample | |
3de39064 | 179 | ar [-]@var{p}[@var{mod} [@var{relpos}] [@var{count}]] @var{archive} [@var{member}@dots{}] |
252b5132 RH |
180 | ar -M [ <mri-script ] |
181 | @end smallexample | |
182 | ||
183 | The @sc{gnu} @code{ar} program creates, modifies, and extracts from | |
184 | archives. An @dfn{archive} is a single file holding a collection of | |
185 | other files in a structure that makes it possible to retrieve | |
186 | the original individual files (called @dfn{members} of the archive). | |
187 | ||
188 | The original files' contents, mode (permissions), timestamp, owner, and | |
189 | group are preserved in the archive, and can be restored on | |
190 | extraction. | |
191 | ||
192 | @cindex name length | |
193 | @sc{gnu} @code{ar} can maintain archives whose members have names of any | |
194 | length; however, depending on how @code{ar} is configured on your | |
195 | system, a limit on member-name length may be imposed for compatibility | |
196 | with archive formats maintained with other tools. If it exists, the | |
197 | limit is often 15 characters (typical of formats related to a.out) or 16 | |
198 | characters (typical of formats related to coff). | |
199 | ||
200 | @cindex libraries | |
201 | @code{ar} is considered a binary utility because archives of this sort | |
202 | are most often used as @dfn{libraries} holding commonly needed | |
203 | subroutines. | |
204 | ||
205 | @cindex symbol index | |
206 | @code{ar} creates an index to the symbols defined in relocatable | |
207 | object modules in the archive when you specify the modifier @samp{s}. | |
208 | Once created, this index is updated in the archive whenever @code{ar} | |
209 | makes a change to its contents (save for the @samp{q} update operation). | |
210 | An archive with such an index speeds up linking to the library, and | |
211 | allows routines in the library to call each other without regard to | |
212 | their placement in the archive. | |
213 | ||
214 | You may use @samp{nm -s} or @samp{nm --print-armap} to list this index | |
215 | table. If an archive lacks the table, another form of @code{ar} called | |
216 | @code{ranlib} can be used to add just the table. | |
217 | ||
218 | @cindex compatibility, @code{ar} | |
219 | @cindex @code{ar} compatibility | |
220 | @sc{gnu} @code{ar} is designed to be compatible with two different | |
221 | facilities. You can control its activity using command-line options, | |
222 | like the different varieties of @code{ar} on Unix systems; or, if you | |
223 | specify the single command-line option @samp{-M}, you can control it | |
224 | with a script supplied via standard input, like the MRI ``librarian'' | |
225 | program. | |
226 | ||
227 | @menu | |
228 | * ar cmdline:: Controlling @code{ar} on the command line | |
229 | * ar scripts:: Controlling @code{ar} with a script | |
230 | @end menu | |
231 | ||
232 | @page | |
233 | @node ar cmdline | |
234 | @section Controlling @code{ar} on the command line | |
235 | ||
236 | @smallexample | |
6e800839 | 237 | ar [-X32_64] [-]@var{p}[@var{mod} [@var{relpos}] [@var{count}]] @var{archive} [@var{member}@dots{}] |
252b5132 RH |
238 | @end smallexample |
239 | ||
240 | @cindex Unix compatibility, @code{ar} | |
241 | When you use @code{ar} in the Unix style, @code{ar} insists on at least two | |
242 | arguments to execute: one keyletter specifying the @emph{operation} | |
243 | (optionally accompanied by other keyletters specifying | |
244 | @emph{modifiers}), and the archive name to act on. | |
245 | ||
246 | Most operations can also accept further @var{member} arguments, | |
247 | specifying particular files to operate on. | |
248 | ||
249 | @sc{gnu} @code{ar} allows you to mix the operation code @var{p} and modifier | |
250 | flags @var{mod} in any order, within the first command-line argument. | |
251 | ||
252 | If you wish, you may begin the first command-line argument with a | |
253 | dash. | |
254 | ||
255 | @cindex operations on archive | |
256 | The @var{p} keyletter specifies what operation to execute; it may be | |
257 | any of the following, but you must specify only one of them: | |
258 | ||
259 | @table @code | |
260 | @item d | |
261 | @cindex deleting from archive | |
262 | @emph{Delete} modules from the archive. Specify the names of modules to | |
263 | be deleted as @var{member}@dots{}; the archive is untouched if you | |
264 | specify no files to delete. | |
265 | ||
266 | If you specify the @samp{v} modifier, @code{ar} lists each module | |
267 | as it is deleted. | |
268 | ||
269 | @item m | |
270 | @cindex moving in archive | |
271 | Use this operation to @emph{move} members in an archive. | |
272 | ||
273 | The ordering of members in an archive can make a difference in how | |
274 | programs are linked using the library, if a symbol is defined in more | |
275 | than one member. | |
276 | ||
277 | If no modifiers are used with @code{m}, any members you name in the | |
278 | @var{member} arguments are moved to the @emph{end} of the archive; | |
279 | you can use the @samp{a}, @samp{b}, or @samp{i} modifiers to move them to a | |
280 | specified place instead. | |
281 | ||
282 | @item p | |
283 | @cindex printing from archive | |
284 | @emph{Print} the specified members of the archive, to the standard | |
285 | output file. If the @samp{v} modifier is specified, show the member | |
286 | name before copying its contents to standard output. | |
287 | ||
288 | If you specify no @var{member} arguments, all the files in the archive are | |
289 | printed. | |
290 | ||
291 | @item q | |
292 | @cindex quick append to archive | |
293 | @emph{Quick append}; Historically, add the files @var{member}@dots{} to the end of | |
294 | @var{archive}, without checking for replacement. | |
295 | ||
296 | The modifiers @samp{a}, @samp{b}, and @samp{i} do @emph{not} affect this | |
297 | operation; new members are always placed at the end of the archive. | |
298 | ||
299 | The modifier @samp{v} makes @code{ar} list each file as it is appended. | |
300 | ||
301 | Since the point of this operation is speed, the archive's symbol table | |
302 | index is not updated, even if it already existed; you can use @samp{ar s} or | |
303 | @code{ranlib} explicitly to update the symbol table index. | |
304 | ||
305 | However, too many different systems assume quick append rebuilds the | |
306 | index, so GNU ar implements @code{q} as a synonym for @code{r}. | |
307 | ||
308 | @item r | |
309 | @cindex replacement in archive | |
310 | Insert the files @var{member}@dots{} into @var{archive} (with | |
311 | @emph{replacement}). This operation differs from @samp{q} in that any | |
312 | previously existing members are deleted if their names match those being | |
313 | added. | |
314 | ||
315 | If one of the files named in @var{member}@dots{} does not exist, @code{ar} | |
316 | displays an error message, and leaves undisturbed any existing members | |
317 | of the archive matching that name. | |
318 | ||
319 | By default, new members are added at the end of the file; but you may | |
320 | use one of the modifiers @samp{a}, @samp{b}, or @samp{i} to request | |
321 | placement relative to some existing member. | |
322 | ||
323 | The modifier @samp{v} used with this operation elicits a line of | |
324 | output for each file inserted, along with one of the letters @samp{a} or | |
325 | @samp{r} to indicate whether the file was appended (no old member | |
326 | deleted) or replaced. | |
327 | ||
328 | @item t | |
329 | @cindex contents of archive | |
330 | Display a @emph{table} listing the contents of @var{archive}, or those | |
331 | of the files listed in @var{member}@dots{} that are present in the | |
332 | archive. Normally only the member name is shown; if you also want to | |
333 | see the modes (permissions), timestamp, owner, group, and size, you can | |
334 | request that by also specifying the @samp{v} modifier. | |
335 | ||
336 | If you do not specify a @var{member}, all files in the archive | |
337 | are listed. | |
338 | ||
339 | @cindex repeated names in archive | |
340 | @cindex name duplication in archive | |
341 | If there is more than one file with the same name (say, @samp{fie}) in | |
342 | an archive (say @samp{b.a}), @samp{ar t b.a fie} lists only the | |
343 | first instance; to see them all, you must ask for a complete | |
344 | listing---in our example, @samp{ar t b.a}. | |
345 | @c WRS only; per Gumby, this is implementation-dependent, and in a more | |
346 | @c recent case in fact works the other way. | |
347 | ||
348 | @item x | |
349 | @cindex extract from archive | |
350 | @emph{Extract} members (named @var{member}) from the archive. You can | |
351 | use the @samp{v} modifier with this operation, to request that | |
352 | @code{ar} list each name as it extracts it. | |
353 | ||
354 | If you do not specify a @var{member}, all files in the archive | |
355 | are extracted. | |
356 | ||
357 | @end table | |
358 | ||
359 | A number of modifiers (@var{mod}) may immediately follow the @var{p} | |
360 | keyletter, to specify variations on an operation's behavior: | |
361 | ||
362 | @table @code | |
363 | @item a | |
364 | @cindex relative placement in archive | |
365 | Add new files @emph{after} an existing member of the | |
366 | archive. If you use the modifier @samp{a}, the name of an existing archive | |
367 | member must be present as the @var{relpos} argument, before the | |
368 | @var{archive} specification. | |
369 | ||
370 | @item b | |
371 | Add new files @emph{before} an existing member of the | |
372 | archive. If you use the modifier @samp{b}, the name of an existing archive | |
373 | member must be present as the @var{relpos} argument, before the | |
374 | @var{archive} specification. (same as @samp{i}). | |
375 | ||
376 | @item c | |
377 | @cindex creating archives | |
378 | @emph{Create} the archive. The specified @var{archive} is always | |
379 | created if it did not exist, when you request an update. But a warning is | |
380 | issued unless you specify in advance that you expect to create it, by | |
381 | using this modifier. | |
382 | ||
383 | @item f | |
384 | Truncate names in the archive. @sc{gnu} @code{ar} will normally permit file | |
385 | names of any length. This will cause it to create archives which are | |
386 | not compatible with the native @code{ar} program on some systems. If | |
387 | this is a concern, the @samp{f} modifier may be used to truncate file | |
388 | names when putting them in the archive. | |
389 | ||
390 | @item i | |
391 | Insert new files @emph{before} an existing member of the | |
392 | archive. If you use the modifier @samp{i}, the name of an existing archive | |
393 | member must be present as the @var{relpos} argument, before the | |
394 | @var{archive} specification. (same as @samp{b}). | |
395 | ||
396 | @item l | |
397 | This modifier is accepted but not used. | |
398 | @c whaffor ar l modifier??? presumably compat; with | |
399 | @c what???---doc@@cygnus.com, 25jan91 | |
400 | ||
3de39064 ILT |
401 | @item N |
402 | Uses the @var{count} parameter. This is used if there are multiple | |
403 | entries in the archive with the same name. Extract or delete instance | |
404 | @var{count} of the given name from the archive. | |
405 | ||
252b5132 RH |
406 | @item o |
407 | @cindex dates in archive | |
408 | Preserve the @emph{original} dates of members when extracting them. If | |
409 | you do not specify this modifier, files extracted from the archive | |
410 | are stamped with the time of extraction. | |
411 | ||
3de39064 ILT |
412 | @item P |
413 | Use the full path name when matching names in the archive. @sc{gnu} | |
414 | @code{ar} can not create an archive with a full path name (such archives | |
415 | are not POSIX complaint), but other archive creators can. This option | |
416 | will cause @sc{gnu} @code{ar} to match file names using a complete path | |
417 | name, which can be convenient when extracting a single file from an | |
418 | archive created by another tool. | |
419 | ||
252b5132 RH |
420 | @item s |
421 | @cindex writing archive index | |
422 | Write an object-file index into the archive, or update an existing one, | |
423 | even if no other change is made to the archive. You may use this modifier | |
424 | flag either with any operation, or alone. Running @samp{ar s} on an | |
425 | archive is equivalent to running @samp{ranlib} on it. | |
426 | ||
427 | @item S | |
428 | @cindex not writing archive index | |
429 | Do not generate an archive symbol table. This can speed up building a | |
430 | large library in several steps. The resulting archive can not be used | |
431 | with the linker. In order to build a symbol table, you must omit the | |
432 | @samp{S} modifier on the last execution of @samp{ar}, or you must run | |
433 | @samp{ranlib} on the archive. | |
434 | ||
435 | @item u | |
436 | @cindex updating an archive | |
437 | Normally, @samp{ar r}@dots{} inserts all files | |
438 | listed into the archive. If you would like to insert @emph{only} those | |
439 | of the files you list that are newer than existing members of the same | |
440 | names, use this modifier. The @samp{u} modifier is allowed only for the | |
441 | operation @samp{r} (replace). In particular, the combination @samp{qu} is | |
442 | not allowed, since checking the timestamps would lose any speed | |
443 | advantage from the operation @samp{q}. | |
444 | ||
445 | @item v | |
446 | This modifier requests the @emph{verbose} version of an operation. Many | |
447 | operations display additional information, such as filenames processed, | |
448 | when the modifier @samp{v} is appended. | |
449 | ||
450 | @item V | |
451 | This modifier shows the version number of @code{ar}. | |
452 | @end table | |
453 | ||
6e800839 GK |
454 | @code{ar} ignores an initial option spelt @code{-X32_64}, for |
455 | compatibility with AIX. The behaviour produced by this option is the | |
456 | default for GNU @code{ar}. @code{ar} does not support any of the other | |
457 | @code{-X} options; in particular, it does not support @code{-X32} | |
458 | which is the default for AIX @code{ar}. | |
459 | ||
252b5132 RH |
460 | @node ar scripts |
461 | @section Controlling @code{ar} with a script | |
462 | ||
463 | @smallexample | |
464 | ar -M [ <@var{script} ] | |
465 | @end smallexample | |
466 | ||
467 | @cindex MRI compatibility, @code{ar} | |
468 | @cindex scripts, @code{ar} | |
469 | If you use the single command-line option @samp{-M} with @code{ar}, you | |
470 | can control its operation with a rudimentary command language. This | |
471 | form of @code{ar} operates interactively if standard input is coming | |
472 | directly from a terminal. During interactive use, @code{ar} prompts for | |
473 | input (the prompt is @samp{AR >}), and continues executing even after | |
474 | errors. If you redirect standard input to a script file, no prompts are | |
475 | issued, and @code{ar} abandons execution (with a nonzero exit code) | |
476 | on any error. | |
477 | ||
478 | The @code{ar} command language is @emph{not} designed to be equivalent | |
479 | to the command-line options; in fact, it provides somewhat less control | |
480 | over archives. The only purpose of the command language is to ease the | |
481 | transition to @sc{gnu} @code{ar} for developers who already have scripts | |
482 | written for the MRI ``librarian'' program. | |
483 | ||
484 | The syntax for the @code{ar} command language is straightforward: | |
485 | @itemize @bullet | |
486 | @item | |
487 | commands are recognized in upper or lower case; for example, @code{LIST} | |
488 | is the same as @code{list}. In the following descriptions, commands are | |
489 | shown in upper case for clarity. | |
490 | ||
491 | @item | |
492 | a single command may appear on each line; it is the first word on the | |
493 | line. | |
494 | ||
495 | @item | |
496 | empty lines are allowed, and have no effect. | |
497 | ||
498 | @item | |
499 | comments are allowed; text after either of the characters @samp{*} | |
500 | or @samp{;} is ignored. | |
501 | ||
502 | @item | |
503 | Whenever you use a list of names as part of the argument to an @code{ar} | |
504 | command, you can separate the individual names with either commas or | |
505 | blanks. Commas are shown in the explanations below, for clarity. | |
506 | ||
507 | @item | |
508 | @samp{+} is used as a line continuation character; if @samp{+} appears | |
509 | at the end of a line, the text on the following line is considered part | |
510 | of the current command. | |
511 | @end itemize | |
512 | ||
513 | Here are the commands you can use in @code{ar} scripts, or when using | |
514 | @code{ar} interactively. Three of them have special significance: | |
515 | ||
516 | @code{OPEN} or @code{CREATE} specify a @dfn{current archive}, which is | |
517 | a temporary file required for most of the other commands. | |
518 | ||
519 | @code{SAVE} commits the changes so far specified by the script. Prior | |
520 | to @code{SAVE}, commands affect only the temporary copy of the current | |
521 | archive. | |
522 | ||
523 | @table @code | |
524 | @item ADDLIB @var{archive} | |
525 | @itemx ADDLIB @var{archive} (@var{module}, @var{module}, @dots{} @var{module}) | |
526 | Add all the contents of @var{archive} (or, if specified, each named | |
527 | @var{module} from @var{archive}) to the current archive. | |
528 | ||
529 | Requires prior use of @code{OPEN} or @code{CREATE}. | |
530 | ||
531 | @item ADDMOD @var{member}, @var{member}, @dots{} @var{member} | |
532 | @c FIXME! w/Replacement?? If so, like "ar r @var{archive} @var{names}" | |
533 | @c else like "ar q..." | |
534 | Add each named @var{member} as a module in the current archive. | |
535 | ||
536 | Requires prior use of @code{OPEN} or @code{CREATE}. | |
537 | ||
538 | @item CLEAR | |
539 | Discard the contents of the current archive, canceling the effect of | |
540 | any operations since the last @code{SAVE}. May be executed (with no | |
541 | effect) even if no current archive is specified. | |
542 | ||
543 | @item CREATE @var{archive} | |
544 | Creates an archive, and makes it the current archive (required for many | |
545 | other commands). The new archive is created with a temporary name; it | |
546 | is not actually saved as @var{archive} until you use @code{SAVE}. | |
547 | You can overwrite existing archives; similarly, the contents of any | |
548 | existing file named @var{archive} will not be destroyed until @code{SAVE}. | |
549 | ||
550 | @item DELETE @var{module}, @var{module}, @dots{} @var{module} | |
551 | Delete each listed @var{module} from the current archive; equivalent to | |
552 | @samp{ar -d @var{archive} @var{module} @dots{} @var{module}}. | |
553 | ||
554 | Requires prior use of @code{OPEN} or @code{CREATE}. | |
555 | ||
556 | @item DIRECTORY @var{archive} (@var{module}, @dots{} @var{module}) | |
557 | @itemx DIRECTORY @var{archive} (@var{module}, @dots{} @var{module}) @var{outputfile} | |
558 | List each named @var{module} present in @var{archive}. The separate | |
559 | command @code{VERBOSE} specifies the form of the output: when verbose | |
560 | output is off, output is like that of @samp{ar -t @var{archive} | |
561 | @var{module}@dots{}}. When verbose output is on, the listing is like | |
562 | @samp{ar -tv @var{archive} @var{module}@dots{}}. | |
563 | ||
564 | Output normally goes to the standard output stream; however, if you | |
565 | specify @var{outputfile} as a final argument, @code{ar} directs the | |
566 | output to that file. | |
567 | ||
568 | @item END | |
569 | Exit from @code{ar}, with a @code{0} exit code to indicate successful | |
570 | completion. This command does not save the output file; if you have | |
571 | changed the current archive since the last @code{SAVE} command, those | |
572 | changes are lost. | |
573 | ||
574 | @item EXTRACT @var{module}, @var{module}, @dots{} @var{module} | |
575 | Extract each named @var{module} from the current archive, writing them | |
576 | into the current directory as separate files. Equivalent to @samp{ar -x | |
577 | @var{archive} @var{module}@dots{}}. | |
578 | ||
579 | Requires prior use of @code{OPEN} or @code{CREATE}. | |
580 | ||
581 | @ignore | |
582 | @c FIXME Tokens but no commands??? | |
583 | @item FULLDIR | |
584 | ||
585 | @item HELP | |
586 | @end ignore | |
587 | ||
588 | @item LIST | |
589 | Display full contents of the current archive, in ``verbose'' style | |
590 | regardless of the state of @code{VERBOSE}. The effect is like @samp{ar | |
c89746f6 | 591 | tv @var{archive}}. (This single command is a @sc{gnu} @code{ar} |
252b5132 RH |
592 | enhancement, rather than present for MRI compatibility.) |
593 | ||
594 | Requires prior use of @code{OPEN} or @code{CREATE}. | |
595 | ||
596 | @item OPEN @var{archive} | |
597 | Opens an existing archive for use as the current archive (required for | |
598 | many other commands). Any changes as the result of subsequent commands | |
599 | will not actually affect @var{archive} until you next use @code{SAVE}. | |
600 | ||
601 | @item REPLACE @var{module}, @var{module}, @dots{} @var{module} | |
602 | In the current archive, replace each existing @var{module} (named in | |
603 | the @code{REPLACE} arguments) from files in the current working directory. | |
604 | To execute this command without errors, both the file, and the module in | |
605 | the current archive, must exist. | |
606 | ||
607 | Requires prior use of @code{OPEN} or @code{CREATE}. | |
608 | ||
609 | @item VERBOSE | |
610 | Toggle an internal flag governing the output from @code{DIRECTORY}. | |
611 | When the flag is on, @code{DIRECTORY} output matches output from | |
612 | @samp{ar -tv }@dots{}. | |
613 | ||
614 | @item SAVE | |
615 | Commit your changes to the current archive, and actually save it as a | |
616 | file with the name specified in the last @code{CREATE} or @code{OPEN} | |
617 | command. | |
618 | ||
619 | Requires prior use of @code{OPEN} or @code{CREATE}. | |
620 | ||
621 | @end table | |
622 | ||
623 | @iftex | |
624 | @node ld | |
625 | @chapter ld | |
626 | @cindex linker | |
627 | @kindex ld | |
628 | The @sc{gnu} linker @code{ld} is now described in a separate manual. | |
629 | @xref{Top,, Overview,, Using LD: the @sc{gnu} linker}. | |
630 | @end iftex | |
631 | ||
632 | @node nm | |
633 | @chapter nm | |
634 | @cindex symbols | |
635 | @kindex nm | |
636 | ||
637 | @smallexample | |
638 | nm [ -a | --debug-syms ] [ -g | --extern-only ] | |
28c309a2 | 639 | [ -B ] [ -C | --demangle[=@var{style}] ] [ -D | --dynamic ] |
252b5132 RH |
640 | [ -s | --print-armap ] [ -A | -o | --print-file-name ] |
641 | [ -n | -v | --numeric-sort ] [ -p | --no-sort ] | |
642 | [ -r | --reverse-sort ] [ --size-sort ] [ -u | --undefined-only ] | |
643 | [ -t @var{radix} | --radix=@var{radix} ] [ -P | --portability ] | |
644 | [ --target=@var{bfdname} ] [ -f @var{format} | --format=@var{format} ] | |
6e800839 GK |
645 | [ --defined-only ] [-l | --line-numbers ] [ --no-demangle ] |
646 | [ -V | --version ] [ -X 32_64 ] [ --help ] [ @var{objfile}@dots{} ] | |
252b5132 RH |
647 | @end smallexample |
648 | ||
649 | @sc{gnu} @code{nm} lists the symbols from object files @var{objfile}@dots{}. | |
f20a759a | 650 | If no object files are listed as arguments, @code{nm} assumes the file |
252b5132 RH |
651 | @file{a.out}. |
652 | ||
653 | For each symbol, @code{nm} shows: | |
654 | ||
655 | @itemize @bullet | |
656 | @item | |
657 | The symbol value, in the radix selected by options (see below), or | |
658 | hexadecimal by default. | |
659 | ||
660 | @item | |
661 | The symbol type. At least the following types are used; others are, as | |
662 | well, depending on the object file format. If lowercase, the symbol is | |
663 | local; if uppercase, the symbol is global (external). | |
664 | ||
665 | @c Some more detail on exactly what these symbol types are used for | |
666 | @c would be nice. | |
667 | @table @code | |
668 | @item A | |
669 | The symbol's value is absolute, and will not be changed by further | |
670 | linking. | |
671 | ||
672 | @item B | |
673 | The symbol is in the uninitialized data section (known as BSS). | |
674 | ||
675 | @item C | |
676 | The symbol is common. Common symbols are uninitialized data. When | |
677 | linking, multiple common symbols may appear with the same name. If the | |
678 | symbol is defined anywhere, the common symbols are treated as undefined | |
679 | references. For more details on common symbols, see the discussion of | |
680 | --warn-common in @ref{Options,,Linker options,ld.info,The GNU linker}. | |
681 | ||
682 | @item D | |
683 | The symbol is in the initialized data section. | |
684 | ||
685 | @item G | |
686 | The symbol is in an initialized data section for small objects. Some | |
687 | object file formats permit more efficient access to small data objects, | |
688 | such as a global int variable as opposed to a large global array. | |
689 | ||
690 | @item I | |
691 | The symbol is an indirect reference to another symbol. This is a GNU | |
692 | extension to the a.out object file format which is rarely used. | |
693 | ||
694 | @item N | |
695 | The symbol is a debugging symbol. | |
696 | ||
697 | @item R | |
698 | The symbol is in a read only data section. | |
699 | ||
700 | @item S | |
701 | The symbol is in an uninitialized data section for small objects. | |
702 | ||
703 | @item T | |
704 | The symbol is in the text (code) section. | |
705 | ||
706 | @item U | |
707 | The symbol is undefined. | |
708 | ||
fad6fcbb NC |
709 | @item V |
710 | The symbol is a weak object. When a weak defined symbol is linked with | |
711 | a normal defined symbol, the normal defined symbol is used with no error. | |
712 | When a weak undefined symbol is linked and the symbol is not defined, | |
713 | the value of the weak symbol becomes zero with no error. | |
714 | ||
252b5132 | 715 | @item W |
fad6fcbb NC |
716 | The symbol is a weak symbol that has not been specifically tagged as a |
717 | weak object symbol. When a weak defined symbol is linked with a normal | |
718 | defined symbol, the normal defined symbol is used with no error. | |
719 | When a weak undefined symbol is linked and the symbol is not defined, | |
720 | the value of the weak symbol becomes zero with no error. | |
252b5132 RH |
721 | |
722 | @item - | |
723 | The symbol is a stabs symbol in an a.out object file. In this case, the | |
724 | next values printed are the stabs other field, the stabs desc field, and | |
725 | the stab type. Stabs symbols are used to hold debugging information; | |
726 | for more information, see @ref{Top,Stabs,Stabs Overview,stabs.info, The | |
727 | ``stabs'' debug format}. | |
728 | ||
729 | @item ? | |
730 | The symbol type is unknown, or object file format specific. | |
731 | @end table | |
732 | ||
733 | @item | |
734 | The symbol name. | |
735 | @end itemize | |
736 | ||
737 | The long and short forms of options, shown here as alternatives, are | |
738 | equivalent. | |
739 | ||
740 | @table @code | |
741 | @item -A | |
742 | @itemx -o | |
743 | @itemx --print-file-name | |
744 | @cindex input file name | |
745 | @cindex file name | |
746 | @cindex source file name | |
f20a759a | 747 | Precede each symbol by the name of the input file (or archive member) |
252b5132 RH |
748 | in which it was found, rather than identifying the input file once only, |
749 | before all of its symbols. | |
750 | ||
751 | @item -a | |
752 | @itemx --debug-syms | |
753 | @cindex debugging symbols | |
754 | Display all symbols, even debugger-only symbols; normally these are not | |
755 | listed. | |
756 | ||
757 | @item -B | |
758 | @cindex @code{nm} format | |
759 | @cindex @code{nm} compatibility | |
760 | The same as @samp{--format=bsd} (for compatibility with the MIPS @code{nm}). | |
761 | ||
762 | @item -C | |
28c309a2 | 763 | @itemx --demangle[=@var{style}] |
252b5132 RH |
764 | @cindex demangling in nm |
765 | Decode (@dfn{demangle}) low-level symbol names into user-level names. | |
766 | Besides removing any initial underscore prepended by the system, this | |
28c309a2 NC |
767 | makes C++ function names readable. Different compilers have different |
768 | mangling styles. The optional demangling style argument can be used to | |
769 | choose an appropriate demangling style for your compiler. @xref{c++filt}, | |
770 | for more information on demangling. | |
252b5132 RH |
771 | |
772 | @item --no-demangle | |
773 | Do not demangle low-level symbol names. This is the default. | |
774 | ||
775 | @item -D | |
776 | @itemx --dynamic | |
777 | @cindex dynamic symbols | |
778 | Display the dynamic symbols rather than the normal symbols. This is | |
779 | only meaningful for dynamic objects, such as certain types of shared | |
780 | libraries. | |
781 | ||
782 | @item -f @var{format} | |
783 | @itemx --format=@var{format} | |
784 | @cindex @code{nm} format | |
785 | @cindex @code{nm} compatibility | |
786 | Use the output format @var{format}, which can be @code{bsd}, | |
787 | @code{sysv}, or @code{posix}. The default is @code{bsd}. | |
788 | Only the first character of @var{format} is significant; it can be | |
789 | either upper or lower case. | |
790 | ||
791 | @item -g | |
792 | @itemx --extern-only | |
793 | @cindex external symbols | |
794 | Display only external symbols. | |
795 | ||
796 | @item -l | |
797 | @itemx --line-numbers | |
798 | @cindex symbol line numbers | |
799 | For each symbol, use debugging information to try to find a filename and | |
800 | line number. For a defined symbol, look for the line number of the | |
801 | address of the symbol. For an undefined symbol, look for the line | |
802 | number of a relocation entry which refers to the symbol. If line number | |
803 | information can be found, print it after the other symbol information. | |
804 | ||
805 | @item -n | |
806 | @itemx -v | |
807 | @itemx --numeric-sort | |
808 | Sort symbols numerically by their addresses, rather than alphabetically | |
809 | by their names. | |
810 | ||
811 | @item -p | |
812 | @itemx --no-sort | |
813 | @cindex sorting symbols | |
814 | Do not bother to sort the symbols in any order; print them in the order | |
815 | encountered. | |
816 | ||
817 | @item -P | |
818 | @itemx --portability | |
819 | Use the POSIX.2 standard output format instead of the default format. | |
820 | Equivalent to @samp{-f posix}. | |
821 | ||
822 | @item -s | |
823 | @itemx --print-armap | |
824 | @cindex symbol index, listing | |
825 | When listing symbols from archive members, include the index: a mapping | |
826 | (stored in the archive by @code{ar} or @code{ranlib}) of which modules | |
827 | contain definitions for which names. | |
828 | ||
829 | @item -r | |
830 | @itemx --reverse-sort | |
831 | Reverse the order of the sort (whether numeric or alphabetic); let the | |
832 | last come first. | |
833 | ||
834 | @item --size-sort | |
835 | Sort symbols by size. The size is computed as the difference between | |
836 | the value of the symbol and the value of the symbol with the next higher | |
837 | value. The size of the symbol is printed, rather than the value. | |
838 | ||
839 | @item -t @var{radix} | |
840 | @itemx --radix=@var{radix} | |
841 | Use @var{radix} as the radix for printing the symbol values. It must be | |
842 | @samp{d} for decimal, @samp{o} for octal, or @samp{x} for hexadecimal. | |
843 | ||
844 | @item --target=@var{bfdname} | |
845 | @cindex object code format | |
846 | Specify an object code format other than your system's default format. | |
847 | @xref{Target Selection}, for more information. | |
848 | ||
849 | @item -u | |
850 | @itemx --undefined-only | |
851 | @cindex external symbols | |
852 | @cindex undefined symbols | |
853 | Display only undefined symbols (those external to each object file). | |
854 | ||
855 | @item --defined-only | |
856 | @cindex external symbols | |
857 | @cindex undefined symbols | |
858 | Display only defined symbols for each object file. | |
859 | ||
860 | @item -V | |
861 | @itemx --version | |
862 | Show the version number of @code{nm} and exit. | |
863 | ||
6e800839 GK |
864 | @item -X |
865 | This option is ignored for compatibility with the AIX version of | |
866 | @code{nm}. It takes one parameter which must be the string | |
867 | @code{32_64}. The default mode of AIX @code{nm} corresponds | |
868 | to @code{-X 32}, which is not supported by @sc{gnu} @code{nm}. | |
869 | ||
252b5132 RH |
870 | @item --help |
871 | Show a summary of the options to @code{nm} and exit. | |
872 | @end table | |
873 | ||
874 | @node objcopy | |
875 | @chapter objcopy | |
876 | ||
877 | @smallexample | |
878 | objcopy [ -F @var{bfdname} | --target=@var{bfdname} ] | |
879 | [ -I @var{bfdname} | --input-target=@var{bfdname} ] | |
880 | [ -O @var{bfdname} | --output-target=@var{bfdname} ] | |
881 | [ -S | --strip-all ] [ -g | --strip-debug ] | |
882 | [ -K @var{symbolname} | --keep-symbol=@var{symbolname} ] | |
883 | [ -N @var{symbolname} | --strip-symbol=@var{symbolname} ] | |
884 | [ -L @var{symbolname} | --localize-symbol=@var{symbolname} ] | |
885 | [ -W @var{symbolname} | --weaken-symbol=@var{symbolname} ] | |
886 | [ -x | --discard-all ] [ -X | --discard-locals ] | |
887 | [ -b @var{byte} | --byte=@var{byte} ] | |
888 | [ -i @var{interleave} | --interleave=@var{interleave} ] | |
f91ea849 | 889 | [ -j @var{sectionname} | --only-section=@var{sectionname} ] |
252b5132 RH |
890 | [ -R @var{sectionname} | --remove-section=@var{sectionname} ] |
891 | [ -p | --preserve-dates ] [ --debugging ] | |
892 | [ --gap-fill=@var{val} ] [ --pad-to=@var{address} ] | |
893 | [ --set-start=@var{val} ] [ --adjust-start=@var{incr} ] | |
894 | [ --change-addresses=@var{incr} ] | |
57938635 AM |
895 | [ --change-section-address @var{section}@{=,+,-@}@var{val} ] |
896 | [ --change-section-lma @var{section}@{=,+,-@}@var{val} ] | |
897 | [ --change-section-vma @var{section}@{=,+,-@}@var{val} ] | |
252b5132 | 898 | [ --change-warnings ] [ --no-change-warnings ] |
57938635 AM |
899 | [ --set-section-flags @var{section}=@var{flags} ] |
900 | [ --add-section @var{sectionname}=@var{filename} ] | |
252b5132 | 901 | [ --change-leading-char ] [ --remove-leading-char ] |
57938635 | 902 | [ --redefine-sym @var{old}=@var{new} ] [ --weaken ] |
252b5132 RH |
903 | [ -v | --verbose ] [ -V | --version ] [ --help ] |
904 | @var{infile} [@var{outfile}] | |
905 | @end smallexample | |
906 | ||
907 | The @sc{gnu} @code{objcopy} utility copies the contents of an object | |
908 | file to another. @code{objcopy} uses the @sc{gnu} @sc{bfd} Library to | |
909 | read and write the object files. It can write the destination object | |
910 | file in a format different from that of the source object file. The | |
911 | exact behavior of @code{objcopy} is controlled by command-line options. | |
ccd13d18 L |
912 | Note that @code{objcopy} should be able to copy a fully linked file |
913 | between any two formats. However, copying a relocatable object file | |
914 | between any two formats may not work as expected. | |
252b5132 RH |
915 | |
916 | @code{objcopy} creates temporary files to do its translations and | |
917 | deletes them afterward. @code{objcopy} uses @sc{bfd} to do all its | |
918 | translation work; it has access to all the formats described in @sc{bfd} | |
919 | and thus is able to recognize most formats without being told | |
920 | explicitly. @xref{BFD,,BFD,ld.info,Using LD}. | |
921 | ||
922 | @code{objcopy} can be used to generate S-records by using an output | |
923 | target of @samp{srec} (e.g., use @samp{-O srec}). | |
924 | ||
925 | @code{objcopy} can be used to generate a raw binary file by using an | |
926 | output target of @samp{binary} (e.g., use @samp{-O binary}). When | |
927 | @code{objcopy} generates a raw binary file, it will essentially produce | |
928 | a memory dump of the contents of the input object file. All symbols and | |
929 | relocation information will be discarded. The memory dump will start at | |
930 | the load address of the lowest section copied into the output file. | |
931 | ||
932 | When generating an S-record or a raw binary file, it may be helpful to | |
933 | use @samp{-S} to remove sections containing debugging information. In | |
934 | some cases @samp{-R} will be useful to remove sections which contain | |
f20a759a | 935 | information that is not needed by the binary file. |
252b5132 RH |
936 | |
937 | @table @code | |
938 | @item @var{infile} | |
939 | @itemx @var{outfile} | |
f20a759a | 940 | The input and output files, respectively. |
252b5132 RH |
941 | If you do not specify @var{outfile}, @code{objcopy} creates a |
942 | temporary file and destructively renames the result with | |
943 | the name of @var{infile}. | |
944 | ||
945 | @item -I @var{bfdname} | |
946 | @itemx --input-target=@var{bfdname} | |
947 | Consider the source file's object format to be @var{bfdname}, rather than | |
948 | attempting to deduce it. @xref{Target Selection}, for more information. | |
949 | ||
950 | @item -O @var{bfdname} | |
951 | @itemx --output-target=@var{bfdname} | |
952 | Write the output file using the object format @var{bfdname}. | |
953 | @xref{Target Selection}, for more information. | |
954 | ||
955 | @item -F @var{bfdname} | |
956 | @itemx --target=@var{bfdname} | |
957 | Use @var{bfdname} as the object format for both the input and the output | |
958 | file; i.e., simply transfer data from source to destination with no | |
959 | translation. @xref{Target Selection}, for more information. | |
960 | ||
f91ea849 ILT |
961 | @item -j @var{sectionname} |
962 | @itemx --only-section=@var{sectionname} | |
963 | Copy only the named section from the input file to the output file. | |
964 | This option may be given more than once. Note that using this option | |
965 | inappropriately may make the output file unusable. | |
966 | ||
252b5132 RH |
967 | @item -R @var{sectionname} |
968 | @itemx --remove-section=@var{sectionname} | |
969 | Remove any section named @var{sectionname} from the output file. This | |
970 | option may be given more than once. Note that using this option | |
971 | inappropriately may make the output file unusable. | |
972 | ||
973 | @item -S | |
974 | @itemx --strip-all | |
975 | Do not copy relocation and symbol information from the source file. | |
976 | ||
977 | @item -g | |
978 | @itemx --strip-debug | |
979 | Do not copy debugging symbols from the source file. | |
980 | ||
981 | @item --strip-unneeded | |
982 | Strip all symbols that are not needed for relocation processing. | |
983 | ||
984 | @item -K @var{symbolname} | |
985 | @itemx --keep-symbol=@var{symbolname} | |
986 | Copy only symbol @var{symbolname} from the source file. This option may | |
987 | be given more than once. | |
988 | ||
989 | @item -N @var{symbolname} | |
990 | @itemx --strip-symbol=@var{symbolname} | |
991 | Do not copy symbol @var{symbolname} from the source file. This option | |
992 | may be given more than once. | |
993 | ||
994 | @item -L @var{symbolname} | |
995 | @itemx --localize-symbol=@var{symbolname} | |
996 | Make symbol @var{symbolname} local to the file, so that it is not | |
997 | visible externally. This option may be given more than once. | |
998 | ||
999 | @item -W @var{symbolname} | |
1000 | @itemx --weaken-symbol=@var{symbolname} | |
1001 | Make symbol @var{symbolname} weak. This option may be given more than once. | |
1002 | ||
1003 | @item -x | |
1004 | @itemx --discard-all | |
1005 | Do not copy non-global symbols from the source file. | |
1006 | @c FIXME any reason to prefer "non-global" to "local" here? | |
1007 | ||
1008 | @item -X | |
1009 | @itemx --discard-locals | |
1010 | Do not copy compiler-generated local symbols. | |
1011 | (These usually start with @samp{L} or @samp{.}.) | |
1012 | ||
1013 | @item -b @var{byte} | |
1014 | @itemx --byte=@var{byte} | |
1015 | Keep only every @var{byte}th byte of the input file (header data is not | |
1016 | affected). @var{byte} can be in the range from 0 to @var{interleave}-1, | |
1017 | where @var{interleave} is given by the @samp{-i} or @samp{--interleave} | |
1018 | option, or the default of 4. This option is useful for creating files | |
1019 | to program @sc{rom}. It is typically used with an @code{srec} output | |
1020 | target. | |
1021 | ||
1022 | @item -i @var{interleave} | |
1023 | @itemx --interleave=@var{interleave} | |
1024 | Only copy one out of every @var{interleave} bytes. Select which byte to | |
1025 | copy with the @var{-b} or @samp{--byte} option. The default is 4. | |
1026 | @code{objcopy} ignores this option if you do not specify either @samp{-b} or | |
1027 | @samp{--byte}. | |
1028 | ||
1029 | @item -p | |
1030 | @itemx --preserve-dates | |
1031 | Set the access and modification dates of the output file to be the same | |
1032 | as those of the input file. | |
1033 | ||
1034 | @item --debugging | |
1035 | Convert debugging information, if possible. This is not the default | |
1036 | because only certain debugging formats are supported, and the | |
1037 | conversion process can be time consuming. | |
1038 | ||
1039 | @item --gap-fill @var{val} | |
1040 | Fill gaps between sections with @var{val}. This operation applies to | |
1041 | the @emph{load address} (LMA) of the sections. It is done by increasing | |
1042 | the size of the section with the lower address, and filling in the extra | |
1043 | space created with @var{val}. | |
1044 | ||
1045 | @item --pad-to @var{address} | |
1046 | Pad the output file up to the load address @var{address}. This is | |
1047 | done by increasing the size of the last section. The extra space is | |
1048 | filled in with the value specified by @samp{--gap-fill} (default zero). | |
1049 | ||
1050 | @item --set-start @var{val} | |
f20a759a | 1051 | Set the start address of the new file to @var{val}. Not all object file |
252b5132 RH |
1052 | formats support setting the start address. |
1053 | ||
1054 | @item --change-start @var{incr} | |
1055 | @itemx --adjust-start @var{incr} | |
1056 | @cindex changing start address | |
1057 | Change the start address by adding @var{incr}. Not all object file | |
1058 | formats support setting the start address. | |
1059 | ||
1060 | @item --change-addresses @var{incr} | |
1061 | @itemx --adjust-vma @var{incr} | |
1062 | @cindex changing object addresses | |
1063 | Change the VMA and LMA addresses of all sections, as well as the start | |
1064 | address, by adding @var{incr}. Some object file formats do not permit | |
1065 | section addresses to be changed arbitrarily. Note that this does not | |
1066 | relocate the sections; if the program expects sections to be loaded at a | |
1067 | certain address, and this option is used to change the sections such | |
1068 | that they are loaded at a different address, the program may fail. | |
1069 | ||
1070 | @item --change-section-address @var{section}@{=,+,-@}@var{val} | |
1071 | @itemx --adjust-section-vma @var{section}@{=,+,-@}@var{val} | |
1072 | @cindex changing section address | |
1073 | Set or change both the VMA address and the LMA address of the named | |
1074 | @var{section}. If @samp{=} is used, the section address is set to | |
1075 | @var{val}. Otherwise, @var{val} is added to or subtracted from the | |
1076 | section address. See the comments under @samp{--change-addresses}, | |
1077 | above. If @var{section} does not exist in the input file, a warning will | |
1078 | be issued, unless @samp{--no-change-warnings} is used. | |
1079 | ||
1080 | @item --change-section-lma @var{section}@{=,+,-@}@var{val} | |
1081 | @cindex changing section LMA | |
1082 | Set or change the LMA address of the named @var{section}. The LMA | |
1083 | address is the address where the section will be loaded into memory at | |
1084 | program load time. Normally this is the same as the VMA address, which | |
1085 | is the address of the section at program run time, but on some systems, | |
1086 | especially those where a program is held in ROM, the two can be | |
1087 | different. If @samp{=} is used, the section address is set to | |
1088 | @var{val}. Otherwise, @var{val} is added to or subtracted from the | |
1089 | section address. See the comments under @samp{--change-addresses}, | |
1090 | above. If @var{section} does not exist in the input file, a warning | |
1091 | will be issued, unless @samp{--no-change-warnings} is used. | |
1092 | ||
1093 | @item --change-section-vma @var{section}@{=,+,-@}@var{val} | |
1094 | @cindex changing section VMA | |
1095 | Set or change the VMA address of the named @var{section}. The VMA | |
1096 | address is the address where the section will be located once the | |
1097 | program has started executing. Normally this is the same as the LMA | |
1098 | address, which is the address where the section will be loaded into | |
1099 | memory, but on some systems, especially those where a program is held in | |
1100 | ROM, the two can be different. If @samp{=} is used, the section address | |
1101 | is set to @var{val}. Otherwise, @var{val} is added to or subtracted | |
1102 | from the section address. See the comments under | |
1103 | @samp{--change-addresses}, above. If @var{section} does not exist in | |
1104 | the input file, a warning will be issued, unless | |
1105 | @samp{--no-change-warnings} is used. | |
1106 | ||
1107 | @item --change-warnings | |
1108 | @itemx --adjust-warnings | |
1109 | If @samp{--change-section-address} or @samp{--change-section-lma} or | |
1110 | @samp{--change-section-vma} is used, and the named section does not | |
1111 | exist, issue a warning. This is the default. | |
1112 | ||
1113 | @item --no-change-warnings | |
1114 | @itemx --no-adjust-warnings | |
1115 | Do not issue a warning if @samp{--change-section-address} or | |
1116 | @samp{--adjust-section-lma} or @samp{--adjust-section-vma} is used, even | |
1117 | if the named section does not exist. | |
1118 | ||
1119 | @item --set-section-flags @var{section}=@var{flags} | |
1120 | Set the flags for the named section. The @var{flags} argument is a | |
1121 | comma separated string of flag names. The recognized names are | |
3994e2c6 ILT |
1122 | @samp{alloc}, @samp{contents}, @samp{load}, @samp{noload}, |
1123 | @samp{readonly}, @samp{code}, @samp{data}, @samp{rom}, @samp{share}, and | |
1124 | @samp{debug}. You can set the @samp{contents} flag for a section which | |
1125 | does not have contents, but it is not meaningful to clear the | |
1126 | @samp{contents} flag of a section which does have contents--just remove | |
1127 | the section instead. Not all flags are meaningful for all object file | |
1128 | formats. | |
252b5132 RH |
1129 | |
1130 | @item --add-section @var{sectionname}=@var{filename} | |
1131 | Add a new section named @var{sectionname} while copying the file. The | |
1132 | contents of the new section are taken from the file @var{filename}. The | |
1133 | size of the section will be the size of the file. This option only | |
1134 | works on file formats which can support sections with arbitrary names. | |
1135 | ||
1136 | @item --change-leading-char | |
1137 | Some object file formats use special characters at the start of | |
1138 | symbols. The most common such character is underscore, which compilers | |
1139 | often add before every symbol. This option tells @code{objcopy} to | |
1140 | change the leading character of every symbol when it converts between | |
1141 | object file formats. If the object file formats use the same leading | |
1142 | character, this option has no effect. Otherwise, it will add a | |
1143 | character, or remove a character, or change a character, as | |
1144 | appropriate. | |
1145 | ||
1146 | @item --remove-leading-char | |
1147 | If the first character of a global symbol is a special symbol leading | |
1148 | character used by the object file format, remove the character. The | |
1149 | most common symbol leading character is underscore. This option will | |
1150 | remove a leading underscore from all global symbols. This can be useful | |
1151 | if you want to link together objects of different file formats with | |
1152 | different conventions for symbol names. This is different from | |
1153 | @code{--change-leading-char} because it always changes the symbol name | |
1154 | when appropriate, regardless of the object file format of the output | |
1155 | file. | |
1156 | ||
57938635 AM |
1157 | @item --redefine-sym @var{old}=@var{new} |
1158 | Change the name of a symbol @var{old}, to @var{new}. This can be useful | |
1159 | when one is trying link two things together for which you have no | |
1160 | source, and there are name collisions. | |
1161 | ||
252b5132 RH |
1162 | @item --weaken |
1163 | Change all global symbols in the file to be weak. This can be useful | |
1164 | when building an object which will be linked against other objects using | |
1165 | the @code{-R} option to the linker. This option is only effective when | |
1166 | using an object file format which supports weak symbols. | |
1167 | ||
1168 | @item -V | |
1169 | @itemx --version | |
1170 | Show the version number of @code{objcopy}. | |
1171 | ||
1172 | @item -v | |
1173 | @itemx --verbose | |
1174 | Verbose output: list all object files modified. In the case of | |
1175 | archives, @samp{objcopy -V} lists all members of the archive. | |
1176 | ||
1177 | @item --help | |
1178 | Show a summary of the options to @code{objcopy}. | |
1179 | @end table | |
1180 | ||
1181 | @node objdump | |
1182 | @chapter objdump | |
1183 | ||
1184 | @cindex object file information | |
1185 | @kindex objdump | |
1186 | ||
1187 | @smallexample | |
1188 | objdump [ -a | --archive-headers ] | |
1dada9c5 | 1189 | [ -b @var{bfdname} | --target=@var{bfdname} ] |
28c309a2 | 1190 | [ -C | --demangle[=@var{style}] ] |
1dada9c5 NC |
1191 | [ -d | --disassemble ] |
1192 | [ -D | --disassemble-all ] | |
1193 | [ -z | --disassemble-zeroes ] | |
252b5132 RH |
1194 | [ -EB | -EL | --endian=@{big | little @} ] |
1195 | [ -f | --file-headers ] | |
f1563258 | 1196 | [ --file-start-context ] |
1dada9c5 NC |
1197 | [ -g | --debugging ] |
1198 | [ -h | --section-headers | --headers ] | |
1199 | [ -i | --info ] | |
252b5132 | 1200 | [ -j @var{section} | --section=@var{section} ] |
1dada9c5 NC |
1201 | [ -l | --line-numbers ] |
1202 | [ -S | --source ] | |
252b5132 | 1203 | [ -m @var{machine} | --architecture=@var{machine} ] |
dd92f639 | 1204 | [ -M @var{options} | --disassembler-options=@var{options}] |
252b5132 | 1205 | [ -p | --private-headers ] |
1dada9c5 NC |
1206 | [ -r | --reloc ] |
1207 | [ -R | --dynamic-reloc ] | |
1208 | [ -s | --full-contents ] | |
1209 | [ -G | --stabs ] | |
1210 | [ -t | --syms ] | |
1211 | [ -T | --dynamic-syms ] | |
1212 | [ -x | --all-headers ] | |
1213 | [ -w | --wide ] | |
1214 | [ --start-address=@var{address} ] | |
252b5132 | 1215 | [ --stop-address=@var{address} ] |
1dada9c5 NC |
1216 | [ --prefix-addresses] |
1217 | [ --[no-]show-raw-insn ] | |
252b5132 | 1218 | [ --adjust-vma=@var{offset} ] |
1dada9c5 NC |
1219 | [ -V | --version ] |
1220 | [ -H | --help ] | |
252b5132 RH |
1221 | @var{objfile}@dots{} |
1222 | @end smallexample | |
1223 | ||
1224 | @code{objdump} displays information about one or more object files. | |
1225 | The options control what particular information to display. This | |
1226 | information is mostly useful to programmers who are working on the | |
1227 | compilation tools, as opposed to programmers who just want their | |
1228 | program to compile and work. | |
1229 | ||
1230 | @var{objfile}@dots{} are the object files to be examined. When you | |
1231 | specify archives, @code{objdump} shows information on each of the member | |
1232 | object files. | |
1233 | ||
1234 | The long and short forms of options, shown here as alternatives, are | |
1dada9c5 NC |
1235 | equivalent. At least one option from the list |
1236 | @samp{-a,-d,-D,-f,-g,-G,-h,-H,-p,-r,-R,-S,-t,-T,-V,-x} must be given. | |
252b5132 RH |
1237 | |
1238 | @table @code | |
1239 | @item -a | |
1240 | @itemx --archive-header | |
1241 | @cindex archive headers | |
1242 | If any of the @var{objfile} files are archives, display the archive | |
1243 | header information (in a format similar to @samp{ls -l}). Besides the | |
1244 | information you could list with @samp{ar tv}, @samp{objdump -a} shows | |
1245 | the object file format of each archive member. | |
1246 | ||
1247 | @item --adjust-vma=@var{offset} | |
1248 | @cindex section addresses in objdump | |
1249 | @cindex VMA in objdump | |
1250 | When dumping information, first add @var{offset} to all the section | |
1251 | addresses. This is useful if the section addresses do not correspond to | |
1252 | the symbol table, which can happen when putting sections at particular | |
1253 | addresses when using a format which can not represent section addresses, | |
1254 | such as a.out. | |
1255 | ||
1256 | @item -b @var{bfdname} | |
1257 | @itemx --target=@var{bfdname} | |
1258 | @cindex object code format | |
1259 | Specify that the object-code format for the object files is | |
1260 | @var{bfdname}. This option may not be necessary; @var{objdump} can | |
1261 | automatically recognize many formats. | |
1262 | ||
1263 | For example, | |
1264 | @example | |
1265 | objdump -b oasys -m vax -h fu.o | |
1266 | @end example | |
1267 | @noindent | |
1268 | displays summary information from the section headers (@samp{-h}) of | |
1269 | @file{fu.o}, which is explicitly identified (@samp{-m}) as a VAX object | |
1270 | file in the format produced by Oasys compilers. You can list the | |
1271 | formats available with the @samp{-i} option. | |
1272 | @xref{Target Selection}, for more information. | |
1273 | ||
1274 | @item -C | |
28c309a2 | 1275 | @itemx --demangle[=@var{style}] |
252b5132 RH |
1276 | @cindex demangling in objdump |
1277 | Decode (@dfn{demangle}) low-level symbol names into user-level names. | |
1278 | Besides removing any initial underscore prepended by the system, this | |
28c309a2 NC |
1279 | makes C++ function names readable. Different compilers have different |
1280 | mangling styles. The optional demangling style argument can be used to | |
1281 | choose an appropriate demangling style for your compiler. @xref{c++filt}, | |
1282 | for more information on demangling. | |
252b5132 | 1283 | |
1dada9c5 | 1284 | @item -G |
252b5132 RH |
1285 | @item --debugging |
1286 | Display debugging information. This attempts to parse debugging | |
1287 | information stored in the file and print it out using a C like syntax. | |
1288 | Only certain types of debugging information have been implemented. | |
1289 | ||
1290 | @item -d | |
1291 | @itemx --disassemble | |
1292 | @cindex disassembling object code | |
1293 | @cindex machine instructions | |
1294 | Display the assembler mnemonics for the machine instructions from | |
1295 | @var{objfile}. This option only disassembles those sections which are | |
1296 | expected to contain instructions. | |
1297 | ||
1298 | @item -D | |
1299 | @itemx --disassemble-all | |
1300 | Like @samp{-d}, but disassemble the contents of all sections, not just | |
1301 | those expected to contain instructions. | |
1302 | ||
1303 | @item --prefix-addresses | |
1304 | When disassembling, print the complete address on each line. This is | |
1305 | the older disassembly format. | |
1306 | ||
1307 | @item --disassemble-zeroes | |
1308 | Normally the disassembly output will skip blocks of zeroes. This | |
1309 | option directs the disassembler to disassemble those blocks, just like | |
1310 | any other data. | |
1311 | ||
1312 | @item -EB | |
1313 | @itemx -EL | |
1314 | @itemx --endian=@{big|little@} | |
1315 | @cindex endianness | |
1316 | @cindex disassembly endianness | |
1317 | Specify the endianness of the object files. This only affects | |
1318 | disassembly. This can be useful when disassembling a file format which | |
1319 | does not describe endianness information, such as S-records. | |
1320 | ||
1321 | @item -f | |
1322 | @itemx --file-header | |
1323 | @cindex object file header | |
1324 | Display summary information from the overall header of | |
1325 | each of the @var{objfile} files. | |
1326 | ||
f1563258 TW |
1327 | @item --file-start-context |
1328 | @cindex source code context | |
1329 | Specify that when displaying interlisted source code/disassembly | |
1330 | (assumes '-S') from a file that has not yet been displayed, extend the | |
1331 | context to the start of the file. | |
1332 | ||
252b5132 RH |
1333 | @item -h |
1334 | @itemx --section-header | |
1335 | @itemx --header | |
1336 | @cindex section headers | |
1337 | Display summary information from the section headers of the | |
1338 | object file. | |
1339 | ||
1340 | File segments may be relocated to nonstandard addresses, for example by | |
1341 | using the @samp{-Ttext}, @samp{-Tdata}, or @samp{-Tbss} options to | |
1342 | @code{ld}. However, some object file formats, such as a.out, do not | |
1343 | store the starting address of the file segments. In those situations, | |
1344 | although @code{ld} relocates the sections correctly, using @samp{objdump | |
1345 | -h} to list the file section headers cannot show the correct addresses. | |
1346 | Instead, it shows the usual addresses, which are implicit for the | |
1347 | target. | |
1348 | ||
1349 | @item --help | |
1350 | Print a summary of the options to @code{objdump} and exit. | |
1351 | ||
1352 | @item -i | |
1353 | @itemx --info | |
1354 | @cindex architectures available | |
1355 | @cindex object formats available | |
1356 | Display a list showing all architectures and object formats available | |
1357 | for specification with @samp{-b} or @samp{-m}. | |
1358 | ||
1359 | @item -j @var{name} | |
1360 | @itemx --section=@var{name} | |
1361 | @cindex section information | |
1362 | Display information only for section @var{name}. | |
1363 | ||
1364 | @item -l | |
1365 | @itemx --line-numbers | |
1366 | @cindex source filenames for object files | |
1367 | Label the display (using debugging information) with the filename and | |
1368 | source line numbers corresponding to the object code or relocs shown. | |
1369 | Only useful with @samp{-d}, @samp{-D}, or @samp{-r}. | |
1370 | ||
1371 | @item -m @var{machine} | |
1372 | @itemx --architecture=@var{machine} | |
1373 | @cindex architecture | |
1374 | @cindex disassembly architecture | |
1375 | Specify the architecture to use when disassembling object files. This | |
1376 | can be useful when disassembling object files which do not describe | |
1377 | architecture information, such as S-records. You can list the available | |
1378 | architectures with the @samp{-i} option. | |
1379 | ||
dd92f639 NC |
1380 | @item -M @var{options} |
1381 | @itemx --disassembler-options=@var{options} | |
1382 | Pass target specific information to the disassembler. Only supported on | |
1383 | some targets. | |
1384 | ||
1385 | If the target is an ARM architecture then this switch can be used to | |
1386 | select which register name set is used during disassembler. Specifying | |
58efb6c0 NC |
1387 | @samp{-M reg-name-std} (the default) will select the register names as |
1388 | used in ARM's instruction set documentation, but with register 13 called | |
1389 | 'sp', register 14 called 'lr' and register 15 called 'pc'. Specifying | |
1390 | @samp{-M reg-names-apcs} will select the name set used by the ARM | |
1391 | Procedure Call Standard, whilst specifying @samp{-M reg-names-raw} will | |
1392 | just use @samp{r} followed by the register number. | |
1393 | ||
1394 | There are also two variants on the APCS register naming scheme enabled | |
0fff8110 | 1395 | by @samp{-M reg-names-atpcs} and @samp{-M reg-names-special-atpcs} which |
58efb6c0 NC |
1396 | use the ARM/Thumb Procedure Call Standard naming conventions. (Eiuther |
1397 | with the normal register name sor the special register names). | |
dd92f639 | 1398 | |
8f915f68 NC |
1399 | This option can also be used for ARM architectures to force the |
1400 | disassembler to interpret all instructions as THUMB instructions by | |
1401 | using the switch @samp{--disassembler-options=force-thumb}. This can be | |
1402 | useful when attempting to disassemble thumb code produced by other | |
1403 | compilers. | |
1404 | ||
252b5132 RH |
1405 | @item -p |
1406 | @itemx --private-headers | |
1407 | Print information that is specific to the object file format. The exact | |
1408 | information printed depends upon the object file format. For some | |
1409 | object file formats, no additional information is printed. | |
1410 | ||
1411 | @item -r | |
1412 | @itemx --reloc | |
1413 | @cindex relocation entries, in object file | |
1414 | Print the relocation entries of the file. If used with @samp{-d} or | |
1415 | @samp{-D}, the relocations are printed interspersed with the | |
1416 | disassembly. | |
1417 | ||
1418 | @item -R | |
1419 | @itemx --dynamic-reloc | |
1420 | @cindex dynamic relocation entries, in object file | |
1421 | Print the dynamic relocation entries of the file. This is only | |
1422 | meaningful for dynamic objects, such as certain types of shared | |
1423 | libraries. | |
1424 | ||
1425 | @item -s | |
1426 | @itemx --full-contents | |
1427 | @cindex sections, full contents | |
1428 | @cindex object file sections | |
1429 | Display the full contents of any sections requested. | |
1430 | ||
1431 | @item -S | |
1432 | @itemx --source | |
1433 | @cindex source disassembly | |
1434 | @cindex disassembly, with source | |
1435 | Display source code intermixed with disassembly, if possible. Implies | |
1436 | @samp{-d}. | |
1437 | ||
1438 | @item --show-raw-insn | |
1439 | When disassembling instructions, print the instruction in hex as well as | |
1440 | in symbolic form. This is the default except when | |
1441 | @code{--prefix-addresses} is used. | |
1442 | ||
1443 | @item --no-show-raw-insn | |
1444 | When disassembling instructions, do not print the instruction bytes. | |
1445 | This is the default when @code{--prefix-addresses} is used. | |
1446 | ||
1dada9c5 | 1447 | @item -G |
252b5132 RH |
1448 | @item --stabs |
1449 | @cindex stab | |
1450 | @cindex .stab | |
1451 | @cindex debug symbols | |
1452 | @cindex ELF object file format | |
1453 | Display the full contents of any sections requested. Display the | |
1454 | contents of the .stab and .stab.index and .stab.excl sections from an | |
1455 | ELF file. This is only useful on systems (such as Solaris 2.0) in which | |
1456 | @code{.stab} debugging symbol-table entries are carried in an ELF | |
1457 | section. In most other file formats, debugging symbol-table entries are | |
1458 | interleaved with linkage symbols, and are visible in the @samp{--syms} | |
1459 | output. For more information on stabs symbols, see @ref{Top,Stabs,Stabs | |
1460 | Overview,stabs.info, The ``stabs'' debug format}. | |
1461 | ||
1462 | @item --start-address=@var{address} | |
1463 | @cindex start-address | |
1464 | Start displaying data at the specified address. This affects the output | |
1465 | of the @code{-d}, @code{-r} and @code{-s} options. | |
1466 | ||
1467 | @item --stop-address=@var{address} | |
1468 | @cindex stop-address | |
1469 | Stop displaying data at the specified address. This affects the output | |
1470 | of the @code{-d}, @code{-r} and @code{-s} options. | |
1471 | ||
1472 | @item -t | |
1473 | @itemx --syms | |
1474 | @cindex symbol table entries, printing | |
1475 | Print the symbol table entries of the file. | |
1476 | This is similar to the information provided by the @samp{nm} program. | |
1477 | ||
1478 | @item -T | |
1479 | @itemx --dynamic-syms | |
1480 | @cindex dynamic symbol table entries, printing | |
1481 | Print the dynamic symbol table entries of the file. This is only | |
1482 | meaningful for dynamic objects, such as certain types of shared | |
1483 | libraries. This is similar to the information provided by the @samp{nm} | |
1484 | program when given the @samp{-D} (@samp{--dynamic}) option. | |
1485 | ||
1486 | @item --version | |
1487 | Print the version number of @code{objdump} and exit. | |
1488 | ||
1489 | @item -x | |
1490 | @itemx --all-header | |
1491 | @cindex all header information, object file | |
1492 | @cindex header information, all | |
1493 | Display all available header information, including the symbol table and | |
1494 | relocation entries. Using @samp{-x} is equivalent to specifying all of | |
1495 | @samp{-a -f -h -r -t}. | |
1496 | ||
1497 | @item -w | |
1498 | @itemx --wide | |
1499 | @cindex wide output, printing | |
1500 | Format some lines for output devices that have more than 80 columns. | |
1501 | @end table | |
1502 | ||
1503 | @node ranlib | |
1504 | @chapter ranlib | |
1505 | ||
1506 | @kindex ranlib | |
1507 | @cindex archive contents | |
1508 | @cindex symbol index | |
1509 | ||
1510 | @smallexample | |
1511 | ranlib [-vV] @var{archive} | |
1512 | @end smallexample | |
1513 | ||
1514 | @code{ranlib} generates an index to the contents of an archive and | |
1515 | stores it in the archive. The index lists each symbol defined by a | |
1516 | member of an archive that is a relocatable object file. | |
1517 | ||
1518 | You may use @samp{nm -s} or @samp{nm --print-armap} to list this index. | |
1519 | ||
1520 | An archive with such an index speeds up linking to the library and | |
1521 | allows routines in the library to call each other without regard to | |
1522 | their placement in the archive. | |
1523 | ||
1524 | The @sc{gnu} @code{ranlib} program is another form of @sc{gnu} @code{ar}; running | |
1525 | @code{ranlib} is completely equivalent to executing @samp{ar -s}. | |
1526 | @xref{ar}. | |
1527 | ||
1528 | @table @code | |
1529 | @item -v | |
1530 | @itemx -V | |
f20a759a | 1531 | @itemx --version |
252b5132 RH |
1532 | Show the version number of @code{ranlib}. |
1533 | @end table | |
1534 | ||
1535 | @node size | |
1536 | @chapter size | |
1537 | ||
1538 | @kindex size | |
1539 | @cindex section sizes | |
1540 | ||
1541 | @smallexample | |
1542 | size [ -A | -B | --format=@var{compatibility} ] | |
1543 | [ --help ] [ -d | -o | -x | --radix=@var{number} ] | |
1544 | [ --target=@var{bfdname} ] [ -V | --version ] | |
1545 | [ @var{objfile}@dots{} ] | |
1546 | @end smallexample | |
1547 | ||
1548 | The @sc{gnu} @code{size} utility lists the section sizes---and the total | |
1549 | size---for each of the object or archive files @var{objfile} in its | |
1550 | argument list. By default, one line of output is generated for each | |
1551 | object file or each module in an archive. | |
1552 | ||
1553 | @var{objfile}@dots{} are the object files to be examined. | |
1554 | If none are specified, the file @code{a.out} will be used. | |
1555 | ||
1556 | The command line options have the following meanings: | |
1557 | ||
1558 | @table @code | |
1559 | @item -A | |
1560 | @itemx -B | |
1561 | @itemx --format=@var{compatibility} | |
1562 | @cindex @code{size} display format | |
1563 | Using one of these options, you can choose whether the output from @sc{gnu} | |
1564 | @code{size} resembles output from System V @code{size} (using @samp{-A}, | |
1565 | or @samp{--format=sysv}), or Berkeley @code{size} (using @samp{-B}, or | |
1566 | @samp{--format=berkeley}). The default is the one-line format similar to | |
1567 | Berkeley's. | |
1568 | @c Bonus for doc-source readers: you can also say --format=strange (or | |
1569 | @c anything else that starts with 's') for sysv, and --format=boring (or | |
1570 | @c anything else that starts with 'b') for Berkeley. | |
1571 | ||
1572 | Here is an example of the Berkeley (default) format of output from | |
1573 | @code{size}: | |
1574 | @smallexample | |
f20a759a | 1575 | $ size --format=Berkeley ranlib size |
252b5132 RH |
1576 | text data bss dec hex filename |
1577 | 294880 81920 11592 388392 5ed28 ranlib | |
1578 | 294880 81920 11888 388688 5ee50 size | |
1579 | @end smallexample | |
1580 | ||
1581 | @noindent | |
1582 | This is the same data, but displayed closer to System V conventions: | |
1583 | ||
1584 | @smallexample | |
f20a759a | 1585 | $ size --format=SysV ranlib size |
252b5132 RH |
1586 | ranlib : |
1587 | section size addr | |
1588 | .text 294880 8192 | |
1589 | .data 81920 303104 | |
1590 | .bss 11592 385024 | |
1591 | Total 388392 | |
1592 | ||
1593 | ||
1594 | size : | |
1595 | section size addr | |
1596 | .text 294880 8192 | |
1597 | .data 81920 303104 | |
1598 | .bss 11888 385024 | |
1599 | Total 388688 | |
1600 | @end smallexample | |
1601 | ||
1602 | @item --help | |
1603 | Show a summary of acceptable arguments and options. | |
1604 | ||
1605 | @item -d | |
1606 | @itemx -o | |
1607 | @itemx -x | |
1608 | @itemx --radix=@var{number} | |
1609 | @cindex @code{size} number format | |
1610 | @cindex radix for section sizes | |
1611 | Using one of these options, you can control whether the size of each | |
1612 | section is given in decimal (@samp{-d}, or @samp{--radix=10}); octal | |
1613 | (@samp{-o}, or @samp{--radix=8}); or hexadecimal (@samp{-x}, or | |
1614 | @samp{--radix=16}). In @samp{--radix=@var{number}}, only the three | |
1615 | values (8, 10, 16) are supported. The total size is always given in two | |
1616 | radices; decimal and hexadecimal for @samp{-d} or @samp{-x} output, or | |
1617 | octal and hexadecimal if you're using @samp{-o}. | |
1618 | ||
1619 | @item --target=@var{bfdname} | |
1620 | @cindex object code format | |
1621 | Specify that the object-code format for @var{objfile} is | |
1622 | @var{bfdname}. This option may not be necessary; @code{size} can | |
1623 | automatically recognize many formats. | |
1624 | @xref{Target Selection}, for more information. | |
1625 | ||
1626 | @item -V | |
1627 | @itemx --version | |
1628 | Display the version number of @code{size}. | |
1629 | @end table | |
1630 | ||
1631 | @node strings | |
1632 | @chapter strings | |
1633 | @kindex strings | |
1634 | @cindex listings strings | |
1635 | @cindex printing strings | |
1636 | @cindex strings, printing | |
1637 | ||
1638 | @smallexample | |
1639 | strings [-afov] [-@var{min-len}] [-n @var{min-len}] [-t @var{radix}] [-] | |
1640 | [--all] [--print-file-name] [--bytes=@var{min-len}] | |
1641 | [--radix=@var{radix}] [--target=@var{bfdname}] | |
1642 | [--help] [--version] @var{file}@dots{} | |
1643 | @end smallexample | |
1644 | ||
1645 | For each @var{file} given, @sc{gnu} @code{strings} prints the printable | |
1646 | character sequences that are at least 4 characters long (or the number | |
1647 | given with the options below) and are followed by an unprintable | |
1648 | character. By default, it only prints the strings from the initialized | |
1649 | and loaded sections of object files; for other types of files, it prints | |
1650 | the strings from the whole file. | |
1651 | ||
1652 | @code{strings} is mainly useful for determining the contents of non-text | |
1653 | files. | |
1654 | ||
1655 | @table @code | |
1656 | @item -a | |
1657 | @itemx --all | |
1658 | @itemx - | |
1659 | Do not scan only the initialized and loaded sections of object files; | |
1660 | scan the whole files. | |
1661 | ||
1662 | @item -f | |
1663 | @itemx --print-file-name | |
1664 | Print the name of the file before each string. | |
1665 | ||
1666 | @item --help | |
1667 | Print a summary of the program usage on the standard output and exit. | |
1668 | ||
1669 | @item -@var{min-len} | |
1670 | @itemx -n @var{min-len} | |
1671 | @itemx --bytes=@var{min-len} | |
1672 | Print sequences of characters that are at least @var{min-len} characters | |
1673 | long, instead of the default 4. | |
1674 | ||
1675 | @item -o | |
1676 | Like @samp{-t o}. Some other versions of @code{strings} have @samp{-o} | |
1677 | act like @samp{-t d} instead. Since we can not be compatible with both | |
1678 | ways, we simply chose one. | |
1679 | ||
1680 | @item -t @var{radix} | |
1681 | @itemx --radix=@var{radix} | |
1682 | Print the offset within the file before each string. The single | |
1683 | character argument specifies the radix of the offset---@samp{o} for | |
1684 | octal, @samp{x} for hexadecimal, or @samp{d} for decimal. | |
1685 | ||
1686 | @item --target=@var{bfdname} | |
1687 | @cindex object code format | |
1688 | Specify an object code format other than your system's default format. | |
1689 | @xref{Target Selection}, for more information. | |
1690 | ||
1691 | @item -v | |
1692 | @itemx --version | |
1693 | Print the program version number on the standard output and exit. | |
1694 | @end table | |
1695 | ||
1696 | @node strip | |
1697 | @chapter strip | |
1698 | ||
1699 | @kindex strip | |
1700 | @cindex removing symbols | |
1701 | @cindex discarding symbols | |
1702 | @cindex symbols, discarding | |
1703 | ||
1704 | @smallexample | |
1705 | strip [ -F @var{bfdname} | --target=@var{bfdname} ] | |
1706 | [ -I @var{bfdname} | --input-target=@var{bfdname} ] | |
1707 | [ -O @var{bfdname} | --output-target=@var{bfdname} ] | |
1708 | [ -s | --strip-all ] [ -S | -g | --strip-debug ] | |
1709 | [ -K @var{symbolname} | --keep-symbol=@var{symbolname} ] | |
1710 | [ -N @var{symbolname} | --strip-symbol=@var{symbolname} ] | |
1711 | [ -x | --discard-all ] [ -X | --discard-locals ] | |
1712 | [ -R @var{sectionname} | --remove-section=@var{sectionname} ] | |
1713 | [ -o @var{file} ] [ -p | --preserve-dates ] | |
1714 | [ -v | --verbose ] [ -V | --version ] [ --help ] | |
1715 | @var{objfile}@dots{} | |
1716 | @end smallexample | |
1717 | ||
1718 | @sc{gnu} @code{strip} discards all symbols from object files | |
1719 | @var{objfile}. The list of object files may include archives. | |
1720 | At least one object file must be given. | |
1721 | ||
1722 | @code{strip} modifies the files named in its argument, | |
1723 | rather than writing modified copies under different names. | |
1724 | ||
1725 | @table @code | |
1726 | @item -F @var{bfdname} | |
1727 | @itemx --target=@var{bfdname} | |
1728 | Treat the original @var{objfile} as a file with the object | |
1729 | code format @var{bfdname}, and rewrite it in the same format. | |
1730 | @xref{Target Selection}, for more information. | |
1731 | ||
1732 | @item --help | |
1733 | Show a summary of the options to @code{strip} and exit. | |
1734 | ||
1735 | @item -I @var{bfdname} | |
1736 | @itemx --input-target=@var{bfdname} | |
1737 | Treat the original @var{objfile} as a file with the object | |
1738 | code format @var{bfdname}. | |
1739 | @xref{Target Selection}, for more information. | |
1740 | ||
1741 | @item -O @var{bfdname} | |
1742 | @itemx --output-target=@var{bfdname} | |
1743 | Replace @var{objfile} with a file in the output format @var{bfdname}. | |
1744 | @xref{Target Selection}, for more information. | |
1745 | ||
1746 | @item -R @var{sectionname} | |
1747 | @itemx --remove-section=@var{sectionname} | |
1748 | Remove any section named @var{sectionname} from the output file. This | |
1749 | option may be given more than once. Note that using this option | |
1750 | inappropriately may make the output file unusable. | |
1751 | ||
1752 | @item -s | |
1753 | @itemx --strip-all | |
1754 | Remove all symbols. | |
1755 | ||
1756 | @item -g | |
1757 | @itemx -S | |
1758 | @itemx --strip-debug | |
1759 | Remove debugging symbols only. | |
1760 | ||
1761 | @item --strip-unneeded | |
1762 | Remove all symbols that are not needed for relocation processing. | |
1763 | ||
1764 | @item -K @var{symbolname} | |
1765 | @itemx --keep-symbol=@var{symbolname} | |
1766 | Keep only symbol @var{symbolname} from the source file. This option may | |
1767 | be given more than once. | |
1768 | ||
1769 | @item -N @var{symbolname} | |
1770 | @itemx --strip-symbol=@var{symbolname} | |
1771 | Remove symbol @var{symbolname} from the source file. This option may be | |
1772 | given more than once, and may be combined with strip options other than | |
1773 | @code{-K}. | |
1774 | ||
1775 | @item -o @var{file} | |
1776 | Put the stripped output in @var{file}, rather than replacing the | |
1777 | existing file. When this argument is used, only one @var{objfile} | |
1778 | argument may be specified. | |
1779 | ||
1780 | @item -p | |
1781 | @itemx --preserve-dates | |
1782 | Preserve the access and modification dates of the file. | |
1783 | ||
1784 | @item -x | |
1785 | @itemx --discard-all | |
1786 | Remove non-global symbols. | |
1787 | ||
1788 | @item -X | |
1789 | @itemx --discard-locals | |
1790 | Remove compiler-generated local symbols. | |
1791 | (These usually start with @samp{L} or @samp{.}.) | |
1792 | ||
1793 | @item -V | |
1794 | @itemx --version | |
1795 | Show the version number for @code{strip}. | |
1796 | ||
1797 | @item -v | |
1798 | @itemx --verbose | |
1799 | Verbose output: list all object files modified. In the case of | |
1800 | archives, @samp{strip -v} lists all members of the archive. | |
1801 | @end table | |
1802 | ||
9d51cc66 | 1803 | @node c++filt, addr2line, strip, Top |
252b5132 RH |
1804 | @chapter c++filt |
1805 | ||
1806 | @kindex c++filt | |
1807 | @cindex demangling C++ symbols | |
1808 | ||
1809 | @smallexample | |
1810 | c++filt [ -_ | --strip-underscores ] | |
1811 | [ -j | --java ] | |
1812 | [ -n | --no-strip-underscores ] | |
1813 | [ -s @var{format} | --format=@var{format} ] | |
1814 | [ --help ] [ --version ] [ @var{symbol}@dots{} ] | |
1815 | @end smallexample | |
1816 | ||
9d51cc66 | 1817 | @kindex cxxfilt |
252b5132 RH |
1818 | The C++ and Java languages provides function overloading, which means |
1819 | that you can write many functions with the same name (providing each | |
1820 | takes parameters of different types). All C++ and Java function names | |
1821 | are encoded into a low-level assembly label (this process is known as | |
9d51cc66 ILT |
1822 | @dfn{mangling}). The @code{c++filt} |
1823 | @footnote{MS-DOS does not allow @kbd{+} characters in file names, so on | |
1824 | MS-DOS this program is named @code{cxxfilt}.} | |
1825 | program does the inverse mapping: it decodes (@dfn{demangles}) low-level | |
1826 | names into user-level names so that the linker can keep these overloaded | |
1827 | functions from clashing. | |
252b5132 RH |
1828 | |
1829 | Every alphanumeric word (consisting of letters, digits, underscores, | |
1830 | dollars, or periods) seen in the input is a potential label. If the | |
1831 | label decodes into a C++ name, the C++ name replaces the low-level | |
1832 | name in the output. | |
1833 | ||
1834 | You can use @code{c++filt} to decipher individual symbols: | |
1835 | ||
1836 | @example | |
1837 | c++filt @var{symbol} | |
1838 | @end example | |
1839 | ||
1840 | If no @var{symbol} arguments are given, @code{c++filt} reads symbol | |
1841 | names from the standard input and writes the demangled names to the | |
1842 | standard output. All results are printed on the standard output. | |
1843 | ||
1844 | @table @code | |
1845 | @item -_ | |
1846 | @itemx --strip-underscores | |
1847 | On some systems, both the C and C++ compilers put an underscore in front | |
1848 | of every name. For example, the C name @code{foo} gets the low-level | |
1849 | name @code{_foo}. This option removes the initial underscore. Whether | |
1850 | @code{c++filt} removes the underscore by default is target dependent. | |
1851 | ||
1852 | @item -j | |
1853 | @itemx --java | |
1854 | Prints demangled names using Java syntax. The default is to use C++ | |
1855 | syntax. | |
1856 | ||
1857 | @item -n | |
1858 | @itemx --no-strip-underscores | |
1859 | Do not remove the initial underscore. | |
1860 | ||
1861 | @item -s @var{format} | |
1862 | @itemx --format=@var{format} | |
1863 | @sc{gnu} @code{nm} can decode three different methods of mangling, used by | |
1864 | different C++ compilers. The argument to this option selects which | |
1865 | method it uses: | |
1866 | ||
1867 | @table @code | |
1868 | @item gnu | |
1869 | the one used by the @sc{gnu} compiler (the default method) | |
1870 | @item lucid | |
1871 | the one used by the Lucid compiler | |
1872 | @item arm | |
1873 | the one specified by the C++ Annotated Reference Manual | |
1874 | @item hp | |
1875 | the one used by the HP compiler | |
1876 | @item edg | |
1877 | the one used by the EDG compiler | |
28c309a2 NC |
1878 | @item gnu-new-abi |
1879 | the one used by the @sc{gnu} compiler with the new ABI. | |
252b5132 RH |
1880 | @end table |
1881 | ||
1882 | @item --help | |
1883 | Print a summary of the options to @code{c++filt} and exit. | |
1884 | ||
1885 | @item --version | |
1886 | Print the version number of @code{c++filt} and exit. | |
1887 | @end table | |
1888 | ||
1889 | @quotation | |
1890 | @emph{Warning:} @code{c++filt} is a new utility, and the details of its | |
1891 | user interface are subject to change in future releases. In particular, | |
1892 | a command-line option may be required in the the future to decode a name | |
1893 | passed as an argument on the command line; in other words, | |
1894 | ||
1895 | @example | |
1896 | c++filt @var{symbol} | |
1897 | @end example | |
1898 | ||
1899 | @noindent | |
1900 | may in a future release become | |
1901 | ||
1902 | @example | |
1903 | c++filt @var{option} @var{symbol} | |
1904 | @end example | |
1905 | @end quotation | |
1906 | ||
1907 | @node addr2line | |
1908 | @chapter addr2line | |
1909 | ||
1910 | @kindex addr2line | |
1911 | @cindex address to file name and line number | |
1912 | ||
1913 | @smallexample | |
1914 | addr2line [ -b @var{bfdname} | --target=@var{bfdname} ] | |
28c309a2 | 1915 | [ -C | --demangle[=@var{style} ] |
252b5132 RH |
1916 | [ -e @var{filename} | --exe=@var{filename} ] |
1917 | [ -f | --functions ] [ -s | --basename ] | |
1918 | [ -H | --help ] [ -V | --version ] | |
1919 | [ addr addr ... ] | |
1920 | @end smallexample | |
1921 | ||
1922 | @code{addr2line} translates program addresses into file names and line | |
1923 | numbers. Given an address and an executable, it uses the debugging | |
1924 | information in the executable to figure out which file name and line | |
1925 | number are associated with a given address. | |
1926 | ||
1927 | The executable to use is specified with the @code{-e} option. The | |
f20a759a | 1928 | default is the file @file{a.out}. |
252b5132 RH |
1929 | |
1930 | @code{addr2line} has two modes of operation. | |
1931 | ||
1932 | In the first, hexadecimal addresses are specified on the command line, | |
1933 | and @code{addr2line} displays the file name and line number for each | |
1934 | address. | |
1935 | ||
1936 | In the second, @code{addr2line} reads hexadecimal addresses from | |
1937 | standard input, and prints the file name and line number for each | |
1938 | address on standard output. In this mode, @code{addr2line} may be used | |
1939 | in a pipe to convert dynamically chosen addresses. | |
1940 | ||
1941 | The format of the output is @samp{FILENAME:LINENO}. The file name and | |
1942 | line number for each address is printed on a separate line. If the | |
1943 | @code{-f} option is used, then each @samp{FILENAME:LINENO} line is | |
1944 | preceded by a @samp{FUNCTIONNAME} line which is the name of the function | |
1945 | containing the address. | |
1946 | ||
1947 | If the file name or function name can not be determined, | |
1948 | @code{addr2line} will print two question marks in their place. If the | |
1949 | line number can not be determined, @code{addr2line} will print 0. | |
1950 | ||
1951 | The long and short forms of options, shown here as alternatives, are | |
1952 | equivalent. | |
1953 | ||
1954 | @table @code | |
1955 | @item -b @var{bfdname} | |
1956 | @itemx --target=@var{bfdname} | |
1957 | @cindex object code format | |
1958 | Specify that the object-code format for the object files is | |
1959 | @var{bfdname}. | |
1960 | ||
1961 | @item -C | |
28c309a2 | 1962 | @itemx --demangle[=@var{style}] |
252b5132 RH |
1963 | @cindex demangling in objdump |
1964 | Decode (@dfn{demangle}) low-level symbol names into user-level names. | |
1965 | Besides removing any initial underscore prepended by the system, this | |
28c309a2 NC |
1966 | makes C++ function names readable. Different compilers have different |
1967 | mangling styles. The optional demangling style argument can be used to | |
1968 | choose an appropriate demangling style for your compiler. @xref{c++filt}, | |
1969 | for more information on demangling. | |
252b5132 RH |
1970 | |
1971 | @item -e @var{filename} | |
1972 | @itemx --exe=@var{filename} | |
1973 | Specify the name of the executable for which addresses should be | |
1974 | translated. The default file is @file{a.out}. | |
1975 | ||
1976 | @item -f | |
1977 | @itemx --functions | |
1978 | Display function names as well as file and line number information. | |
1979 | ||
1980 | @item -s | |
1981 | @itemx --basenames | |
1982 | Display only the base of each file name. | |
e107c42f | 1983 | @end table |
252b5132 RH |
1984 | |
1985 | @node nlmconv | |
1986 | @chapter nlmconv | |
1987 | ||
1988 | @code{nlmconv} converts a relocatable object file into a NetWare | |
1989 | Loadable Module. | |
1990 | ||
1991 | @ignore | |
1992 | @code{nlmconv} currently works with @samp{i386} object | |
1993 | files in @code{coff}, @sc{elf}, or @code{a.out} format, and @sc{SPARC} | |
1994 | object files in @sc{elf}, or @code{a.out} format@footnote{ | |
1995 | @code{nlmconv} should work with any @samp{i386} or @sc{sparc} object | |
1996 | format in the Binary File Descriptor library. It has only been tested | |
1997 | with the above formats.}. | |
1998 | @end ignore | |
1999 | ||
2000 | @quotation | |
2001 | @emph{Warning:} @code{nlmconv} is not always built as part of the binary | |
2002 | utilities, since it is only useful for NLM targets. | |
2003 | @end quotation | |
2004 | ||
2005 | @smallexample | |
2006 | nlmconv [ -I @var{bfdname} | --input-target=@var{bfdname} ] | |
2007 | [ -O @var{bfdname} | --output-target=@var{bfdname} ] | |
2008 | [ -T @var{headerfile} | --header-file=@var{headerfile} ] | |
2009 | [ -d | --debug] [ -l @var{linker} | --linker=@var{linker} ] | |
2010 | [ -h | --help ] [ -V | --version ] | |
2011 | @var{infile} @var{outfile} | |
2012 | @end smallexample | |
2013 | ||
2014 | @code{nlmconv} converts the relocatable @samp{i386} object file | |
2015 | @var{infile} into the NetWare Loadable Module @var{outfile}, optionally | |
2016 | reading @var{headerfile} for NLM header information. For instructions | |
2017 | on writing the NLM command file language used in header files, see the | |
2018 | @samp{linkers} section, @samp{NLMLINK} in particular, of the @cite{NLM | |
2019 | Development and Tools Overview}, which is part of the NLM Software | |
2020 | Developer's Kit (``NLM SDK''), available from Novell, Inc. | |
2021 | @code{nlmconv} uses the @sc{gnu} Binary File Descriptor library to read | |
2022 | @var{infile}; see @ref{BFD,,BFD,ld.info,Using LD}, for | |
2023 | more information. | |
2024 | ||
2025 | @code{nlmconv} can perform a link step. In other words, you can list | |
2026 | more than one object file for input if you list them in the definitions | |
2027 | file (rather than simply specifying one input file on the command line). | |
2028 | In this case, @code{nlmconv} calls the linker for you. | |
2029 | ||
2030 | @table @code | |
2031 | @item -I @var{bfdname} | |
2032 | @itemx --input-target=@var{bfdname} | |
2033 | Object format of the input file. @code{nlmconv} can usually determine | |
2034 | the format of a given file (so no default is necessary). | |
2035 | @xref{Target Selection}, for more information. | |
2036 | ||
2037 | @item -O @var{bfdname} | |
2038 | @itemx --output-target=@var{bfdname} | |
2039 | Object format of the output file. @code{nlmconv} infers the output | |
2040 | format based on the input format, e.g. for a @samp{i386} input file the | |
2041 | output format is @samp{nlm32-i386}. | |
2042 | @xref{Target Selection}, for more information. | |
2043 | ||
2044 | @item -T @var{headerfile} | |
2045 | @itemx --header-file=@var{headerfile} | |
2046 | Reads @var{headerfile} for NLM header information. For instructions on | |
2047 | writing the NLM command file language used in header files, see@ see the | |
2048 | @samp{linkers} section, of the @cite{NLM Development and Tools | |
2049 | Overview}, which is part of the NLM Software Developer's Kit, available | |
2050 | from Novell, Inc. | |
2051 | ||
2052 | @item -d | |
2053 | @itemx --debug | |
2054 | Displays (on standard error) the linker command line used by @code{nlmconv}. | |
2055 | ||
2056 | @item -l @var{linker} | |
2057 | @itemx --linker=@var{linker} | |
2058 | Use @var{linker} for any linking. @var{linker} can be an absolute or a | |
2059 | relative pathname. | |
2060 | ||
2061 | @item -h | |
2062 | @itemx --help | |
2063 | Prints a usage summary. | |
2064 | ||
2065 | @item -V | |
2066 | @itemx --version | |
2067 | Prints the version number for @code{nlmconv}. | |
2068 | @end table | |
2069 | ||
2070 | @node windres | |
2071 | @chapter windres | |
2072 | ||
2073 | @code{windres} may be used to manipulate Windows resources. | |
2074 | ||
2075 | @quotation | |
2076 | @emph{Warning:} @code{windres} is not always built as part of the binary | |
2077 | utilities, since it is only useful for Windows targets. | |
2078 | @end quotation | |
2079 | ||
2080 | @smallexample | |
2081 | windres [options] [input-file] [output-file] | |
2082 | @end smallexample | |
2083 | ||
2084 | @code{windres} reads resources from an input file and copies them into | |
2085 | an output file. Either file may be in one of three formats: | |
2086 | ||
2087 | @table @code | |
2088 | @item rc | |
2089 | A text format read by the Resource Compiler. | |
2090 | ||
2091 | @item res | |
2092 | A binary format generated by the Resource Compiler. | |
2093 | ||
2094 | @item coff | |
2095 | A COFF object or executable. | |
2096 | @end table | |
2097 | ||
2098 | The exact description of these different formats is available in | |
2099 | documentation from Microsoft. | |
2100 | ||
2101 | When @code{windres} converts from the @code{rc} format to the @code{res} | |
2102 | format, it is acting like the Windows Resource Compiler. When | |
2103 | @code{windres} converts from the @code{res} format to the @code{coff} | |
2104 | format, it is acting like the Windows @code{CVTRES} program. | |
2105 | ||
2106 | When @code{windres} generates an @code{rc} file, the output is similar | |
2107 | but not identical to the format expected for the input. When an input | |
2108 | @code{rc} file refers to an external filename, an output @code{rc} file | |
2109 | will instead include the file contents. | |
2110 | ||
2111 | If the input or output format is not specified, @code{windres} will | |
2112 | guess based on the file name, or, for the input file, the file contents. | |
2113 | A file with an extension of @file{.rc} will be treated as an @code{rc} | |
2114 | file, a file with an extension of @file{.res} will be treated as a | |
2115 | @code{res} file, and a file with an extension of @file{.o} or | |
2116 | @file{.exe} will be treated as a @code{coff} file. | |
2117 | ||
2118 | If no output file is specified, @code{windres} will print the resources | |
2119 | in @code{rc} format to standard output. | |
2120 | ||
2121 | The normal use is for you to write an @code{rc} file, use @code{windres} | |
2122 | to convert it to a COFF object file, and then link the COFF file into | |
2123 | your application. This will make the resources described in the | |
2124 | @code{rc} file available to Windows. | |
2125 | ||
2126 | @table @code | |
2127 | @item -i @var{filename} | |
2128 | @itemx --input @var{filename} | |
2129 | The name of the input file. If this option is not used, then | |
2130 | @code{windres} will use the first non-option argument as the input file | |
2131 | name. If there are no non-option arguments, then @code{windres} will | |
2132 | read from standard input. @code{windres} can not read a COFF file from | |
2133 | standard input. | |
2134 | ||
2135 | @item -o @var{filename} | |
2136 | @itemx --output @var{filename} | |
2137 | The name of the output file. If this option is not used, then | |
2138 | @code{windres} will use the first non-option argument, after any used | |
2139 | for the input file name, as the output file name. If there is no | |
2140 | non-option argument, then @code{windres} will write to standard output. | |
2141 | @code{windres} can not write a COFF file to standard output. | |
2142 | ||
2143 | @item -I @var{format} | |
2144 | @itemx --input-format @var{format} | |
2145 | The input format to read. @var{format} may be @samp{res}, @samp{rc}, or | |
2146 | @samp{coff}. If no input format is specified, @code{windres} will | |
2147 | guess, as described above. | |
2148 | ||
2149 | @item -O @var{format} | |
2150 | @itemx --output-format @var{format} | |
2151 | The output format to generate. @var{format} may be @samp{res}, | |
2152 | @samp{rc}, or @samp{coff}. If no output format is specified, | |
2153 | @code{windres} will guess, as described above. | |
2154 | ||
2155 | @item -F @var{target} | |
2156 | @itemx --target @var{target} | |
2157 | Specify the BFD format to use for a COFF file as input or output. This | |
2158 | is a BFD target name; you can use the @code{--help} option to see a list | |
2159 | of supported targets. Normally @code{windres} will use the default | |
2160 | format, which is the first one listed by the @code{--help} option. | |
2161 | @ref{Target Selection}. | |
2162 | ||
2163 | @item --preprocessor @var{program} | |
2164 | When @code{windres} reads an @code{rc} file, it runs it through the C | |
2165 | preprocessor first. This option may be used to specify the preprocessor | |
2166 | to use, including any leading arguments. The default preprocessor | |
2167 | argument is @code{gcc -E -xc-header -DRC_INVOKED}. | |
2168 | ||
2169 | @item --include-dir @var{directory} | |
2170 | Specify an include directory to use when reading an @code{rc} file. | |
2171 | @code{windres} will pass this to the preprocessor as an @code{-I} | |
2172 | option. @code{windres} will also search this directory when looking for | |
2173 | files named in the @code{rc} file. | |
2174 | ||
751d21b5 | 2175 | @item -D @var{target} |
ad0481cd | 2176 | @itemx --define @var{sym}[=@var{val}] |
252b5132 RH |
2177 | Specify a @code{-D} option to pass to the preprocessor when reading an |
2178 | @code{rc} file. | |
2179 | ||
751d21b5 DD |
2180 | @item -v |
2181 | Enable verbose mode. This tells you what the preprocessor is if you | |
2182 | didn't specify one. | |
2183 | ||
252b5132 RH |
2184 | @item --language @var{val} |
2185 | Specify the default language to use when reading an @code{rc} file. | |
2186 | @var{val} should be a hexadecimal language code. The low eight bits are | |
2187 | the language, and the high eight bits are the sublanguage. | |
2188 | ||
5a298d2d NC |
2189 | @item --use-temp-file |
2190 | Use a temporary file to instead of using popen to read the output of | |
2191 | the preprocessor. Use this option if the popen implementation is buggy | |
2192 | on the host (eg., certain non-English language versions of Windows 95 and | |
2193 | Windows 98 are known to have buggy popen where the output will instead | |
2194 | go the console). | |
2195 | ||
2196 | @item --no-use-temp-file | |
2197 | Use popen, not a temporary file, to read the output of the preprocessor. | |
2198 | This is the default behaviour. | |
2199 | ||
252b5132 RH |
2200 | @item --help |
2201 | Prints a usage summary. | |
2202 | ||
2203 | @item --version | |
2204 | Prints the version number for @code{windres}. | |
2205 | ||
2206 | @item --yydebug | |
2207 | If @code{windres} is compiled with @code{YYDEBUG} defined as @code{1}, | |
2208 | this will turn on parser debugging. | |
2209 | @end table | |
2210 | ||
2211 | ||
2212 | @node dlltool | |
2213 | @chapter Create files needed to build and use DLLs | |
2214 | @cindex DLL | |
2215 | @kindex dlltool | |
2216 | ||
2217 | @code{dlltool} may be used to create the files needed to build and use | |
2218 | dynamic link libraries (DLLs). | |
2219 | ||
2220 | @quotation | |
2221 | @emph{Warning:} @code{dlltool} is not always built as part of the binary | |
2222 | utilities, since it is only useful for those targets which support DLLs. | |
2223 | @end quotation | |
2224 | ||
2225 | @smallexample | |
2226 | dlltool [-d|--input-def @var{def-file-name}] | |
2227 | [-b|--base-file @var{base-file-name}] | |
2228 | [-e|--output-exp @var{exports-file-name}] | |
2229 | [-z|--output-def @var{def-file-name}] | |
2230 | [-l|--output-lib @var{library-file-name}] | |
2231 | [--export-all-symbols] [--no-export-all-symbols] | |
2232 | [--exclude-symbols @var{list}] | |
2233 | [--no-default-excludes] | |
2234 | [-S|--as @var{path-to-assembler}] [-f|--as-flags @var{options}] | |
2235 | [-D|--dllname @var{name}] [-m|--machine @var{machine}] | |
2236 | [-a|--add-indirect] [-U|--add-underscore] [-k|--kill-at] | |
2237 | [-A|--add-stdcall-alias] | |
2238 | [-x|--no-idata4] [-c|--no-idata5] [-i|--interwork] | |
2239 | [-n|--nodelete] [-v|--verbose] [-h|--help] [-V|--version] | |
2240 | [object-file @dots{}] | |
2241 | @end smallexample | |
2242 | ||
2243 | @code{dlltool} reads its inputs, which can come from the @samp{-d} and | |
2244 | @samp{-b} options as well as object files specified on the command | |
2245 | line. It then processes these inputs and if the @samp{-e} option has | |
2246 | been specified it creates a exports file. If the @samp{-l} option | |
2247 | has been specified it creates a library file and if the @samp{-z} option | |
2248 | has been specified it creates a def file. Any or all of the -e, -l | |
2249 | and -z options can be present in one invocation of dlltool. | |
2250 | ||
2251 | When creating a DLL, along with the source for the DLL, it is necessary | |
2252 | to have three other files. @code{dlltool} can help with the creation of | |
2253 | these files. | |
2254 | ||
2255 | The first file is a @samp{.def} file which specifies which functions are | |
2256 | exported from the DLL, which functions the DLL imports, and so on. This | |
2257 | is a text file and can be created by hand, or @code{dlltool} can be used | |
2258 | to create it using the @samp{-z} option. In this case @code{dlltool} | |
2259 | will scan the object files specified on its command line looking for | |
2260 | those functions which have been specially marked as being exported and | |
2261 | put entries for them in the .def file it creates. | |
2262 | ||
2263 | In order to mark a function as being exported from a DLL, it needs to | |
2264 | have an @samp{-export:<name_of_function>} entry in the @samp{.drectve} | |
2265 | section of the object file. This can be done in C by using the | |
2266 | asm() operator: | |
2267 | ||
2268 | @smallexample | |
2269 | asm (".section .drectve"); | |
2270 | asm (".ascii \"-export:my_func\""); | |
2271 | ||
2272 | int my_func (void) @{ @dots{} @} | |
2273 | @end smallexample | |
2274 | ||
2275 | The second file needed for DLL creation is an exports file. This file | |
2276 | is linked with the object files that make up the body of the DLL and it | |
2277 | handles the interface between the DLL and the outside world. This is a | |
2278 | binary file and it can be created by giving the @samp{-e} option to | |
2279 | @code{dlltool} when it is creating or reading in a .def file. | |
2280 | ||
2281 | The third file needed for DLL creation is the library file that programs | |
2282 | will link with in order to access the functions in the DLL. This file | |
2283 | can be created by giving the @samp{-l} option to dlltool when it | |
2284 | is creating or reading in a .def file. | |
2285 | ||
2286 | @code{dlltool} builds the library file by hand, but it builds the | |
2287 | exports file by creating temporary files containing assembler statements | |
2288 | and then assembling these. The @samp{-S} command line option can be | |
2289 | used to specify the path to the assembler that dlltool will use, | |
2290 | and the @samp{-f} option can be used to pass specific flags to that | |
2291 | assembler. The @samp{-n} can be used to prevent dlltool from deleting | |
2292 | these temporary assembler files when it is done, and if @samp{-n} is | |
2293 | specified twice then this will prevent dlltool from deleting the | |
2294 | temporary object files it used to build the library. | |
2295 | ||
2296 | Here is an example of creating a DLL from a source file @samp{dll.c} and | |
2297 | also creating a program (from an object file called @samp{program.o}) | |
2298 | that uses that DLL: | |
2299 | ||
2300 | @smallexample | |
2301 | gcc -c dll.c | |
2302 | dlltool -e exports.o -l dll.lib dll.o | |
2303 | gcc dll.o exports.o -o dll.dll | |
2304 | gcc program.o dll.lib -o program | |
2305 | @end smallexample | |
2306 | ||
2307 | The command line options have the following meanings: | |
2308 | ||
2309 | @table @code | |
2310 | ||
2311 | @item -d @var{filename} | |
2312 | @itemx --input-def @var{filename} | |
2313 | @cindex input .def file | |
2314 | Specifies the name of a .def file to be read in and processed. | |
2315 | ||
2316 | @item -b @var{filename} | |
2317 | @itemx --base-file @var{filename} | |
2318 | @cindex base files | |
2319 | Specifies the name of a base file to be read in and processed. The | |
2320 | contents of this file will be added to the relocation section in the | |
2321 | exports file generated by dlltool. | |
2322 | ||
2323 | @item -e @var{filename} | |
2324 | @itemx --output-exp @var{filename} | |
2325 | Specifies the name of the export file to be created by dlltool. | |
2326 | ||
2327 | @item -z @var{filename} | |
2328 | @itemx --output-def @var{filename} | |
2329 | Specifies the name of the .def file to be created by dlltool. | |
2330 | ||
2331 | @item -l @var{filename} | |
2332 | @itemx --output-lib @var{filename} | |
2333 | Specifies the name of the library file to be created by dlltool. | |
2334 | ||
2335 | @item --export-all-symbols | |
2336 | Treat all global and weak defined symbols found in the input object | |
2337 | files as symbols to be exported. There is a small list of symbols which | |
2338 | are not exported by default; see the @code{--no-default-excludes} | |
2339 | option. You may add to the list of symbols to not export by using the | |
2340 | @code{--exclude-symbols} option. | |
2341 | ||
2342 | @item --no-export-all-symbols | |
2343 | Only export symbols explicitly listed in an input .def file or in | |
2344 | @samp{.drectve} sections in the input object files. This is the default | |
2345 | behaviour. The @samp{.drectve} sections are created by @samp{dllexport} | |
2346 | attributes in the source code. | |
2347 | ||
2348 | @item --exclude-symbols @var{list} | |
2349 | Do not export the symbols in @var{list}. This is a list of symbol names | |
2350 | separated by comma or colon characters. The symbol names should not | |
2351 | contain a leading underscore. This is only meaningful when | |
2352 | @code{--export-all-symbols} is used. | |
2353 | ||
2354 | @item --no-default-excludes | |
2355 | When @code{--export-all-symbols} is used, it will by default avoid | |
2356 | exporting certain special symbols. The current list of symbols to avoid | |
2357 | exporting is @samp{DllMain@@12}, @samp{DllEntryPoint@@0}, | |
2358 | @samp{impure_ptr}. You may use the @code{--no-default-excludes} option | |
2359 | to go ahead and export these special symbols. This is only meaningful | |
2360 | when @code{--export-all-symbols} is used. | |
2361 | ||
2362 | @item -S @var{path} | |
2363 | @itemx --as @var{path} | |
2364 | Specifies the path, including the filename, of the assembler to be used | |
2365 | to create the exports file. | |
2366 | ||
2367 | @item -f @var{switches} | |
2368 | @itemx --as-flags @var{switches} | |
2369 | Specifies any specific command line switches to be passed to the | |
2370 | assembler when building the exports file. This option will work even if | |
2371 | the @samp{-S} option is not used. This option only takes one argument, | |
2372 | and if it occurs more than once on the command line, then later | |
2373 | occurrences will override earlier occurrences. So if it is necessary to | |
2374 | pass multiple switches to the assembler they should be enclosed in | |
2375 | double quotes. | |
2376 | ||
2377 | @item -D @var{name} | |
2378 | @itemx --dll-name @var{name} | |
2379 | Specifies the name to be stored in the .def file as the name of the DLL | |
2380 | when the @samp{-e} option is used. If this option is not present, then | |
2381 | the filename given to the @samp{-e} option will be used as the name of | |
2382 | the DLL. | |
2383 | ||
2384 | @item -m @var{machine} | |
2385 | @itemx -machine @var{machine} | |
2386 | Specifies the type of machine for which the library file should be | |
2387 | built. @code{dlltool} has a built in default type, depending upon how | |
2388 | it was created, but this option can be used to override that. This is | |
2389 | normally only useful when creating DLLs for an ARM processor, when the | |
2390 | contents of the DLL are actually encode using THUMB instructions. | |
2391 | ||
2392 | @item -a | |
2393 | @itemx --add-indirect | |
2394 | Specifies that when @code{dlltool} is creating the exports file it | |
2395 | should add a section which allows the exported functions to be | |
2396 | referenced without using the import library. Whatever the hell that | |
2397 | means! | |
2398 | ||
2399 | @item -U | |
2400 | @itemx --add-underscore | |
2401 | Specifies that when @code{dlltool} is creating the exports file it | |
2402 | should prepend an underscore to the names of the exported functions. | |
2403 | ||
2404 | @item -k | |
2405 | @itemx --kill-at | |
2406 | Specifies that when @code{dlltool} is creating the exports file it | |
2407 | should not append the string @samp{@@ <number>}. These numbers are | |
2408 | called ordinal numbers and they represent another way of accessing the | |
2409 | function in a DLL, other than by name. | |
2410 | ||
2411 | @item -A | |
2412 | @itemx --add-stdcall-alias | |
2413 | Specifies that when @code{dlltool} is creating the exports file it | |
2414 | should add aliases for stdcall symbols without @samp{@@ <number>} | |
2415 | in addition to the symbols with @samp{@@ <number>}. | |
2416 | ||
2417 | @item -x | |
2418 | @itemx --no-idata4 | |
2419 | Specifies that when @code{dlltool} is creating the exports and library | |
2420 | files it should omit the .idata4 section. This is for compatibility | |
2421 | with certain operating systems. | |
2422 | ||
2423 | @item -c | |
2424 | @itemx --no-idata5 | |
2425 | Specifies that when @code{dlltool} is creating the exports and library | |
2426 | files it should omit the .idata5 section. This is for compatibility | |
2427 | with certain operating systems. | |
2428 | ||
2429 | @item -i | |
2430 | @itemx --interwork | |
2431 | Specifies that @code{dlltool} should mark the objects in the library | |
2432 | file and exports file that it produces as supporting interworking | |
2433 | between ARM and THUMB code. | |
2434 | ||
2435 | @item -n | |
2436 | @itemx --nodelete | |
2437 | Makes @code{dlltool} preserve the temporary assembler files it used to | |
2438 | create the exports file. If this option is repeated then dlltool will | |
2439 | also preserve the temporary object files it uses to create the library | |
2440 | file. | |
2441 | ||
2442 | @item -v | |
2443 | @itemx --verbose | |
2444 | Make dlltool describe what it is doing. | |
2445 | ||
2446 | @item -h | |
2447 | @itemx --help | |
2448 | Displays a list of command line options and then exits. | |
2449 | ||
2450 | @item -V | |
2451 | @itemx --version | |
2452 | Displays dlltool's version number and then exits. | |
2453 | ||
2454 | @end table | |
2455 | ||
2456 | @node readelf | |
2457 | @chapter readelf | |
2458 | ||
2459 | @cindex ELF file information | |
2460 | @kindex readelf | |
2461 | ||
2462 | @smallexample | |
2463 | readelf [ -a | --all ] | |
2464 | [ -h | --file-header] | |
2465 | [ -l | --program-headers | --segments] | |
2466 | [ -S | --section-headers | --sections] | |
2467 | [ -e | --headers] | |
2468 | [ -s | --syms | --symbols] | |
779fe533 | 2469 | [ -n | --notes] |
252b5132 RH |
2470 | [ -r | --relocs] |
2471 | [ -d | --dynamic] | |
2472 | [ -V | --version-info] | |
2473 | [ -D | --use-dynamic] | |
2474 | [ -x <number> | --hex-dump=<number>] | |
2475 | [ -w[liapr] | --debug-dump[=info,=line,=abbrev,=pubnames,=ranges]] | |
2476 | [ --histogram] | |
2477 | [ -v | --version] | |
2478 | [ -H | --help] | |
2479 | @var{elffile}@dots{} | |
2480 | @end smallexample | |
2481 | ||
2482 | @code{readelf} displays information about one or more ELF format object | |
2483 | files. The options control what particular information to display. | |
2484 | ||
2485 | @var{elffile}@dots{} are the object files to be examined. At the | |
2486 | moment, @code{readelf} does not support examining archives, nor does it | |
2487 | support examing 64 bit ELF files. | |
2488 | ||
2489 | The long and short forms of options, shown here as alternatives, are | |
2490 | equivalent. At least one option besides @samp{-v} or @samp{-H} must be | |
2491 | given. | |
2492 | ||
2493 | @table @code | |
2494 | @item -a | |
2495 | @itemx --all | |
2496 | Equivalent to specifiying @samp{--file-header}, | |
2497 | @samp{--program-headers}, @samp{--sections}, @samp{--symbols}, | |
779fe533 NC |
2498 | @samp{--relocs}, @samp{--dynamic}, @samp{--notes} and |
2499 | @samp{--version-info}. | |
252b5132 RH |
2500 | |
2501 | @item -h | |
2502 | @itemx --file-header | |
2503 | @cindex ELF file header information | |
2504 | Displays the information contained in the ELF header at the start of the | |
2505 | file. | |
2506 | ||
2507 | @item -l | |
2508 | @itemx --program-headers | |
2509 | @itemx --segments | |
2510 | @cindex ELF program header information | |
2511 | @cindex ELF segment information | |
2512 | Displays the information contained in the file's segment headers, if it | |
2513 | has any. | |
2514 | ||
2515 | @item -S | |
2516 | @itemx --sections | |
2517 | @itemx --section-headers | |
2518 | @cindex ELF section information | |
2519 | Displays the information contained in the file's section headers, if it | |
2520 | has any. | |
2521 | ||
2522 | @item -s | |
2523 | @itemx --symbols | |
2524 | @itemx --syms | |
2525 | @cindex ELF symbol table information | |
2526 | Displays the entries in symbol table section of the file, if it has one. | |
2527 | ||
2528 | @item -e | |
2529 | @itemx --headers | |
2530 | Display all the headers in the file. Equivalent to @samp{-h -l -S}. | |
2531 | ||
779fe533 NC |
2532 | @item -n |
2533 | @itemx --notes | |
2534 | @cindex ELF core notes | |
2535 | Displays the contents of the NOTE segment, if it exists. | |
2536 | ||
252b5132 RH |
2537 | @item -r |
2538 | @itemx --relocs | |
2539 | @cindex ELF reloc information | |
2540 | Displays the contents of the file's relocation section, if it ha one. | |
2541 | ||
2542 | @item -d | |
2543 | @itemx --dynamic | |
2544 | @cindex ELF dynamic section information | |
2545 | Displays the contents of the file's dynamic section, if it has one. | |
2546 | ||
2547 | @item -V | |
2548 | @itemx --version-info | |
2549 | @cindex ELF version sections informations | |
2550 | Displays the contents of the version sections in the file, it they | |
2551 | exist. | |
2552 | ||
2553 | @item -D | |
2554 | @itemx --use-dynamic | |
2555 | When displaying symbols, this option makes @code{readelf} use the | |
6dbb55b6 | 2556 | symbol table in the file's dynamic section, rather than the one in the |
252b5132 RH |
2557 | symbols section. |
2558 | ||
2559 | @item -x <number> | |
2560 | @itemx --hex-dump=<number> | |
2561 | Displays the contents of the indicated section as a hexadecimal dump. | |
2562 | ||
2563 | @item -w[liapr] | |
2564 | @itemx --debug-dump[=line,=info,=abbrev,=pubnames,=ranges] | |
2565 | Displays the contents of the debug sections in the file, if any are | |
2566 | present. If one of the optional letters or words follows the switch | |
2567 | then only data found in those specific sections will be dumped. | |
2568 | ||
2569 | @item --histogram | |
2570 | Display a histogram of bucket list lengths when displaying the contents | |
2571 | of the symbol tables. | |
2572 | ||
2573 | @item -v | |
2574 | @itemx --version | |
2575 | Display the version number of readelf. | |
2576 | ||
2577 | @item -H | |
2578 | @itemx --help | |
2579 | Display the command line options understood by @code{readelf}. | |
2580 | ||
2581 | @end table | |
2582 | ||
2583 | ||
2584 | @node Selecting The Target System | |
2585 | @chapter Selecting the target system | |
2586 | ||
2587 | You can specify three aspects of the target system to the @sc{gnu} | |
2588 | binary file utilities, each in several ways: | |
2589 | ||
2590 | @itemize @bullet | |
2591 | @item | |
2592 | the target | |
2593 | ||
2594 | @item | |
2595 | the architecture | |
2596 | ||
2597 | @item | |
2598 | the linker emulation (which applies to the linker only) | |
2599 | @end itemize | |
2600 | ||
2601 | In the following summaries, the lists of ways to specify values are in | |
2602 | order of decreasing precedence. The ways listed first override those | |
2603 | listed later. | |
2604 | ||
2605 | The commands to list valid values only list the values for which the | |
2606 | programs you are running were configured. If they were configured with | |
2607 | @samp{--enable-targets=all}, the commands list most of the available | |
2608 | values, but a few are left out; not all targets can be configured in at | |
2609 | once because some of them can only be configured @dfn{native} (on hosts | |
2610 | with the same type as the target system). | |
2611 | ||
2612 | @menu | |
2613 | * Target Selection:: | |
2614 | * Architecture Selection:: | |
2615 | * Linker Emulation Selection:: | |
2616 | @end menu | |
2617 | ||
2618 | @node Target Selection | |
2619 | @section Target Selection | |
2620 | ||
2621 | A @dfn{target} is an object file format. A given target may be | |
2622 | supported for multiple architectures (@pxref{Architecture Selection}). | |
2623 | A target selection may also have variations for different operating | |
2624 | systems or architectures. | |
2625 | ||
2626 | The command to list valid target values is @samp{objdump -i} | |
2627 | (the first column of output contains the relevant information). | |
2628 | ||
2629 | Some sample values are: @samp{a.out-hp300bsd}, @samp{ecoff-littlemips}, | |
2630 | @samp{a.out-sunos-big}. | |
2631 | ||
2632 | You can also specify a target using a configuration triplet. This is | |
f20a759a ILT |
2633 | the same sort of name that is passed to @file{configure} to specify a |
2634 | target. When you use a configuration triplet as an argument, it must be | |
2635 | fully canonicalized. You can see the canonical version of a triplet by | |
252b5132 RH |
2636 | running the shell script @file{config.sub} which is included with the |
2637 | sources. | |
2638 | ||
2639 | Some sample configuration triplets are: @samp{m68k-hp-bsd}, | |
2640 | @samp{mips-dec-ultrix}, @samp{sparc-sun-sunos}. | |
2641 | ||
2642 | @subheading @code{objdump} Target | |
2643 | ||
2644 | Ways to specify: | |
2645 | ||
2646 | @enumerate | |
2647 | @item | |
2648 | command line option: @samp{-b} or @samp{--target} | |
2649 | ||
2650 | @item | |
2651 | environment variable @code{GNUTARGET} | |
2652 | ||
2653 | @item | |
2654 | deduced from the input file | |
2655 | @end enumerate | |
2656 | ||
2657 | @subheading @code{objcopy} and @code{strip} Input Target | |
2658 | ||
2659 | Ways to specify: | |
2660 | ||
2661 | @enumerate | |
2662 | @item | |
2663 | command line options: @samp{-I} or @samp{--input-target}, or @samp{-F} or @samp{--target} | |
2664 | ||
2665 | @item | |
2666 | environment variable @code{GNUTARGET} | |
2667 | ||
2668 | @item | |
2669 | deduced from the input file | |
2670 | @end enumerate | |
2671 | ||
2672 | @subheading @code{objcopy} and @code{strip} Output Target | |
2673 | ||
2674 | Ways to specify: | |
2675 | ||
2676 | @enumerate | |
2677 | @item | |
2678 | command line options: @samp{-O} or @samp{--output-target}, or @samp{-F} or @samp{--target} | |
2679 | ||
2680 | @item | |
2681 | the input target (see ``@code{objcopy} and @code{strip} Input Target'' above) | |
2682 | ||
2683 | @item | |
2684 | environment variable @code{GNUTARGET} | |
2685 | ||
2686 | @item | |
2687 | deduced from the input file | |
2688 | @end enumerate | |
2689 | ||
2690 | @subheading @code{nm}, @code{size}, and @code{strings} Target | |
2691 | ||
2692 | Ways to specify: | |
2693 | ||
2694 | @enumerate | |
2695 | @item | |
2696 | command line option: @samp{--target} | |
2697 | ||
2698 | @item | |
2699 | environment variable @code{GNUTARGET} | |
2700 | ||
2701 | @item | |
2702 | deduced from the input file | |
2703 | @end enumerate | |
2704 | ||
2705 | @subheading Linker Input Target | |
2706 | ||
2707 | Ways to specify: | |
2708 | ||
2709 | @enumerate | |
2710 | @item | |
2711 | command line option: @samp{-b} or @samp{--format} | |
2712 | (@pxref{Options,,Options,ld.info,Using LD}) | |
2713 | ||
2714 | @item | |
2715 | script command @code{TARGET} | |
2716 | (@pxref{Option Commands,,Option Commands,ld.info,Using LD}) | |
2717 | ||
2718 | @item | |
2719 | environment variable @code{GNUTARGET} | |
2720 | (@pxref{Environment,,Environment,ld.info,Using LD}) | |
2721 | ||
2722 | @item | |
2723 | the default target of the selected linker emulation | |
2724 | (@pxref{Linker Emulation Selection}) | |
2725 | @end enumerate | |
2726 | ||
2727 | @subheading Linker Output Target | |
2728 | ||
2729 | Ways to specify: | |
2730 | ||
2731 | @enumerate | |
2732 | @item | |
2733 | command line option: @samp{-oformat} | |
2734 | (@pxref{Options,,Options,ld.info,Using LD}) | |
2735 | ||
2736 | @item | |
2737 | script command @code{OUTPUT_FORMAT} | |
2738 | (@pxref{Option Commands,,Option Commands,ld.info,Using LD}) | |
2739 | ||
2740 | @item | |
2741 | the linker input target (see ``Linker Input Target'' above) | |
2742 | @end enumerate | |
2743 | ||
2744 | @node Architecture Selection | |
2745 | @section Architecture selection | |
2746 | ||
2747 | An @dfn{architecture} is a type of @sc{cpu} on which an object file is | |
2748 | to run. Its name may contain a colon, separating the name of the | |
2749 | processor family from the name of the particular @sc{cpu}. | |
2750 | ||
2751 | The command to list valid architecture values is @samp{objdump -i} (the | |
2752 | second column contains the relevant information). | |
2753 | ||
2754 | Sample values: @samp{m68k:68020}, @samp{mips:3000}, @samp{sparc}. | |
2755 | ||
2756 | @subheading @code{objdump} Architecture | |
2757 | ||
2758 | Ways to specify: | |
2759 | ||
2760 | @enumerate | |
2761 | @item | |
2762 | command line option: @samp{-m} or @samp{--architecture} | |
2763 | ||
2764 | @item | |
2765 | deduced from the input file | |
2766 | @end enumerate | |
2767 | ||
2768 | @subheading @code{objcopy}, @code{nm}, @code{size}, @code{strings} Architecture | |
2769 | ||
2770 | Ways to specify: | |
2771 | ||
2772 | @enumerate | |
2773 | @item | |
2774 | deduced from the input file | |
2775 | @end enumerate | |
2776 | ||
2777 | @subheading Linker Input Architecture | |
2778 | ||
2779 | Ways to specify: | |
2780 | ||
2781 | @enumerate | |
2782 | @item | |
2783 | deduced from the input file | |
2784 | @end enumerate | |
2785 | ||
2786 | @subheading Linker Output Architecture | |
2787 | ||
2788 | Ways to specify: | |
2789 | ||
2790 | @enumerate | |
2791 | @item | |
2792 | script command @code{OUTPUT_ARCH} | |
2793 | (@pxref{Option Commands,,Option Commands,ld.info,Using LD}) | |
2794 | ||
2795 | @item | |
2796 | the default architecture from the linker output target | |
2797 | (@pxref{Target Selection}) | |
2798 | @end enumerate | |
2799 | ||
2800 | @node Linker Emulation Selection | |
2801 | @section Linker emulation selection | |
2802 | ||
2803 | A linker @dfn{emulation} is a ``personality'' of the linker, which gives | |
2804 | the linker default values for the other aspects of the target system. | |
2805 | In particular, it consists of | |
2806 | ||
2807 | @itemize @bullet | |
2808 | @item | |
2809 | the linker script | |
2810 | ||
2811 | @item | |
2812 | the target | |
2813 | ||
2814 | @item | |
2815 | several ``hook'' functions that are run at certain stages of the linking | |
2816 | process to do special things that some targets require | |
2817 | @end itemize | |
2818 | ||
2819 | The command to list valid linker emulation values is @samp{ld -V}. | |
2820 | ||
2821 | Sample values: @samp{hp300bsd}, @samp{mipslit}, @samp{sun4}. | |
2822 | ||
2823 | Ways to specify: | |
2824 | ||
2825 | @enumerate | |
2826 | @item | |
2827 | command line option: @samp{-m} | |
2828 | (@pxref{Options,,Options,ld.info,Using LD}) | |
2829 | ||
2830 | @item | |
2831 | environment variable @code{LDEMULATION} | |
2832 | ||
2833 | @item | |
2834 | compiled-in @code{DEFAULT_EMULATION} from @file{Makefile}, | |
2835 | which comes from @code{EMUL} in @file{config/@var{target}.mt} | |
2836 | @end enumerate | |
2837 | ||
2838 | @node Reporting Bugs | |
2839 | @chapter Reporting Bugs | |
2840 | @cindex bugs | |
2841 | @cindex reporting bugs | |
2842 | ||
2843 | Your bug reports play an essential role in making the binary utilities | |
2844 | reliable. | |
2845 | ||
2846 | Reporting a bug may help you by bringing a solution to your problem, or | |
2847 | it may not. But in any case the principal function of a bug report is | |
2848 | to help the entire community by making the next version of the binary | |
2849 | utilities work better. Bug reports are your contribution to their | |
2850 | maintenance. | |
2851 | ||
2852 | In order for a bug report to serve its purpose, you must include the | |
2853 | information that enables us to fix the bug. | |
2854 | ||
2855 | @menu | |
2856 | * Bug Criteria:: Have you found a bug? | |
2857 | * Bug Reporting:: How to report bugs | |
2858 | @end menu | |
2859 | ||
2860 | @node Bug Criteria | |
2861 | @section Have you found a bug? | |
2862 | @cindex bug criteria | |
2863 | ||
2864 | If you are not sure whether you have found a bug, here are some guidelines: | |
2865 | ||
2866 | @itemize @bullet | |
2867 | @cindex fatal signal | |
2868 | @cindex crash | |
2869 | @item | |
2870 | If a binary utility gets a fatal signal, for any input whatever, that is | |
2871 | a bug. Reliable utilities never crash. | |
2872 | ||
2873 | @cindex error on valid input | |
2874 | @item | |
2875 | If a binary utility produces an error message for valid input, that is a | |
2876 | bug. | |
2877 | ||
2878 | @item | |
2879 | If you are an experienced user of binary utilities, your suggestions for | |
2880 | improvement are welcome in any case. | |
2881 | @end itemize | |
2882 | ||
2883 | @node Bug Reporting | |
2884 | @section How to report bugs | |
2885 | @cindex bug reports | |
2886 | @cindex bugs, reporting | |
2887 | ||
2888 | A number of companies and individuals offer support for @sc{gnu} | |
2889 | products. If you obtained the binary utilities from a support | |
2890 | organization, we recommend you contact that organization first. | |
2891 | ||
2892 | You can find contact information for many support companies and | |
2893 | individuals in the file @file{etc/SERVICE} in the @sc{gnu} Emacs | |
2894 | distribution. | |
2895 | ||
2896 | In any event, we also recommend that you send bug reports for the binary | |
2897 | utilities to @samp{bug-gnu-utils@@gnu.org}. | |
2898 | ||
2899 | The fundamental principle of reporting bugs usefully is this: | |
2900 | @strong{report all the facts}. If you are not sure whether to state a | |
2901 | fact or leave it out, state it! | |
2902 | ||
2903 | Often people omit facts because they think they know what causes the | |
2904 | problem and assume that some details do not matter. Thus, you might | |
2905 | assume that the name of a file you use in an example does not matter. | |
2906 | Well, probably it does not, but one cannot be sure. Perhaps the bug is | |
2907 | a stray memory reference which happens to fetch from the location where | |
2908 | that pathname is stored in memory; perhaps, if the pathname were | |
2909 | different, the contents of that location would fool the utility into | |
2910 | doing the right thing despite the bug. Play it safe and give a | |
2911 | specific, complete example. That is the easiest thing for you to do, | |
2912 | and the most helpful. | |
2913 | ||
2914 | Keep in mind that the purpose of a bug report is to enable us to fix the bug if | |
2915 | it is new to us. Therefore, always write your bug reports on the assumption | |
2916 | that the bug has not been reported previously. | |
2917 | ||
2918 | Sometimes people give a few sketchy facts and ask, ``Does this ring a | |
2919 | bell?'' Those bug reports are useless, and we urge everyone to | |
2920 | @emph{refuse to respond to them} except to chide the sender to report | |
2921 | bugs properly. | |
2922 | ||
2923 | To enable us to fix the bug, you should include all these things: | |
2924 | ||
2925 | @itemize @bullet | |
2926 | @item | |
2927 | The version of the utility. Each utility announces it if you start it | |
2928 | with the @samp{--version} argument. | |
2929 | ||
2930 | Without this, we will not know whether there is any point in looking for | |
2931 | the bug in the current version of the binary utilities. | |
2932 | ||
2933 | @item | |
2934 | Any patches you may have applied to the source, including any patches | |
2935 | made to the @code{BFD} library. | |
2936 | ||
2937 | @item | |
2938 | The type of machine you are using, and the operating system name and | |
2939 | version number. | |
2940 | ||
2941 | @item | |
2942 | What compiler (and its version) was used to compile the utilities---e.g. | |
2943 | ``@code{gcc-2.7}''. | |
2944 | ||
2945 | @item | |
2946 | The command arguments you gave the utility to observe the bug. To | |
2947 | guarantee you will not omit something important, list them all. A copy | |
2948 | of the Makefile (or the output from make) is sufficient. | |
2949 | ||
2950 | If we were to try to guess the arguments, we would probably guess wrong | |
2951 | and then we might not encounter the bug. | |
2952 | ||
2953 | @item | |
2954 | A complete input file, or set of input files, that will reproduce the | |
2955 | bug. If the utility is reading an object file or files, then it is | |
2956 | generally most helpful to send the actual object files, uuencoded if | |
757acbc5 ILT |
2957 | necessary to get them through the mail system. Note that |
2958 | @samp{bug-gnu-utils@@gnu.org} is a mailing list, so you should avoid | |
2959 | sending very large files to it. Making the files available for | |
2960 | anonymous FTP is OK. | |
252b5132 RH |
2961 | |
2962 | If the source files were produced exclusively using @sc{gnu} programs | |
2963 | (e.g., @code{gcc}, @code{gas}, and/or the @sc{gnu} @code{ld}), then it | |
2964 | may be OK to send the source files rather than the object files. In | |
2965 | this case, be sure to say exactly what version of @code{gcc}, or | |
2966 | whatever, was used to produce the object files. Also say how | |
2967 | @code{gcc}, or whatever, was configured. | |
2968 | ||
2969 | @item | |
2970 | A description of what behavior you observe that you believe is | |
2971 | incorrect. For example, ``It gets a fatal signal.'' | |
2972 | ||
2973 | Of course, if the bug is that the utility gets a fatal signal, then we | |
2974 | will certainly notice it. But if the bug is incorrect output, we might | |
2975 | not notice unless it is glaringly wrong. You might as well not give us | |
2976 | a chance to make a mistake. | |
2977 | ||
2978 | Even if the problem you experience is a fatal signal, you should still | |
f20a759a | 2979 | say so explicitly. Suppose something strange is going on, such as your |
252b5132 RH |
2980 | copy of the utility is out of synch, or you have encountered a bug in |
2981 | the C library on your system. (This has happened!) Your copy might | |
2982 | crash and ours would not. If you told us to expect a crash, then when | |
2983 | ours fails to crash, we would know that the bug was not happening for | |
2984 | us. If you had not told us to expect a crash, then we would not be able | |
2985 | to draw any conclusion from our observations. | |
2986 | ||
2987 | @item | |
2988 | If you wish to suggest changes to the source, send us context diffs, as | |
2989 | generated by @code{diff} with the @samp{-u}, @samp{-c}, or @samp{-p} | |
2990 | option. Always send diffs from the old file to the new file. If you | |
f20a759a ILT |
2991 | wish to discuss something in the @code{ld} source, refer to it by |
2992 | context, not by line number. | |
252b5132 RH |
2993 | |
2994 | The line numbers in our development sources will not match those in your | |
2995 | sources. Your line numbers would convey no useful information to us. | |
2996 | @end itemize | |
2997 | ||
2998 | Here are some things that are not necessary: | |
2999 | ||
3000 | @itemize @bullet | |
3001 | @item | |
3002 | A description of the envelope of the bug. | |
3003 | ||
3004 | Often people who encounter a bug spend a lot of time investigating | |
3005 | which changes to the input file will make the bug go away and which | |
3006 | changes will not affect it. | |
3007 | ||
3008 | This is often time consuming and not very useful, because the way we | |
3009 | will find the bug is by running a single example under the debugger | |
3010 | with breakpoints, not by pure deduction from a series of examples. | |
3011 | We recommend that you save your time for something else. | |
3012 | ||
3013 | Of course, if you can find a simpler example to report @emph{instead} | |
3014 | of the original one, that is a convenience for us. Errors in the | |
3015 | output will be easier to spot, running under the debugger will take | |
3016 | less time, and so on. | |
3017 | ||
3018 | However, simplification is not vital; if you do not want to do this, | |
3019 | report the bug anyway and send us the entire test case you used. | |
3020 | ||
3021 | @item | |
3022 | A patch for the bug. | |
3023 | ||
3024 | A patch for the bug does help us if it is a good one. But do not omit | |
3025 | the necessary information, such as the test case, on the assumption that | |
3026 | a patch is all we need. We might see problems with your patch and decide | |
3027 | to fix the problem another way, or we might not understand it at all. | |
3028 | ||
3029 | Sometimes with programs as complicated as the binary utilities it is | |
3030 | very hard to construct an example that will make the program follow a | |
3031 | certain path through the code. If you do not send us the example, we | |
3032 | will not be able to construct one, so we will not be able to verify that | |
3033 | the bug is fixed. | |
3034 | ||
3035 | And if we cannot understand what bug you are trying to fix, or why your | |
3036 | patch should be an improvement, we will not install it. A test case will | |
3037 | help us to understand. | |
3038 | ||
3039 | @item | |
3040 | A guess about what the bug is or what it depends on. | |
3041 | ||
3042 | Such guesses are usually wrong. Even we cannot guess right about such | |
3043 | things without first using the debugger to find the facts. | |
3044 | @end itemize | |
3045 | ||
3046 | @node Index | |
3047 | @unnumbered Index | |
3048 | ||
3049 | @printindex cp | |
3050 | ||
3051 | @contents | |
3052 | @bye |