Commit | Line | Data |
---|---|---|
765a273f | 1 | \input texinfo @c -*- Texinfo -*- |
c72af735 RP |
2 | @setfilename binutils.info |
3 | ||
9abcc3b8 RP |
4 | @ifinfo |
5 | @format | |
6 | START-INFO-DIR-ENTRY | |
e31e9a8d JO |
7 | * Binutils: (binutils). The GNU binary utilities "ar", "ld", "copy", |
8 | "objdump", "nm", "size", "strip", and "ranlib". | |
9abcc3b8 RP |
9 | END-INFO-DIR-ENTRY |
10 | @end format | |
11 | @end ifinfo | |
c72af735 | 12 | |
8b2c2275 RP |
13 | @ifinfo |
14 | Copyright @copyright{} 1991 Free Software Foundation, Inc. | |
15 | ||
16 | Permission is granted to make and distribute verbatim copies of | |
17 | this manual provided the copyright notice and this permission notice | |
18 | are preserved on all copies. | |
19 | ||
20 | @ignore | |
21 | Permission is granted to process this file through TeX and print the | |
22 | results, provided the printed document carries a copying permission | |
23 | notice identical to this one except for the removal of this paragraph | |
24 | (this paragraph not being relevant to the printed manual). | |
25 | ||
26 | @end ignore | |
27 | ||
28 | Permission is granted to copy and distribute modified versions of this | |
29 | manual under the conditions for verbatim copying, provided also that | |
30 | the entire resulting derived work is distributed under the terms of a | |
31 | permission notice identical to this one. | |
32 | ||
33 | Permission is granted to copy and distribute translations of this manual | |
34 | into another language, under the above conditions for modified versions. | |
35 | @end ifinfo | |
36 | ||
c72af735 RP |
37 | @synindex ky cp |
38 | @c | |
e31e9a8d JO |
39 | @c This file documents the GNU binary utilities "ar", "ld", "copy", "objdump", |
40 | @c "nm", "size", "strip", and "ranlib". | |
c72af735 RP |
41 | @c |
42 | @c Copyright (C) 1991 Free Software Foundation, Inc. | |
43 | @c | |
44 | @c This text may be freely distributed under the terms of the GNU | |
45 | @c General Public License. | |
46 | @c | |
27e94bd5 | 47 | |
c72af735 RP |
48 | @setchapternewpage odd |
49 | @settitle GNU Binary Utilities | |
27e94bd5 RP |
50 | @c @smallbook |
51 | @c @cropmarks | |
4928b97b RP |
52 | @titlepage |
53 | @finalout | |
c72af735 | 54 | @title The GNU Binary Utilities |
da52f26b | 55 | @subtitle Version 1.97 |
c72af735 RP |
56 | @sp 1 |
57 | @subtitle October 1991 | |
58 | @author Roland H. Pesch | |
59 | @author Cygnus Support | |
60 | @page | |
61 | ||
62 | @tex | |
63 | \def\$#1${{#1}} % Kluge: collect RCS revision info without $...$ | |
64 | \xdef\manvers{\$Revision$} % For use in headers, footers too | |
65 | {\parskip=0pt \hfill Cygnus Support\par \hfill \manvers\par \hfill | |
66 | \TeX{}info \texinfoversion\par } | |
67 | @end tex | |
68 | ||
69 | @vskip 0pt plus 1filll | |
70 | Copyright @copyright{} 1991 Free Software Foundation, Inc. | |
71 | ||
72 | Permission is granted to make and distribute verbatim copies of | |
73 | this manual provided the copyright notice and this permission notice | |
74 | are preserved on all copies. | |
75 | ||
76 | Permission is granted to copy and distribute modified versions of this | |
77 | manual under the conditions for verbatim copying, provided also that | |
78 | the entire resulting derived work is distributed under the terms of a | |
79 | permission notice identical to this one. | |
80 | ||
81 | Permission is granted to copy and distribute translations of this manual | |
82 | into another language, under the above conditions for modified versions. | |
83 | @end titlepage | |
84 | ||
85 | @node Top, ar, (dir), (dir) | |
86 | @chapter Introduction | |
87 | ||
88 | @cindex version | |
89 | This brief manual contains preliminary documentation for the GNU binary | |
ec40bbb8 | 90 | utilities (collectively version 2.1): |
8b2c2275 RP |
91 | |
92 | @iftex | |
c72af735 RP |
93 | @table @code |
94 | @item ar | |
95 | Create, modify, and extract from archives | |
96 | ||
e31e9a8d JO |
97 | @item copy |
98 | Copy and translate object files | |
99 | ||
c72af735 RP |
100 | @item nm |
101 | List symbols from object files | |
102 | ||
103 | @item objdump | |
104 | Display information from object files | |
105 | ||
106 | @item ranlib | |
107 | Generate index to archive contents | |
108 | ||
109 | @item size | |
110 | List section sizes and total size | |
111 | ||
112 | @item strip | |
113 | Discard symbols | |
114 | @end table | |
8b2c2275 | 115 | @end iftex |
c72af735 RP |
116 | |
117 | @menu | |
8b2c2275 | 118 | * ar:: Create, modify, and extract from archives |
e31e9a8d | 119 | * copy:: Copy and translate object files |
8b2c2275 RP |
120 | * ld:(ld)Overview. Combine object and archive files |
121 | * nm:: List symbols from object files | |
122 | * objdump:: Display information from object files | |
123 | * ranlib:: Generate index to archive contents | |
124 | * size:: List section sizes and total size | |
125 | * strip:: Discard symbols | |
126 | * Index:: | |
c72af735 RP |
127 | @end menu |
128 | ||
e31e9a8d | 129 | @node ar, copy, Top, Top |
c72af735 RP |
130 | @chapter ar |
131 | ||
132 | @kindex ar | |
133 | @cindex archives | |
134 | @cindex collections of files | |
135 | @smallexample | |
b703c078 | 136 | ar [-]@var{p}@var{mod} [ @var{membername} ] @var{archive} @var{file}@dots{} |
765a273f | 137 | ar -M [ <mri-script ] |
c72af735 RP |
138 | @end smallexample |
139 | ||
140 | The GNU @code{ar} program creates, modifies, and extracts from | |
141 | archives. An @dfn{archive} is a single file holding a collection of | |
142 | other files in a structure that makes it possible to retrieve | |
143 | the original individual files (called @dfn{members} of the archive). | |
144 | ||
145 | The original files' contents, mode (permissions), timestamp, owner, and | |
ec40bbb8 | 146 | group are preserved in the archive, and can be restored on |
c72af735 RP |
147 | extraction. |
148 | ||
149 | @cindex name length | |
150 | GNU @code{ar} can maintain archives whose members have names of any | |
151 | length; however, depending on how @code{ar} is configured on your | |
ec40bbb8 DM |
152 | system, a limit on member-name length may be imposed for compatibility |
153 | with archive formats maintained with other tools. If it exists, the | |
c72af735 RP |
154 | limit is often 15 characters (typical of formats related to a.out) or 16 |
155 | characters (typical of formats related to coff). | |
156 | ||
157 | @cindex libraries | |
158 | @code{ar} is considered a binary utility because archives of this sort | |
159 | are most often used as @dfn{libraries} holding commonly needed | |
160 | subroutines. | |
161 | ||
162 | @cindex symbol index | |
e31e9a8d | 163 | @code{ar} creates an index to the symbols defined in relocatable |
c72af735 RP |
164 | object modules in the archive when you specify the modifier @samp{s}. |
165 | Once created, this index is updated in the archive whenever @code{ar} | |
166 | makes a change to its contents (save for the @samp{q} update operation). | |
167 | An archive with such an index speeds up linking to the library, and | |
168 | allows routines in the library to call each other without regard to | |
169 | their placement in the archive. | |
170 | ||
918c2f61 | 171 | You may use @samp{nm -s} or @samp{nm --print-armap} to list this index |
c72af735 RP |
172 | table. If an archive lacks the table, another form of @code{ar} called |
173 | @code{ranlib} can be used to add just the table. | |
174 | ||
765a273f RP |
175 | @cindex compatibility, @code{ar} |
176 | @cindex @code{ar} compatibility | |
177 | GNU @code{ar} is designed to be compatible with two different | |
178 | facilities. You can control its activity using command-line options, | |
179 | like the different varieties of @code{ar} on Unix systems; or, if you | |
180 | specify the single command-line option @samp{-M}, you can control it | |
181 | with a script supplied via standard input, like the MRI ``librarian'' | |
182 | program. | |
183 | ||
184 | @menu | |
185 | * ar-cmdline:: Controlling @code{ar} on the command line | |
186 | * ar-scripts:: Controlling @code{ar} with a script | |
187 | @end menu | |
188 | ||
189 | @page | |
190 | @node ar-cmdline, ar-scripts, ar, ar | |
191 | @section Controlling @code{ar} on the command line | |
192 | ||
193 | @smallexample | |
b703c078 | 194 | ar [-]@var{p}@var{mod} [ @var{membername} ] @var{archive} @var{file}@dots{} |
765a273f RP |
195 | @end smallexample |
196 | ||
197 | @cindex Unix compatibility, @code{ar} | |
198 | When you use @code{ar} in the Unix style, @code{ar} insists on at least two | |
199 | arguments to execute: one keyletter specifying the @emph{operation} | |
200 | (optionally accompanied by other keyletters specifying | |
201 | @emph{modifiers}), and the archive name to act on. | |
c72af735 | 202 | |
ec40bbb8 | 203 | Most operations can also accept further @var{file} arguments, |
c72af735 RP |
204 | specifying particular files to operate on. |
205 | ||
206 | GNU @code{ar} allows you to mix the operation code @var{p} and modifier | |
207 | flags @var{mod} in any order, within the first command-line argument. | |
208 | ||
209 | If you wish, you may begin the first command-line argument with a | |
210 | dash. | |
211 | ||
212 | @cindex operations on archive | |
213 | The @var{p} keyletter specifies what operation to execute; it may be | |
214 | any of the following, but you must specify only one of them: | |
215 | ||
216 | @table @code | |
217 | @item d | |
218 | @cindex deleting from archive | |
219 | @emph{Delete} modules from the archive. Specify the names of modules to | |
b703c078 | 220 | be deleted as @var{file}@dots{}; the archive is untouched if you |
c72af735 RP |
221 | specify no files to delete. |
222 | ||
e31e9a8d | 223 | If you specify the @samp{v} modifier, @code{ar} lists each module |
c72af735 RP |
224 | as it is deleted. |
225 | ||
226 | @item m | |
227 | @cindex moving in archive | |
228 | Use this operation to @emph{move} members in an archive. | |
229 | ||
230 | The ordering of members in an archive can make a difference in how | |
231 | programs are linked using the library, if a symbol is defined in more | |
232 | than one member. | |
233 | ||
234 | If no modifiers are used with @code{m}, any members you name in the | |
ec40bbb8 | 235 | @var{file} arguments are moved to the @emph{end} of the archive; |
c72af735 RP |
236 | you can use the @samp{a}, @samp{b}, or @samp{i} modifiers to move them to a |
237 | specified place instead. | |
238 | ||
239 | @item p | |
240 | @cindex printing from archive | |
241 | @emph{Print} the specified members of the archive, to the standard | |
242 | output file. If the @samp{v} modifier is specified, show the member | |
243 | name before copying its contents to standard output. | |
244 | ||
ec40bbb8 DM |
245 | If you specify no @var{file} arguments, all the files in the archive are |
246 | printed. | |
c72af735 RP |
247 | |
248 | @item q | |
249 | @cindex quick append to archive | |
b703c078 | 250 | @emph{Quick append}; add the files @var{file}@dots{} to the end of |
ec40bbb8 | 251 | @var{archive}, without checking for replacement. |
c72af735 RP |
252 | |
253 | The modifiers @samp{a}, @samp{b}, and @samp{i} do @emph{not} affect this | |
254 | operation; new members are always placed at the end of the archive. | |
255 | ||
256 | The modifier @samp{v} makes @code{ar} list each file as it is appended. | |
257 | ||
258 | Since the point of this operation is speed, the archive's symbol table | |
259 | index is not updated, even if it already existed; you can use @samp{ar s} or | |
260 | @code{ranlib} explicitly to update the symbol table index. | |
261 | ||
262 | @item r | |
263 | @cindex replacement in archive | |
b703c078 | 264 | Insert the files @var{file}@dots{} into @var{archive} (with |
ec40bbb8 DM |
265 | @emph{replacement}). This operation differs from @samp{q} in that any |
266 | previously existing members are deleted if their names match those being | |
267 | added. | |
c72af735 | 268 | |
b703c078 | 269 | If one of the files named in @var{file}@dots{} doesn't exist, @code{ar} |
c72af735 RP |
270 | displays an error message, and leaves undisturbed any existing members |
271 | of the archive matching that name. | |
272 | ||
273 | By default, new members are added at the end of the file; but you may | |
274 | use one of the modifiers @samp{a}, @samp{b}, or @samp{i} to request | |
275 | placement relative to some existing member. | |
276 | ||
277 | The modifier @samp{v} used with this operation elicits a line of | |
278 | output for each file inserted, along with one of the letters @samp{a} or | |
279 | @samp{r} to indicate whether the file was appended (no old member | |
280 | deleted) or replaced. | |
281 | ||
282 | @item t | |
283 | @cindex contents of archive | |
284 | Display a @emph{table} listing the contents of @var{archive}, or those | |
b703c078 | 285 | of the files listed in @var{file}@dots{} that are present in the |
c72af735 RP |
286 | archive. Normally only the member name is shown; if you also want to |
287 | see the modes (permissions), timestamp, owner, group, and size, you can | |
288 | request that by also specifying the @samp{v} modifier. | |
289 | ||
ec40bbb8 | 290 | If you do not specify a @var{file}, all files in the archive |
c72af735 RP |
291 | are listed. |
292 | ||
293 | @cindex repeated names in archive | |
294 | @cindex name duplication in archive | |
295 | If there is more than one file with the same name (say, @samp{fie}) in | |
e31e9a8d | 296 | an archive (say @samp{b.a}), @samp{ar t b.a fie} lists only the |
c72af735 RP |
297 | first instance; to see them all, you must ask for a complete |
298 | listing---in our example, @samp{ar t b.a}. | |
299 | @c WRS only; per Gumby, this is implementation-dependent, and in a more | |
300 | @c recent case in fact works the other way. | |
301 | ||
302 | @item x | |
303 | @cindex extract from archive | |
ec40bbb8 | 304 | @emph{Extract} members (named @var{file}) from the archive. You can |
c72af735 RP |
305 | use the @samp{v} modifier with this operation, to request that |
306 | @code{ar} list each name as it extracts it. | |
307 | ||
ec40bbb8 | 308 | If you do not specify a @var{file}, all files in the archive |
c72af735 RP |
309 | are extracted. |
310 | ||
311 | @end table | |
312 | ||
313 | A number of modifiers (@var{mod}) may immediately follow the @var{p} | |
314 | keyletter, to specify variations on an operation's behavior: | |
315 | ||
316 | @table @code | |
317 | @item a | |
318 | @cindex relative placement in archive | |
319 | Add new files @emph{after} an existing member of the | |
ec40bbb8 | 320 | archive. If you use the modifier @samp{a}, the name of an existing archive |
c72af735 RP |
321 | member must be present as the @var{membername} argument, before the |
322 | @var{archive} specification. | |
323 | ||
324 | @item b | |
325 | Add new files @emph{before} an existing member of the | |
ec40bbb8 | 326 | archive. If you use the modifier @samp{b}, the name of an existing archive |
c72af735 RP |
327 | member must be present as the @var{membername} argument, before the |
328 | @var{archive} specification. (same as @samp{i}). | |
329 | ||
330 | @item c | |
331 | @cindex creating archives | |
332 | @emph{Create} the archive. The specified @var{archive} is always | |
333 | created if it didn't exist, when you request an update. But a warning is | |
334 | issued unless you specify in advance that you expect to create it, by | |
335 | using this modifier. | |
336 | ||
337 | @item i | |
338 | Insert new files @emph{before} an existing member of the | |
ec40bbb8 | 339 | archive. If you use the modifier @samp{i}, the name of an existing archive |
c72af735 RP |
340 | member must be present as the @var{membername} argument, before the |
341 | @var{archive} specification. (same as @samp{b}). | |
342 | ||
343 | @item l | |
344 | This modifier is accepted but not used. | |
345 | @c whaffor ar l modifier??? presumably compat; with | |
346 | @c what???---pesch@@cygnus.com, 25jan91 | |
347 | ||
348 | @item o | |
349 | @cindex dates in archive | |
350 | Preserve the @emph{original} dates of members when extracting them. If | |
351 | you do not specify this modifier, files extracted from the archive | |
e31e9a8d | 352 | are stamped with the time of extraction. |
c72af735 RP |
353 | |
354 | @item s | |
355 | @cindex writing archive index | |
356 | Write an object-file index into the archive, or update an existing one, | |
357 | even if no other change is made to the archive. You may use this modifier | |
358 | flag either with any operation, or alone. Running @samp{ar s} on an | |
359 | archive is equivalent to running @samp{ranlib} on it. | |
360 | ||
361 | @item u | |
362 | @cindex updating an archive | |
b703c078 | 363 | Normally, @samp{ar r}@dots{} inserts all files |
c72af735 RP |
364 | listed into the archive. If you would like to insert @emph{only} those |
365 | of the files you list that are newer than existing members of the same | |
366 | names, use this modifier. The @samp{u} modifier is allowed only for the | |
367 | operation @samp{r} (replace). In particular, the combination @samp{qu} is | |
368 | not allowed, since checking the timestamps would lose any speed | |
369 | advantage from the operation @samp{q}. | |
370 | ||
371 | @item v | |
372 | This modifier requests the @emph{verbose} version of an operation. Many | |
373 | operations display additional information, such as filenames processed, | |
374 | when the modifier @samp{v} is appended. | |
765a273f RP |
375 | @end table |
376 | ||
377 | @node ar-scripts, , ar-cmdline, ar | |
378 | @section Controlling @code{ar} with a script | |
379 | ||
380 | @smallexample | |
381 | ar -M [ <@var{script} ] | |
382 | @end smallexample | |
383 | ||
384 | @cindex MRI compatibility, @code{ar} | |
385 | @cindex scripts, @code{ar} | |
386 | If you use the single command-line option @samp{-M} with @code{ar}, you | |
387 | can control its operation with a rudimentary command language. This | |
e31e9a8d | 388 | form of @code{ar} operates interactively if standard input is coming |
765a273f RP |
389 | directly from a terminal. During interactive use, @code{ar} prompts for |
390 | input (the prompt is @samp{AR >}), and continues executing even after | |
391 | errors. If you redirect standard input to a script file, no prompts are | |
e31e9a8d | 392 | issued, and @code{ar} abandons execution (with a nonzero exit code) |
765a273f RP |
393 | on any error. |
394 | ||
395 | The @code{ar} command language is @emph{not} designed to be equivalent | |
396 | to the command-line options; in fact, it provides somewhat less control | |
397 | over archives. The only purpose of the command language is to ease the | |
398 | transition to GNU @code{ar} for developers who already have scripts | |
399 | written for the MRI ``librarian'' program. | |
400 | ||
401 | The syntax for the @code{ar} command language is straightforward: | |
402 | @itemize @bullet | |
403 | @item | |
404 | commands are recognized in upper or lower case; for example, @code{LIST} | |
405 | is the same as @code{list}. In the following descriptions, commands are | |
406 | shown in upper case for clarity. | |
407 | ||
408 | @item | |
409 | a single command may appear on each line; it is the first word on the | |
410 | line. | |
411 | ||
412 | @item | |
413 | empty lines are allowed, and have no effect. | |
414 | ||
415 | @item | |
416 | comments are allowed; text after either of the characters @samp{*} | |
417 | or @samp{;} is ignored. | |
418 | ||
419 | @item | |
420 | Whenever you use a list of names as part of the argument to an @code{ar} | |
421 | command, you can separate the individual names with either commas or | |
422 | blanks. Commas are shown in the explanations below, for clarity. | |
423 | ||
424 | @item | |
425 | @samp{+} is used as a line continuation character; if @samp{+} appears | |
426 | at the end of a line, the text on the following line is considered part | |
427 | of the current command. | |
428 | @end itemize | |
429 | ||
430 | Here are the commands you can use in @code{ar} scripts, or when using | |
431 | @code{ar} interactively. Three of them have special significance: | |
432 | ||
433 | @code{OPEN} or @code{CREATE} specify a @dfn{current archive}, which is | |
434 | a temporary file required for most of the other commands. | |
435 | ||
436 | @code{SAVE} commits the changes so far specified by the script. Prior | |
437 | to @code{SAVE}, commands affect only the temporary copy of the current | |
438 | archive. | |
439 | ||
440 | @table @code | |
441 | @item ADDLIB @var{archive} | |
442 | @itemx ADDLIB @var{archive} (@var{module}, @var{module}, @dots{} @var{module}) | |
443 | Add all the contents of @var{archive} (or, if specified, each named | |
444 | @var{module} from @var{archive}) to the current archive. | |
445 | ||
446 | Requires prior use of @code{OPEN} or @code{CREATE}. | |
447 | ||
448 | @item ADDMOD @var{file}, @var{file}, @dots{} @var{file} | |
449 | @c FIXME! w/Replacement?? If so, like "ar r @var{archive} @var{names}" | |
450 | @c else like "ar q..." | |
451 | Add each named @var{file} as a module in the current archive. | |
452 | ||
453 | Requires prior use of @code{OPEN} or @code{CREATE}. | |
454 | ||
455 | @item CLEAR | |
456 | Discard the contents of the current archive, cancelling the effect of | |
457 | any operations since the last @code{SAVE}. May be executed (with no | |
458 | effect) even if no current archive is specified. | |
459 | ||
460 | @item CREATE @var{archive} | |
461 | Creates an archive, and makes it the current archive (required for many | |
462 | other commands). The new archive is created with a temporary name; it | |
463 | is not actually saved as @var{archive} until you use @code{SAVE}. | |
464 | You can overwrite existing archives; similarly, the contents of any | |
465 | existing file named @var{archive} will not be destroyed until @code{SAVE}. | |
466 | ||
467 | @item DELETE @var{module}, @var{module}, @dots{} @var{module} | |
468 | Delete each listed @var{module} from the current archive; equivalent to | |
469 | @samp{ar -d @var{archive} @var{module} @dots{} @var{module}}. | |
470 | ||
471 | Requires prior use of @code{OPEN} or @code{CREATE}. | |
472 | ||
473 | @item DIRECTORY @var{archive} (@var{module}, @dots{} @var{module}) | |
474 | @itemx DIRECTORY @var{archive} (@var{module}, @dots{} @var{module}) @var{outputfile} | |
475 | List each named @var{module} present in @var{archive}. The separate | |
476 | command @code{VERBOSE} specifies the form of the output: when verbose | |
477 | output is off, output is like that of @samp{ar -t @var{archive} | |
b703c078 DM |
478 | @var{module}@dots{}}. When verbose output is on, the listing is like |
479 | @samp{ar -tv @var{archive} @var{module}@dots{}}. | |
765a273f RP |
480 | |
481 | Output normally goes to the standard output stream; however, if you | |
482 | specify @var{outputfile} as a final argument, @code{ar} directs the | |
483 | output to that file. | |
484 | ||
485 | @item END | |
486 | Exit from @code{ar}, with a @code{0} exit code to indicate successful | |
487 | completion. This command does not save the output file; if you have | |
488 | changed the current archive since the last @code{SAVE} command, those | |
489 | changes are lost. | |
490 | ||
491 | @item EXTRACT @var{module}, @var{module}, @dots{} @var{module} | |
492 | Extract each named @var{module} from the current archive, writing them | |
493 | into the current directory as separate files. Equivalent to @samp{ar -x | |
b703c078 | 494 | @var{archive} @var{module}@dots{}}. |
765a273f RP |
495 | |
496 | Requires prior use of @code{OPEN} or @code{CREATE}. | |
497 | ||
498 | @ignore | |
499 | @c FIXME Tokens but no commands??? | |
500 | @item FULLDIR | |
501 | ||
502 | @item HELP | |
503 | @end ignore | |
504 | ||
505 | @item LIST | |
506 | Display full contents of the current archive, in ``verbose'' style | |
507 | regardless of the state of @code{VERBOSE}. The effect is like @samp{ar | |
508 | tv @var{archive}}). (This single command is a GNU @code{ld} | |
509 | enhancement, rather than present for MRI compatibility.) | |
510 | ||
511 | Requires prior use of @code{OPEN} or @code{CREATE}. | |
512 | ||
513 | @item OPEN @var{archive} | |
514 | Opens an existing archive for use as the current archive (required for | |
515 | many other commands). Any changes as the result of subsequent commands | |
516 | will not actually affect @var{archive} until you next use @code{SAVE}. | |
517 | ||
518 | @item REPLACE @var{module}, @var{module}, @dots{} @var{module} | |
519 | In the current archive, replace each existing @var{module} (named in | |
520 | the @code{REPLACE} arguments) from files in the current working directory. | |
521 | To execute this command without errors, both the file, and the module in | |
522 | the current archive, must exist. | |
523 | ||
524 | Requires prior use of @code{OPEN} or @code{CREATE}. | |
525 | ||
526 | @item VERBOSE | |
527 | Toggle an internal flag governing the output from @code{DIRECTORY}. | |
528 | When the flag is on, @code{DIRECTORY} output matches output from | |
b703c078 | 529 | @samp{ar -tv }@dots{}. |
765a273f RP |
530 | |
531 | @item SAVE | |
532 | Commit your changes to the current archive, and actually save it as a | |
533 | file with the name specified in the last @code{CREATE} or @code{OPEN} | |
534 | command. | |
535 | ||
536 | Requires prior use of @code{OPEN} or @code{CREATE}. | |
c72af735 RP |
537 | |
538 | @end table | |
539 | ||
e31e9a8d | 540 | @node copy, nm, ar, Top |
e31e9a8d JO |
541 | @chapter copy |
542 | ||
543 | @smallexample | |
918c2f61 PB |
544 | copy [ -F @var{format} | --format=@var{format} ] |
545 | [ -I @var{format} | --input-format=@var{format} ] | |
546 | [ -O @var{format} | --output-format=@var{format} ] | |
547 | [ -S | --strip-all ] [ -g | --strip-debug ] | |
548 | [ -x | --discard-all ] [ -X | --discard-locals ] | |
549 | [ -v | --verbose ] [ -V | --version ] | |
550 | @var{infile} [@var{outfile}] | |
e31e9a8d JO |
551 | @end smallexample |
552 | ||
918c2f61 PB |
553 | The GNU @code{copy} utility copies the contents of an object file to |
554 | another. @code{copy} uses the GNU BFD Library to read and write the | |
555 | object files. It can write the destination object file in a format | |
556 | different from that of the source object file. The exact behavior of | |
557 | @code{copy} is controlled by command-line options. | |
e31e9a8d JO |
558 | |
559 | @code{copy} creates temporary files to do its translations and | |
918c2f61 | 560 | deletes them afterward. @code{copy} uses BFD to do all its |
e31e9a8d JO |
561 | translation work; it knows about all the formats BFD knows about, and |
562 | thus is able to recognize most formats without being told explicitly. | |
563 | @xref{BFD,,BFD,ld.info,Using LD, the GNU linker}. | |
564 | ||
565 | @table @code | |
918c2f61 PB |
566 | @item @var{infile} |
567 | @itemx @var{outfile} | |
568 | The source and output files respectively. | |
569 | If you do not specify @var{outfile}, @code{copy} creates a | |
570 | temporary file and destructively renames the result with | |
571 | the name of the input file. | |
572 | ||
573 | @item -I @var{format} | |
574 | @itemx --input-format=@var{format} | |
ec40bbb8 | 575 | Consider the source file's object format to be @var{format}, rather than |
918c2f61 PB |
576 | attempting to deduce it. |
577 | ||
578 | @item -O @var{format} | |
579 | @itemx --output-format=@var{format} | |
ec40bbb8 | 580 | Write the output file using the object format @var{format}. |
918c2f61 PB |
581 | |
582 | @item -F @var{format} | |
583 | @itemx --format=@var{format} | |
584 | Use @var{format} as the object format for both the input and the output | |
585 | file; i.e. simply transfer data from source to destination with no | |
586 | translation. | |
e31e9a8d | 587 | |
918c2f61 PB |
588 | @item -S |
589 | @itemx --strip-all | |
590 | Do not copy relocation and symbol information from the source file. | |
e31e9a8d | 591 | |
918c2f61 PB |
592 | @item -g |
593 | @itemx --strip-debug | |
594 | Do not copy debugging symbols from the source file. | |
e31e9a8d | 595 | |
918c2f61 PB |
596 | @item -x |
597 | @itemx --discard-all | |
598 | Do not copy non-global symbols from the source file. | |
599 | @c FIXME any reason to prefer "non-global" to "local" here? | |
e31e9a8d | 600 | |
918c2f61 PB |
601 | @item -X |
602 | @itemx --discard-locals | |
603 | Do not copy compiler-generated local symbols. | |
604 | (These usually start with @samp{L} or @samp{.}.) | |
e31e9a8d JO |
605 | |
606 | @item -V | |
918c2f61 PB |
607 | @itemx --version |
608 | Show version number. | |
e31e9a8d | 609 | |
918c2f61 PB |
610 | @item -v |
611 | @itemx --verbose | |
612 | Verbose output: list all object files modified. In the case of | |
613 | archives, @samp{copy -V} lists all members of the archive. | |
e31e9a8d JO |
614 | @end table |
615 | ||
8b2c2275 RP |
616 | @iftex |
617 | @node ld | |
c72af735 RP |
618 | @chapter ld |
619 | @cindex linker | |
620 | @kindex ld | |
621 | The GNU linker @code{ld} is now described in a separate manual. | |
27e94bd5 | 622 | @xref{Top,, Overview,, Using LD: the GNU linker}. |
8b2c2275 | 623 | @end iftex |
c72af735 | 624 | |
e31e9a8d | 625 | @node nm, objdump, copy, Top |
c72af735 RP |
626 | @chapter nm |
627 | @cindex symbols | |
628 | @kindex nm | |
629 | ||
630 | @smallexample | |
918c2f61 PB |
631 | nm [ -a | --debug-syms ] [ -g | --extern-only ] |
632 | [ -s | --print-armap ] [ -o | --print-file-name ] | |
633 | [ -n | --numeric-sort ] [ -p | --no-sort ] | |
634 | [ -r | --reverse-sort ] [ -u | --undefined-only ] | |
ec40bbb8 | 635 | [ --target=@var{bfdname} ] |
b703c078 | 636 | [ @var{objfile}@dots{} ] |
c72af735 RP |
637 | @end smallexample |
638 | ||
b703c078 | 639 | GNU @code{nm} lists the symbols from object files @var{objfile}@dots{}. |
c72af735 RP |
640 | |
641 | The long and short forms of options, shown here as alternatives, are | |
642 | equivalent. | |
643 | ||
644 | @table @code | |
b703c078 | 645 | @item @var{objfile}@dots{} |
c72af735 RP |
646 | @kindex a.out |
647 | Object files whose symbols are to be listed. If no object files are | |
648 | listed as arguments, @code{nm} assumes @samp{a.out}. | |
649 | ||
650 | @item -a | |
918c2f61 | 651 | @itemx --debug-syms |
c72af735 RP |
652 | @cindex debugging symbols |
653 | Display debugger-only symbols; normally these are not listed. | |
654 | ||
655 | @item -g | |
918c2f61 | 656 | @itemx --extern-only |
c72af735 RP |
657 | @cindex external symbols |
658 | Display only external symbols. | |
659 | ||
660 | @item -p | |
918c2f61 | 661 | @itemx --no-sort |
c72af735 RP |
662 | @cindex sorting symbols |
663 | Don't bother to sort the symbols in any order; just print them in the | |
664 | order encountered. | |
665 | ||
666 | @item -n | |
918c2f61 | 667 | @itemx --numeric-sort |
ec40bbb8 DM |
668 | Sort symbols numerically by their addresses, rather than alphabetically |
669 | by their names. | |
c72af735 RP |
670 | |
671 | @item -s | |
918c2f61 | 672 | @itemx --print-armap |
c72af735 RP |
673 | @cindex symbol index, listing |
674 | When listing symbols from archive members, include the index: a mapping | |
ec40bbb8 DM |
675 | (stored in the archive by @code{ar} or @code{ranlib}) of which modules |
676 | contain definitions for which names. | |
c72af735 RP |
677 | |
678 | @item -o | |
918c2f61 | 679 | @itemx --print-file-name |
c72af735 RP |
680 | @cindex input file name |
681 | @cindex file name | |
682 | @cindex source file name | |
683 | Precede each symbol by the name of the input file where it was found, | |
684 | rather than identifying the input file once only before all of its | |
685 | symbols. | |
686 | ||
687 | @item -r | |
918c2f61 | 688 | @itemx --reverse-sort |
ec40bbb8 | 689 | Reverse the order of the sort (whether numeric or alphabetic); let the |
c72af735 RP |
690 | last come first. |
691 | ||
ec40bbb8 | 692 | @item --target=@var{bfdname} |
918c2f61 | 693 | @c @item --target |
c72af735 RP |
694 | @cindex object code format |
695 | Specify an object code format other than your system's default format. | |
696 | @xref{objdump}, for information on listing available formats. | |
918c2f61 | 697 | @c FIXME what *does* --target/no arg do? |
c72af735 RP |
698 | |
699 | @item -u | |
918c2f61 | 700 | @itemx --undefined-only |
c72af735 RP |
701 | @cindex external symbols |
702 | @cindex undefined symbols | |
703 | Display only undefined symbols (those external to each object file). | |
704 | ||
705 | @end table | |
706 | ||
707 | @node objdump, ranlib, nm, Top | |
708 | @chapter objdump | |
709 | ||
710 | @cindex object file information | |
711 | @kindex objdump | |
712 | ||
713 | @smallexample | |
714 | objdump [ -a ] [ -b @var{bfdname} ] [ -d ] [ -f ] | |
c5f0c938 JG |
715 | [ -h | --header ] [ -i ] [ -j @var{section} ] [ -l ] |
716 | [ -m @var{machine} ] [ -r | --reloc ] [ -s ] | |
717 | [ --stabs ] [ -t | --syms ] [ -x ] | |
b703c078 | 718 | @var{objfile}@dots{} |
c72af735 RP |
719 | @end smallexample |
720 | ||
721 | @code{objdump} displays information about one or more object files. | |
722 | The options control what particular information to display. This | |
723 | information is mostly useful to programmers who are working on the | |
724 | compilation tools, as opposed to programmers who just want their | |
725 | program to compile and work. | |
726 | ||
727 | The long and short forms of options, shown here as alternatives, are | |
728 | equivalent. | |
729 | ||
730 | @table @code | |
b703c078 | 731 | @item @var{objfile}@dots{} |
c72af735 RP |
732 | The object files to be examined. When you specify archives, |
733 | @code{objdump} shows information on each of the member object files. | |
734 | ||
735 | @item -a | |
736 | @c print_arelt_descr | |
737 | @cindex archive headers | |
ec40bbb8 | 738 | If any of the @var{objfile} files are archives, display the archive |
c72af735 RP |
739 | header information (in a format similar to @samp{ls -l}). Besides the |
740 | information you could list with @samp{ar tv}, @samp{objdump -a} shows | |
741 | the object file format of each archive member. | |
742 | ||
c5f0c938 | 743 | @c suggest longname --target or --format or --bfd |
c72af735 RP |
744 | @item -b @var{bfdname} |
745 | @cindex object code format | |
ec40bbb8 DM |
746 | Specify that the object-code format for the object files is |
747 | @var{bfdname}. This option may not be necessary; @var{objdump} can | |
748 | automatically recognize many formats. | |
749 | ||
750 | For example, | |
c72af735 RP |
751 | @example |
752 | objdump -b oasys -m vax -h fu.o | |
753 | @end example | |
754 | @noindent | |
ec40bbb8 DM |
755 | displays summary information from the section headers (@samp{-h}) of |
756 | @file{fu.o}, which is explicitly identified (@samp{-m}) as a VAX object | |
c72af735 RP |
757 | file in the format produced by Oasys compilers. You can list the |
758 | formats available with the @samp{-i} option. | |
759 | ||
760 | @item -d | |
761 | @cindex disassembling object code | |
762 | @cindex machine instructions | |
763 | Disassemble. Display the assembler mnemonics for the machine | |
ec40bbb8 | 764 | instructions from @var{objfile}. |
c72af735 RP |
765 | |
766 | @item -f | |
767 | @cindex object file header | |
768 | File header. Display summary information from the overall header of | |
ec40bbb8 | 769 | each of the @var{objfile} files. |
c72af735 RP |
770 | |
771 | @item -h | |
c5f0c938 | 772 | @itemx --header |
c72af735 RP |
773 | @cindex section headers |
774 | Header. Display summary information from the section headers of the | |
775 | object file. | |
776 | ||
777 | @item -i | |
778 | @cindex architectures available | |
779 | @cindex object formats available | |
780 | Display a list showing all architectures and object formats available | |
ec40bbb8 | 781 | for specification with @samp{-b} or @samp{-m}. |
c72af735 | 782 | |
c5f0c938 | 783 | @c suggest longname --section |
c72af735 RP |
784 | @item -j @var{name} |
785 | @cindex section information | |
ec40bbb8 | 786 | Display information only for section @var{name}. |
c72af735 | 787 | |
c5f0c938 | 788 | @c suggest longname --label or --linespec |
c72af735 RP |
789 | @item -l |
790 | @cindex source filenames for object files | |
791 | Label the display (using debugging information) with the source filename | |
792 | and line numbers corresponding to the object code shown. | |
793 | ||
c5f0c938 | 794 | @c suggest longname --architecture |
c72af735 RP |
795 | @item -m @var{machine} |
796 | @cindex architecture | |
ec40bbb8 | 797 | Specify that the object files @var{objfile} are for architecture |
c72af735 RP |
798 | @var{machine}. You can list available architectures using the @samp{-i} |
799 | option. | |
800 | ||
801 | @item -r | |
c5f0c938 | 802 | @itemx --reloc |
c72af735 RP |
803 | @cindex relocation entries, in object file |
804 | Relocation. Print the relocation entries of the file. | |
805 | ||
806 | @item -s | |
807 | @cindex sections, full contents | |
808 | @cindex object file sections | |
809 | Display the full contents of any sections requested. | |
810 | ||
c5f0c938 JG |
811 | @item --stabs |
812 | @cindex stab | |
813 | @cindex .stab | |
814 | @cindex debug symbols | |
815 | @cindex ELF object file format | |
c3c93fda JG |
816 | Display the full contents of any sections requested. Display the |
817 | contents of the .stab and .stab.index and .stab.excl sections from an | |
818 | ELF file. This is only useful on systems (such as Solaris 2.0) in which | |
819 | @code{.stab} debugging symbol-table entries are carried in an ELF | |
820 | section. In most other file formats, debugging symbol-table entries are | |
c5f0c938 JG |
821 | interleaved with linkage symbols, and are visible in the @samp{--syms} |
822 | output. | |
823 | ||
c72af735 | 824 | @item -t |
c5f0c938 | 825 | @itemx --syms |
c72af735 RP |
826 | @cindex symbol table entries, printing |
827 | Symbol Table. Print the symbol table entries of the file. | |
828 | This is similar to the information provided by the @samp{nm} program. | |
829 | ||
830 | @item -x | |
831 | @cindex all header information, object file | |
832 | @cindex header information, all | |
833 | Display all available header information, including the symbol table and | |
834 | relocation entries. Using @samp{-x} is equivalent to specifying all of | |
835 | @samp{-a -f -h -r -t}. | |
836 | ||
837 | @end table | |
838 | ||
839 | @node ranlib, size, objdump, Top | |
840 | @chapter ranlib | |
841 | ||
842 | @kindex ranlib | |
843 | @cindex archive contents | |
844 | @cindex symbol index | |
845 | ||
846 | @smallexample | |
847 | ranlib @var{archive} | |
848 | @end smallexample | |
849 | ||
ec40bbb8 | 850 | @code{ranlib} generates an index to the contents of an archive and |
c72af735 RP |
851 | stores it in the archive. The index lists each symbol defined by a |
852 | member of an archive that is a relocatable object file. | |
853 | ||
918c2f61 | 854 | You may use @samp{nm -s} or @samp{nm --print-armap} to list this index. |
c72af735 | 855 | |
ec40bbb8 | 856 | An archive with such an index speeds up linking to the library and |
c72af735 RP |
857 | allows routines in the library to call each other without regard to |
858 | their placement in the archive. | |
859 | ||
860 | The GNU @code{ranlib} program is another form of GNU @code{ar}; running | |
861 | @code{ranlib} is completely equivalent to executing @samp{ar -s}. | |
862 | @xref{ar}. | |
863 | ||
864 | @node size, strip, ranlib, Top | |
865 | @chapter size | |
866 | ||
867 | @kindex size | |
868 | @cindex section sizes | |
869 | ||
870 | @smallexample | |
ec40bbb8 DM |
871 | size [ -A | -B | --format=@var{compatibility} ] |
872 | [ --help ] [ -d | -o | -x | --radix=@var{number} ] | |
873 | [ --target=@var{bfdname} ] [ -V | --version ] | |
b703c078 | 874 | @var{objfile}@dots{} |
c72af735 RP |
875 | @end smallexample |
876 | ||
877 | The GNU @code{size} utility lists the section sizes---and the total | |
ec40bbb8 DM |
878 | size---for each of the object or archive files @var{objfile} in its |
879 | argument list. By default, one line of output is generated for each | |
880 | object file or each module in an archive. | |
c72af735 RP |
881 | |
882 | The command line options have the following meanings: | |
883 | @table @code | |
b703c078 | 884 | @item @var{objfile}@dots{} |
c72af735 RP |
885 | The object files to be examined. |
886 | ||
887 | @item -A | |
888 | @itemx -B | |
ec40bbb8 | 889 | @itemx --format=@var{compatibility} |
c72af735 RP |
890 | @cindex size display format |
891 | Using one of these options, you can choose whether the output from GNU | |
892 | @code{size} resembles output from System V @code{size} (using @samp{-A}, | |
ec40bbb8 DM |
893 | or @samp{--format=sysv}), or Berkeley @code{size} (using @samp{-B}, or |
894 | @samp{--format=berkeley}). The default is the one-line format similar to | |
c72af735 | 895 | Berkeley's. |
918c2f61 PB |
896 | @c Bonus for doc-source readers: you can also say --format=strange (or |
897 | @c anything else that starts with 's') for sysv, and --format=boring (or | |
c72af735 RP |
898 | @c anything else that starts with 'b') for Berkeley. |
899 | ||
900 | Here is an example of the Berkeley (default) format of output from | |
901 | @code{size}: | |
902 | @smallexample | |
918c2f61 | 903 | eg$ size --format Berkeley ranlib size |
c72af735 RP |
904 | text data bss dec hex filename |
905 | 294880 81920 11592 388392 5ed28 ranlib | |
906 | 294880 81920 11888 388688 5ee50 size | |
907 | @end smallexample | |
908 | ||
909 | @noindent | |
910 | This is the same data, but displayed closer to System V conventions: | |
911 | ||
912 | @smallexample | |
918c2f61 | 913 | eg$ size --format SysV ranlib size |
c72af735 RP |
914 | ranlib : |
915 | section size addr | |
916 | .text 294880 8192 | |
917 | .data 81920 303104 | |
918 | .bss 11592 385024 | |
919 | Total 388392 | |
920 | ||
921 | ||
922 | size : | |
923 | section size addr | |
924 | .text 294880 8192 | |
925 | .data 81920 303104 | |
926 | .bss 11888 385024 | |
927 | Total 388688 | |
928 | @end smallexample | |
929 | ||
918c2f61 | 930 | @item --help |
c72af735 RP |
931 | Show a summary of acceptable arguments and options. |
932 | ||
933 | @item -d | |
934 | @itemx -o | |
935 | @itemx -x | |
ec40bbb8 | 936 | @itemx --radix=@var{number} |
c72af735 RP |
937 | @cindex size number format |
938 | @cindex radix for section sizes | |
939 | Using one of these options, you can control whether the size of each | |
ec40bbb8 DM |
940 | section is given in decimal (@samp{-d}, or @samp{--radix=10}); octal |
941 | (@samp{-o}, or @samp{--radix=8}); or hexadecimal (@samp{-x}, or | |
942 | @samp{--radix=16}). In @samp{--radix=@var{number}}, only the three | |
c72af735 RP |
943 | values (8, 10, 16) are supported. The total size is always given in two |
944 | radices; decimal and hexadecimal for @samp{-d} or @samp{-x} output, or | |
945 | octal and hexadecimal if you're using @samp{-o}. | |
946 | ||
ec40bbb8 | 947 | @item --target=@var{bfdname} |
c72af735 | 948 | @cindex object code format |
ec40bbb8 DM |
949 | Specify that the object-code format for @var{objfile} is |
950 | @var{bfdname}. This option may not be necessary; @code{size} can | |
c72af735 RP |
951 | automatically recognize many formats. @xref{objdump}, for information |
952 | on listing available formats. | |
953 | ||
954 | @item -V | |
918c2f61 | 955 | @itemx --version |
ec40bbb8 | 956 | Display version number information for @code{size} itself. |
c72af735 RP |
957 | |
958 | @end table | |
959 | ||
960 | @node strip, Index, size, Top | |
961 | @chapter strip | |
962 | ||
963 | @kindex strip | |
964 | @cindex removing symbols | |
965 | @cindex discarding symbols | |
1815e42c | 966 | @cindex symbols, discarding |
c72af735 RP |
967 | |
968 | @smallexample | |
b703c078 DM |
969 | strip [ -F @var{format} | --format=@var{format} | --target=@var{format} ] |
970 | [ -I @var{format} | --input-format=@var{format} ] | |
971 | [ -O @var{format} | --output-format=@var{format} ] | |
972 | [ -s | --strip-all ] [ -S | -g | --strip-debug ] | |
973 | [ -x | --discard-all ] [ -X | --discard-locals ] | |
918c2f61 | 974 | [ -v | --verbose ] [ -V | --version ] |
b703c078 | 975 | @var{objfile}@dots{} |
c72af735 RP |
976 | @end smallexample |
977 | ||
e31e9a8d | 978 | GNU @code{strip} discards all symbols from object files |
ec40bbb8 | 979 | @var{objfile}. The list of object files may include archives. |
c72af735 RP |
980 | |
981 | @code{strip} will not execute unless at least one object file is listed. | |
982 | ||
ec40bbb8 | 983 | @code{strip} modifies the files named in its argument, |
c72af735 | 984 | rather than writing modified copies under different names. |
c72af735 | 985 | |
c72af735 | 986 | @table @code |
918c2f61 PB |
987 | @item -I @var{format} |
988 | @itemx --input-format=@var{format} | |
ec40bbb8 DM |
989 | Treat the original @var{objfile} as a file with the object |
990 | code format @var{format}. | |
918c2f61 PB |
991 | |
992 | @item -O @var{format} | |
993 | @itemx --output-format=@var{format} | |
ec40bbb8 | 994 | Replace @var{objfile} with a file in the output format @var{format}. |
918c2f61 PB |
995 | |
996 | @item -F @var{format} | |
997 | @itemx --format=@var{format} | |
b703c078 | 998 | @itemx --target=@var{format} |
ec40bbb8 DM |
999 | Treat the original @var{objfile} as a file with the object |
1000 | code format @var{format}, and rewrite it in the same format. | |
918c2f61 | 1001 | |
b703c078 DM |
1002 | @item -s |
1003 | @itemx --strip-all | |
1004 | Remove all symbols. | |
1005 | ||
918c2f61 PB |
1006 | @item -g |
1007 | @itemx -S | |
1008 | @itemx --strip-debug | |
1009 | Remove debugging symbols only. | |
1010 | ||
1011 | @item -x | |
1012 | @itemx --discard-all | |
1013 | Remove non-global symbols. | |
1014 | ||
1015 | @item -X | |
1016 | @itemx --discard-locals | |
1017 | Remove compiler-generated local symbols. | |
ec40bbb8 | 1018 | (These usually start with @samp{L} or @samp{.}.) |
918c2f61 PB |
1019 | |
1020 | @item -V | |
1021 | @itemx --version | |
ec40bbb8 | 1022 | Show the version number for @code{strip}. |
918c2f61 | 1023 | |
1815e42c | 1024 | @item -v |
918c2f61 PB |
1025 | @itemx --verbose |
1026 | Verbose output: list all object files modified. In the case of | |
1027 | archives, @samp{strip -V} lists all members of the archive. | |
c72af735 RP |
1028 | @end table |
1029 | ||
765a273f | 1030 | @node Index, , strip, Top |
c72af735 RP |
1031 | @unnumbered Index |
1032 | ||
1033 | @printindex cp | |
1034 | ||
1035 | @contents | |
1036 | @bye |