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