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