1 /* nm.c -- Describe symbol table of a rel file.
2 Copyright (C) 1991-2021 Free Software Foundation, Inc.
4 This file is part of GNU Binutils.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
25 #include "aout/stab_gnu.h"
26 #include "aout/ranlib.h"
28 #include "libiberty.h"
30 #include "elf/common.h"
31 #define DO_NOT_DEFINE_AOUTHDR
32 #define DO_NOT_DEFINE_FILHDR
33 #define DO_NOT_DEFINE_LINENO
34 #define DO_NOT_DEFINE_SCNHDR
35 #include "coff/external.h"
36 #include "coff/internal.h"
39 #include "plugin-api.h"
42 /* When sorting by size, we use this structure to hold the size and a
43 pointer to the minisymbol. */
51 /* When fetching relocs, we use this structure to pass information to
54 struct get_relocs_info
62 struct extended_symbol_info
66 elf_symbol_type
*elfinfo
;
67 coff_symbol_type
*coffinfo
;
68 /* FIXME: We should add more fields for Type, Line, Section. */
70 #define SYM_VALUE(sym) (sym->sinfo->value)
71 #define SYM_TYPE(sym) (sym->sinfo->type)
72 #define SYM_STAB_NAME(sym) (sym->sinfo->stab_name)
73 #define SYM_STAB_DESC(sym) (sym->sinfo->stab_desc)
74 #define SYM_STAB_OTHER(sym) (sym->sinfo->stab_other)
75 #define SYM_SIZE(sym) \
76 (sym->elfinfo ? sym->elfinfo->internal_elf_sym.st_size: sym->ssize)
78 /* The output formatting functions. */
79 static void print_object_filename_bsd (const char *);
80 static void print_object_filename_sysv (const char *);
81 static void print_object_filename_posix (const char *);
82 static void print_archive_filename_bsd (const char *);
83 static void print_archive_filename_sysv (const char *);
84 static void print_archive_filename_posix (const char *);
85 static void print_archive_member_bsd (const char *, const char *);
86 static void print_archive_member_sysv (const char *, const char *);
87 static void print_archive_member_posix (const char *, const char *);
88 static void print_symbol_filename_bsd (bfd
*, bfd
*);
89 static void print_symbol_filename_sysv (bfd
*, bfd
*);
90 static void print_symbol_filename_posix (bfd
*, bfd
*);
91 static void print_value (bfd
*, bfd_vma
);
92 static void print_symbol_info_bsd (struct extended_symbol_info
*, bfd
*);
93 static void print_symbol_info_sysv (struct extended_symbol_info
*, bfd
*);
94 static void print_symbol_info_posix (struct extended_symbol_info
*, bfd
*);
96 /* Support for different output formats. */
99 /* Print the name of an object file given on the command line. */
100 void (*print_object_filename
) (const char *);
102 /* Print the name of an archive file given on the command line. */
103 void (*print_archive_filename
) (const char *);
105 /* Print the name of an archive member file. */
106 void (*print_archive_member
) (const char *, const char *);
108 /* Print the name of the file (and archive, if there is one)
109 containing a symbol. */
110 void (*print_symbol_filename
) (bfd
*, bfd
*);
112 /* Print a line of information about a symbol. */
113 void (*print_symbol_info
) (struct extended_symbol_info
*, bfd
*);
116 static struct output_fns formats
[] =
118 {print_object_filename_bsd
,
119 print_archive_filename_bsd
,
120 print_archive_member_bsd
,
121 print_symbol_filename_bsd
,
122 print_symbol_info_bsd
},
123 {print_object_filename_sysv
,
124 print_archive_filename_sysv
,
125 print_archive_member_sysv
,
126 print_symbol_filename_sysv
,
127 print_symbol_info_sysv
},
128 {print_object_filename_posix
,
129 print_archive_filename_posix
,
130 print_archive_member_posix
,
131 print_symbol_filename_posix
,
132 print_symbol_info_posix
}
135 /* Indices in `formats'. */
137 #define FORMAT_SYSV 1
138 #define FORMAT_POSIX 2
139 #define FORMAT_DEFAULT FORMAT_BSD
141 /* The output format to use. */
142 static struct output_fns
*format
= &formats
[FORMAT_DEFAULT
];
143 static unsigned int print_format
= FORMAT_DEFAULT
;
144 static const char *print_format_string
= NULL
;
146 /* Command options. */
148 static int do_demangle
= 0; /* Pretty print C++ symbol names. */
149 static int external_only
= 0; /* Print external symbols only. */
150 static int defined_only
= 0; /* Print defined symbols only. */
151 static int no_sort
= 0; /* Don't sort; print syms in order found. */
152 static int print_debug_syms
= 0;/* Print debugger-only symbols too. */
153 static int print_armap
= 0; /* Describe __.SYMDEF data in archive files. */
154 static int print_size
= 0; /* Print size of defined symbols. */
155 static int reverse_sort
= 0; /* Sort in downward(alpha or numeric) order. */
156 static int sort_numerically
= 0;/* Sort in numeric rather than alpha order. */
157 static int sort_by_size
= 0; /* Sort by size of symbol. */
158 static int undefined_only
= 0; /* Print undefined symbols only. */
159 static int dynamic
= 0; /* Print dynamic symbols. */
160 static int show_version
= 0; /* Show the version number. */
161 static int show_synthetic
= 0; /* Display synthesized symbols too. */
162 static int line_numbers
= 0; /* Print line numbers for symbols. */
163 static int allow_special_symbols
= 0; /* Allow special symbols. */
164 static int with_symbol_versions
= -1; /* Output symbol version information. */
165 static int quiet
= 0; /* Suppress "no symbols" diagnostic. */
167 /* The characters to use for global and local ifunc symbols. */
168 #if DEFAULT_F_FOR_IFUNC_SYMBOLS
169 static const char * ifunc_type_chars
= "Ff";
171 static const char * ifunc_type_chars
= NULL
;
174 static int demangle_flags
= DMGL_ANSI
| DMGL_PARAMS
;
176 /* When to print the names of files. Not mutually exclusive in SYSV format. */
177 static int filename_per_file
= 0; /* Once per file, on its own line. */
178 static int filename_per_symbol
= 0; /* Once per symbol, at start of line. */
180 static int print_width
= 0;
181 static int print_radix
= 16;
182 /* Print formats for printing stab info. */
183 static char other_format
[] = "%02x";
184 static char desc_format
[] = "%04x";
186 static char *target
= NULL
;
187 #if BFD_SUPPORTS_PLUGINS
188 static const char *plugin_target
= "plugin";
190 static const char *plugin_target
= NULL
;
193 /* Used to cache the line numbers for a BFD. */
194 static bfd
*lineno_cache_bfd
;
195 static bfd
*lineno_cache_rel_bfd
;
197 enum long_option_values
202 OPTION_RECURSE_LIMIT
,
203 OPTION_NO_RECURSE_LIMIT
,
208 static struct option long_options
[] =
210 {"debug-syms", no_argument
, &print_debug_syms
, 1},
211 {"demangle", optional_argument
, 0, 'C'},
212 {"dynamic", no_argument
, &dynamic
, 1},
213 {"extern-only", no_argument
, &external_only
, 1},
214 {"format", required_argument
, 0, 'f'},
215 {"help", no_argument
, 0, 'h'},
216 {"ifunc-chars", required_argument
, 0, OPTION_IFUNC_CHARS
},
217 {"line-numbers", no_argument
, 0, 'l'},
218 {"no-cplus", no_argument
, &do_demangle
, 0}, /* Linux compatibility. */
219 {"no-demangle", no_argument
, &do_demangle
, 0},
220 {"no-recurse-limit", no_argument
, NULL
, OPTION_NO_RECURSE_LIMIT
},
221 {"no-recursion-limit", no_argument
, NULL
, OPTION_NO_RECURSE_LIMIT
},
222 {"no-sort", no_argument
, 0, 'p'},
223 {"numeric-sort", no_argument
, 0, 'n'},
224 {"plugin", required_argument
, 0, OPTION_PLUGIN
},
225 {"portability", no_argument
, 0, 'P'},
226 {"print-armap", no_argument
, &print_armap
, 1},
227 {"print-file-name", no_argument
, 0, 'o'},
228 {"print-size", no_argument
, 0, 'S'},
229 {"quiet", no_argument
, 0, OPTION_QUIET
},
230 {"radix", required_argument
, 0, 't'},
231 {"recurse-limit", no_argument
, NULL
, OPTION_RECURSE_LIMIT
},
232 {"recursion-limit", no_argument
, NULL
, OPTION_RECURSE_LIMIT
},
233 {"reverse-sort", no_argument
, &reverse_sort
, 1},
234 {"size-sort", no_argument
, 0, OPTION_SIZE_SORT
},
235 {"special-syms", no_argument
, &allow_special_symbols
, 1},
236 {"synthetic", no_argument
, &show_synthetic
, 1},
237 {"target", required_argument
, 0, OPTION_TARGET
},
238 {"defined-only", no_argument
, &defined_only
, 1},
239 {"undefined-only", no_argument
, &undefined_only
, 1},
240 {"version", no_argument
, &show_version
, 1},
241 {"with-symbol-versions", no_argument
, &with_symbol_versions
, 1},
242 {"without-symbol-versions", no_argument
, &with_symbol_versions
, 0},
243 {0, no_argument
, 0, 0}
246 /* Some error-reporting functions. */
248 ATTRIBUTE_NORETURN
static void
249 usage (FILE *stream
, int status
)
251 fprintf (stream
, _("Usage: %s [option(s)] [file(s)]\n"), program_name
);
252 fprintf (stream
, _(" List symbols in [file(s)] (a.out by default).\n"));
253 fprintf (stream
, _(" The options are:\n\
254 -a, --debug-syms Display debugger-only symbols\n\
255 -A, --print-file-name Print name of the input file before every symbol\n\
256 -B Same as --format=bsd\n\
257 -C, --demangle[=STYLE] Decode low-level symbol names into user-level names\n\
258 The STYLE, if specified, can be `auto' (the default),\n\
259 `gnu', `lucid', `arm', `hp', `edg', `gnu-v3', `java'\n\
261 --no-demangle Do not demangle low-level symbol names\n\
262 --recurse-limit Enable a demangling recursion limit. This is the default.\n\
263 --no-recurse-limit Disable a demangling recursion limit.\n\
264 -D, --dynamic Display dynamic symbols instead of normal symbols\n\
265 --defined-only Display only defined symbols\n\
267 -f, --format=FORMAT Use the output format FORMAT. FORMAT can be `bsd',\n\
268 `sysv' or `posix'. The default is `bsd'\n\
269 -g, --extern-only Display only external symbols\n\
270 --ifunc-chars=CHARS Characters to use when displaying ifunc symbols\n\
271 -l, --line-numbers Use debugging information to find a filename and\n\
272 line number for each symbol\n\
273 -n, --numeric-sort Sort symbols numerically by address\n\
275 -p, --no-sort Do not sort the symbols\n\
276 -P, --portability Same as --format=posix\n\
277 -r, --reverse-sort Reverse the sense of the sort\n"));
278 #if BFD_SUPPORTS_PLUGINS
279 fprintf (stream
, _("\
280 --plugin NAME Load the specified plugin\n"));
282 fprintf (stream
, _("\
283 -S, --print-size Print size of defined symbols\n\
284 -s, --print-armap Include index for symbols from archive members\n\
285 --quiet Suppress \"no symbols\" diagnostic\n\
286 --size-sort Sort symbols by size\n\
287 --special-syms Include special symbols in the output\n\
288 --synthetic Display synthetic symbols as well\n\
289 -t, --radix=RADIX Use RADIX for printing symbol values\n\
290 --target=BFDNAME Specify the target object format as BFDNAME\n\
291 -u, --undefined-only Display only undefined symbols\n\
292 --with-symbol-versions Display version strings after symbol names\n\
293 -X 32_64 (ignored)\n\
294 @FILE Read options from FILE\n\
295 -h, --help Display this information\n\
296 -V, --version Display this program's version number\n\
298 list_supported_targets (program_name
, stream
);
299 if (REPORT_BUGS_TO
[0] && status
== 0)
300 fprintf (stream
, _("Report bugs to %s.\n"), REPORT_BUGS_TO
);
304 /* Set the radix for the symbol value and size according to RADIX. */
307 set_print_radix (char *radix
)
311 case 'x': print_radix
= 16; break;
312 case 'd': print_radix
= 10; break;
313 case 'o': print_radix
= 8; break;
316 fatal (_("%s: invalid radix"), radix
);
319 other_format
[3] = desc_format
[3] = *radix
;
323 set_output_format (char *f
)
342 fatal (_("%s: invalid output format"), f
);
344 format
= &formats
[i
];
349 get_elf_symbol_type (unsigned int type
)
356 case STT_NOTYPE
: return "NOTYPE";
357 case STT_OBJECT
: return "OBJECT";
358 case STT_FUNC
: return "FUNC";
359 case STT_SECTION
: return "SECTION";
360 case STT_FILE
: return "FILE";
361 case STT_COMMON
: return "COMMON";
362 case STT_TLS
: return "TLS";
366 if (type
>= STT_LOPROC
&& type
<= STT_HIPROC
)
367 n
= asprintf (&bufp
, _("<processor specific>: %d"), type
);
368 else if (type
>= STT_LOOS
&& type
<= STT_HIOS
)
369 n
= asprintf (&bufp
, _("<OS specific>: %d"), type
);
371 n
= asprintf (&bufp
, _("<unknown>: %d"), type
);
373 fatal ("%s", xstrerror (errno
));
378 get_coff_symbol_type (const struct internal_syment
*sym
)
383 switch (sym
->n_sclass
)
385 case C_BLOCK
: return "Block";
386 case C_FILE
: return "File";
387 case C_LINE
: return "Line";
393 switch (DTYPE(sym
->n_type
))
395 case DT_FCN
: return "Function";
396 case DT_PTR
: return "Pointer";
397 case DT_ARY
: return "Array";
401 n
= asprintf (&bufp
, _("<unknown>: %d/%d"), sym
->n_sclass
, sym
->n_type
);
403 fatal ("%s", xstrerror (errno
));
407 /* Print symbol name NAME, read from ABFD, with printf format FORM,
408 demangling it if requested. */
411 print_symname (const char *form
, struct extended_symbol_info
*info
,
412 const char *name
, bfd
*abfd
)
418 name
= info
->sinfo
->name
;
419 if (!with_symbol_versions
420 && bfd_get_flavour (abfd
) == bfd_target_elf_flavour
)
422 atver
= strchr (name
, '@');
426 if (do_demangle
&& *name
)
428 alloc
= bfd_demangle (abfd
, name
, demangle_flags
);
433 if (info
!= NULL
&& info
->elfinfo
&& with_symbol_versions
)
435 const char *version_string
;
439 = bfd_get_symbol_version_string (abfd
, &info
->elfinfo
->symbol
,
441 if (version_string
&& version_string
[0])
443 const char *at
= "@@";
444 if (hidden
|| bfd_is_und_section (info
->elfinfo
->symbol
.section
))
446 alloc
= reconcat (alloc
, name
, at
, version_string
, NULL
);
458 print_symdef_entry (bfd
*abfd
)
460 symindex idx
= BFD_NO_MORE_SYMBOLS
;
462 bfd_boolean everprinted
= FALSE
;
464 for (idx
= bfd_get_next_mapent (abfd
, idx
, &thesym
);
465 idx
!= BFD_NO_MORE_SYMBOLS
;
466 idx
= bfd_get_next_mapent (abfd
, idx
, &thesym
))
471 printf (_("\nArchive index:\n"));
474 elt
= bfd_get_elt_at_index (abfd
, idx
);
476 bfd_fatal ("bfd_get_elt_at_index");
477 if (thesym
->name
!= (char *) NULL
)
479 print_symname ("%s", NULL
, thesym
->name
, abfd
);
480 printf (" in %s\n", bfd_get_filename (elt
));
486 /* True when we can report missing plugin error. */
487 bfd_boolean report_plugin_err
= TRUE
;
489 /* Choose which symbol entries to print;
490 compact them downward to get rid of the rest.
491 Return the number of symbols to be printed. */
494 filter_symbols (bfd
*abfd
, bfd_boolean is_dynamic
, void *minisyms
,
495 long symcount
, unsigned int size
)
497 bfd_byte
*from
, *fromend
, *to
;
500 store
= bfd_make_empty_symbol (abfd
);
502 bfd_fatal (bfd_get_filename (abfd
));
504 from
= (bfd_byte
*) minisyms
;
505 fromend
= from
+ symcount
* size
;
506 to
= (bfd_byte
*) minisyms
;
508 for (; from
< fromend
; from
+= size
)
515 sym
= bfd_minisymbol_to_symbol (abfd
, is_dynamic
, (const void *) from
, store
);
517 bfd_fatal (bfd_get_filename (abfd
));
519 if (sym
->name
[0] == '_'
520 && sym
->name
[1] == '_'
521 && strcmp (sym
->name
+ (sym
->name
[2] == '_'), "__gnu_lto_slim") == 0
522 && report_plugin_err
)
524 report_plugin_err
= FALSE
;
525 non_fatal (_("%s: plugin needed to handle lto object"),
526 bfd_get_filename (abfd
));
530 keep
= bfd_is_und_section (sym
->section
);
531 else if (external_only
)
532 /* PR binutls/12753: Unique symbols are global too. */
533 keep
= ((sym
->flags
& (BSF_GLOBAL
535 | BSF_GNU_UNIQUE
)) != 0
536 || bfd_is_und_section (sym
->section
)
537 || bfd_is_com_section (sym
->section
));
542 && ! print_debug_syms
543 && (sym
->flags
& BSF_DEBUGGING
) != 0)
548 && (bfd_is_abs_section (sym
->section
)
549 || bfd_is_und_section (sym
->section
)))
555 if (bfd_is_und_section (sym
->section
))
560 && bfd_is_target_special_symbol (abfd
, sym
)
561 && ! allow_special_symbols
)
567 memcpy (to
, from
, size
);
572 return (to
- (bfd_byte
*) minisyms
) / size
;
575 /* These globals are used to pass information into the sorting
577 static bfd
*sort_bfd
;
578 static bfd_boolean sort_dynamic
;
579 static asymbol
*sort_x
;
580 static asymbol
*sort_y
;
582 /* Symbol-sorting predicates */
583 #define valueof(x) ((x)->section->vma + (x)->value)
585 /* Numeric sorts. Undefined symbols are always considered "less than"
586 defined symbols with zero values. Common symbols are not treated
587 specially -- i.e., their sizes are used as their "values". */
590 non_numeric_forward (const void *P_x
, const void *P_y
)
595 x
= bfd_minisymbol_to_symbol (sort_bfd
, sort_dynamic
, P_x
, sort_x
);
596 y
= bfd_minisymbol_to_symbol (sort_bfd
, sort_dynamic
, P_y
, sort_y
);
597 if (x
== NULL
|| y
== NULL
)
598 bfd_fatal (bfd_get_filename (sort_bfd
));
600 xn
= bfd_asymbol_name (x
);
601 yn
= bfd_asymbol_name (y
);
609 /* Solaris 2.5 has a bug in strcoll.
610 strcoll returns invalid values when confronted with empty strings. */
616 return strcoll (xn
, yn
);
618 return strcmp (xn
, yn
);
623 non_numeric_reverse (const void *x
, const void *y
)
625 return - non_numeric_forward (x
, y
);
629 numeric_forward (const void *P_x
, const void *P_y
)
634 x
= bfd_minisymbol_to_symbol (sort_bfd
, sort_dynamic
, P_x
, sort_x
);
635 y
= bfd_minisymbol_to_symbol (sort_bfd
, sort_dynamic
, P_y
, sort_y
);
636 if (x
== NULL
|| y
== NULL
)
637 bfd_fatal (bfd_get_filename (sort_bfd
));
639 xs
= bfd_asymbol_section (x
);
640 ys
= bfd_asymbol_section (y
);
642 if (bfd_is_und_section (xs
))
644 if (! bfd_is_und_section (ys
))
647 else if (bfd_is_und_section (ys
))
649 else if (valueof (x
) != valueof (y
))
650 return valueof (x
) < valueof (y
) ? -1 : 1;
652 return non_numeric_forward (P_x
, P_y
);
656 numeric_reverse (const void *x
, const void *y
)
658 return - numeric_forward (x
, y
);
661 static int (*(sorters
[2][2])) (const void *, const void *) =
663 { non_numeric_forward
, non_numeric_reverse
},
664 { numeric_forward
, numeric_reverse
}
667 /* This sort routine is used by sort_symbols_by_size. It is similar
668 to numeric_forward, but when symbols have the same value it sorts
669 by section VMA. This simplifies the sort_symbols_by_size code
670 which handles symbols at the end of sections. Also, this routine
671 tries to sort file names before other symbols with the same value.
672 That will make the file name have a zero size, which will make
673 sort_symbols_by_size choose the non file name symbol, leading to
674 more meaningful output. For similar reasons, this code sorts
675 gnu_compiled_* and gcc2_compiled before other symbols with the same
679 size_forward1 (const void *P_x
, const void *P_y
)
687 x
= bfd_minisymbol_to_symbol (sort_bfd
, sort_dynamic
, P_x
, sort_x
);
688 y
= bfd_minisymbol_to_symbol (sort_bfd
, sort_dynamic
, P_y
, sort_y
);
689 if (x
== NULL
|| y
== NULL
)
690 bfd_fatal (bfd_get_filename (sort_bfd
));
692 xs
= bfd_asymbol_section (x
);
693 ys
= bfd_asymbol_section (y
);
695 if (bfd_is_und_section (xs
))
697 if (bfd_is_und_section (ys
))
700 if (valueof (x
) != valueof (y
))
701 return valueof (x
) < valueof (y
) ? -1 : 1;
703 if (xs
->vma
!= ys
->vma
)
704 return xs
->vma
< ys
->vma
? -1 : 1;
706 xn
= bfd_asymbol_name (x
);
707 yn
= bfd_asymbol_name (y
);
711 /* The symbols gnu_compiled and gcc2_compiled convey even less
712 information than the file name, so sort them out first. */
714 xf
= (strstr (xn
, "gnu_compiled") != NULL
715 || strstr (xn
, "gcc2_compiled") != NULL
);
716 yf
= (strstr (yn
, "gnu_compiled") != NULL
717 || strstr (yn
, "gcc2_compiled") != NULL
);
724 /* We use a heuristic for the file name. It may not work on non
725 Unix systems, but it doesn't really matter; the only difference
726 is precisely which symbol names get printed. */
728 #define file_symbol(s, sn, snl) \
729 (((s)->flags & BSF_FILE) != 0 \
731 && (sn)[(snl) - 2] == '.' \
732 && ((sn)[(snl) - 1] == 'o' \
733 || (sn)[(snl) - 1] == 'a')))
735 xf
= file_symbol (x
, xn
, xnl
);
736 yf
= file_symbol (y
, yn
, ynl
);
743 return non_numeric_forward (P_x
, P_y
);
746 /* This sort routine is used by sort_symbols_by_size. It is sorting
747 an array of size_sym structures into size order. */
750 size_forward2 (const void *P_x
, const void *P_y
)
752 const struct size_sym
*x
= (const struct size_sym
*) P_x
;
753 const struct size_sym
*y
= (const struct size_sym
*) P_y
;
755 if (x
->size
< y
->size
)
756 return reverse_sort
? 1 : -1;
757 else if (x
->size
> y
->size
)
758 return reverse_sort
? -1 : 1;
760 return sorters
[0][reverse_sort
] (x
->minisym
, y
->minisym
);
763 /* Sort the symbols by size. ELF provides a size but for other formats
764 we have to make a guess by assuming that the difference between the
765 address of a symbol and the address of the next higher symbol is the
769 sort_symbols_by_size (bfd
*abfd
, bfd_boolean is_dynamic
, void *minisyms
,
770 long symcount
, unsigned int size
,
771 struct size_sym
**symsizesp
)
773 struct size_sym
*symsizes
;
774 bfd_byte
*from
, *fromend
;
776 asymbol
*store_sym
, *store_next
;
778 qsort (minisyms
, symcount
, size
, size_forward1
);
780 /* We are going to return a special set of symbols and sizes to
782 symsizes
= (struct size_sym
*) xmalloc (symcount
* sizeof (struct size_sym
));
783 *symsizesp
= symsizes
;
785 /* Note that filter_symbols has already removed all absolute and
786 undefined symbols. Here we remove all symbols whose size winds
788 from
= (bfd_byte
*) minisyms
;
789 fromend
= from
+ symcount
* size
;
796 sym
= bfd_minisymbol_to_symbol (abfd
, is_dynamic
, (const void *) from
,
799 bfd_fatal (bfd_get_filename (abfd
));
802 for (; from
< fromend
; from
+= size
)
809 if (from
+ size
< fromend
)
811 next
= bfd_minisymbol_to_symbol (abfd
,
813 (const void *) (from
+ size
),
816 bfd_fatal (bfd_get_filename (abfd
));
821 sec
= bfd_asymbol_section (sym
);
823 /* Synthetic symbols don't have a full type set of data available, thus
824 we can't rely on that information for the symbol size. Ditto for
825 bfd/section.c:global_syms like *ABS*. */
826 if ((sym
->flags
& (BSF_SECTION_SYM
| BSF_SYNTHETIC
)) == 0
827 && bfd_get_flavour (abfd
) == bfd_target_elf_flavour
)
828 sz
= ((elf_symbol_type
*) sym
)->internal_elf_sym
.st_size
;
829 else if ((sym
->flags
& (BSF_SECTION_SYM
| BSF_SYNTHETIC
)) == 0
830 && bfd_is_com_section (sec
))
834 if (from
+ size
< fromend
835 && sec
== bfd_asymbol_section (next
))
836 sz
= valueof (next
) - valueof (sym
);
838 sz
= (bfd_section_vma (sec
)
839 + bfd_section_size (sec
)
845 symsizes
->minisym
= (const void *) from
;
853 store_sym
= store_next
;
857 symcount
= symsizes
- *symsizesp
;
859 /* We must now sort again by size. */
860 qsort ((void *) *symsizesp
, symcount
, sizeof (struct size_sym
), size_forward2
);
865 /* This function is used to get the relocs for a particular section.
866 It is called via bfd_map_over_sections. */
869 get_relocs (bfd
*abfd
, asection
*sec
, void *dataarg
)
871 struct get_relocs_info
*data
= (struct get_relocs_info
*) dataarg
;
875 if ((sec
->flags
& SEC_RELOC
) == 0)
877 *data
->relocs
= NULL
;
884 relsize
= bfd_get_reloc_upper_bound (abfd
, sec
);
886 bfd_fatal (bfd_get_filename (abfd
));
888 *data
->relocs
= (arelent
**) xmalloc (relsize
);
889 *data
->relcount
= bfd_canonicalize_reloc (abfd
, sec
, *data
->relocs
,
891 if (*data
->relcount
< 0)
892 bfd_fatal (bfd_get_filename (abfd
));
900 /* Print a single symbol. */
903 print_symbol (bfd
* abfd
,
909 struct extended_symbol_info info
;
913 format
->print_symbol_filename (archive_bfd
, abfd
);
915 bfd_get_symbol_info (abfd
, sym
, &syminfo
);
917 /* PR 22967 - Distinguish between local and global ifunc symbols. */
918 if (syminfo
.type
== 'i'
919 && sym
->flags
& BSF_GNU_INDIRECT_FUNCTION
)
921 if (ifunc_type_chars
== NULL
|| ifunc_type_chars
[0] == 0)
922 ; /* Change nothing. */
923 else if (sym
->flags
& BSF_GLOBAL
)
924 syminfo
.type
= ifunc_type_chars
[0];
925 else if (ifunc_type_chars
[1] != 0)
926 syminfo
.type
= ifunc_type_chars
[1];
929 info
.sinfo
= &syminfo
;
931 /* Synthetic symbols do not have a full symbol type set of data available.
932 Nor do bfd/section.c:global_syms like *ABS*. */
933 if ((sym
->flags
& (BSF_SECTION_SYM
| BSF_SYNTHETIC
)) != 0)
936 info
.coffinfo
= NULL
;
940 info
.elfinfo
= elf_symbol_from (sym
);
941 info
.coffinfo
= coff_symbol_from (sym
);
944 format
->print_symbol_info (&info
, abfd
);
948 static asymbol
**syms
;
949 static long symcount
;
950 const char *filename
, *functionname
;
953 /* We need to get the canonical symbols in order to call
954 bfd_find_nearest_line. This is inefficient, but, then, you
955 don't have to use --line-numbers. */
956 if (abfd
!= lineno_cache_bfd
&& syms
!= NULL
)
965 symsize
= bfd_get_symtab_upper_bound (abfd
);
967 bfd_fatal (bfd_get_filename (abfd
));
968 syms
= (asymbol
**) xmalloc (symsize
);
969 symcount
= bfd_canonicalize_symtab (abfd
, syms
);
971 bfd_fatal (bfd_get_filename (abfd
));
972 lineno_cache_bfd
= abfd
;
975 if (bfd_is_und_section (bfd_asymbol_section (sym
)))
977 static asection
**secs
;
978 static arelent
***relocs
;
979 static long *relcount
;
980 static unsigned int seccount
;
984 /* For an undefined symbol, we try to find a reloc for the
985 symbol, and print the line number of the reloc. */
986 if (abfd
!= lineno_cache_rel_bfd
&& relocs
!= NULL
)
988 for (i
= 0; i
< seccount
; i
++)
989 if (relocs
[i
] != NULL
)
1001 struct get_relocs_info rinfo
;
1003 seccount
= bfd_count_sections (abfd
);
1005 secs
= (asection
**) xmalloc (seccount
* sizeof *secs
);
1006 relocs
= (arelent
***) xmalloc (seccount
* sizeof *relocs
);
1007 relcount
= (long *) xmalloc (seccount
* sizeof *relcount
);
1010 rinfo
.relocs
= relocs
;
1011 rinfo
.relcount
= relcount
;
1013 bfd_map_over_sections (abfd
, get_relocs
, (void *) &rinfo
);
1014 lineno_cache_rel_bfd
= abfd
;
1017 symname
= bfd_asymbol_name (sym
);
1018 for (i
= 0; i
< seccount
; i
++)
1022 for (j
= 0; j
< relcount
[i
]; j
++)
1027 if (r
->sym_ptr_ptr
!= NULL
1028 && (*r
->sym_ptr_ptr
)->section
== sym
->section
1029 && (*r
->sym_ptr_ptr
)->value
== sym
->value
1031 bfd_asymbol_name (*r
->sym_ptr_ptr
)) == 0
1032 && bfd_find_nearest_line (abfd
, secs
[i
], syms
,
1033 r
->address
, &filename
,
1034 &functionname
, &lineno
)
1035 && filename
!= NULL
)
1037 /* We only print the first one we find. */
1038 printf ("\t%s:%u", filename
, lineno
);
1045 else if (bfd_asymbol_section (sym
)->owner
== abfd
)
1047 if ((bfd_find_line (abfd
, syms
, sym
, &filename
, &lineno
)
1048 || bfd_find_nearest_line (abfd
, bfd_asymbol_section (sym
),
1049 syms
, sym
->value
, &filename
,
1050 &functionname
, &lineno
))
1053 printf ("\t%s:%u", filename
, lineno
);
1060 /* Print the symbols when sorting by size. */
1063 print_size_symbols (bfd
* abfd
,
1064 bfd_boolean is_dynamic
,
1065 struct size_sym
* symsizes
,
1070 struct size_sym
*from
;
1071 struct size_sym
*fromend
;
1073 store
= bfd_make_empty_symbol (abfd
);
1075 bfd_fatal (bfd_get_filename (abfd
));
1078 fromend
= from
+ symcount
;
1080 for (; from
< fromend
; from
++)
1084 sym
= bfd_minisymbol_to_symbol (abfd
, is_dynamic
, from
->minisym
, store
);
1086 bfd_fatal (bfd_get_filename (abfd
));
1088 print_symbol (abfd
, sym
, from
->size
, archive_bfd
);
1093 /* Print the symbols of ABFD that are held in MINISYMS.
1095 If ARCHIVE_BFD is non-NULL, it is the archive containing ABFD.
1097 SYMCOUNT is the number of symbols in MINISYMS.
1099 SIZE is the size of a symbol in MINISYMS. */
1102 print_symbols (bfd
* abfd
,
1103 bfd_boolean is_dynamic
,
1113 store
= bfd_make_empty_symbol (abfd
);
1115 bfd_fatal (bfd_get_filename (abfd
));
1117 from
= (bfd_byte
*) minisyms
;
1118 fromend
= from
+ symcount
* size
;
1120 for (; from
< fromend
; from
+= size
)
1124 sym
= bfd_minisymbol_to_symbol (abfd
, is_dynamic
, from
, store
);
1126 bfd_fatal (bfd_get_filename (abfd
));
1128 print_symbol (abfd
, sym
, (bfd_vma
) 0, archive_bfd
);
1132 /* If ARCHIVE_BFD is non-NULL, it is the archive containing ABFD. */
1135 display_rel_file (bfd
*abfd
, bfd
*archive_bfd
)
1140 struct size_sym
*symsizes
;
1141 asymbol
*synthsyms
= NULL
;
1145 if (!(bfd_get_file_flags (abfd
) & HAS_SYMS
))
1148 non_fatal (_("%s: no symbols"), bfd_get_filename (abfd
));
1153 symcount
= bfd_read_minisymbols (abfd
, dynamic
, &minisyms
, &size
);
1156 if (dynamic
&& bfd_get_error () == bfd_error_no_symbols
)
1159 non_fatal (_("%s: no symbols"), bfd_get_filename (abfd
));
1163 bfd_fatal (bfd_get_filename (abfd
));
1169 non_fatal (_("%s: no symbols"), bfd_get_filename (abfd
));
1173 if (show_synthetic
&& size
== sizeof (asymbol
*))
1175 asymbol
**static_syms
= NULL
;
1176 asymbol
**dyn_syms
= NULL
;
1177 long static_count
= 0;
1183 dyn_count
= symcount
;
1184 dyn_syms
= (asymbol
**) minisyms
;
1188 long storage
= bfd_get_dynamic_symtab_upper_bound (abfd
);
1190 static_count
= symcount
;
1191 static_syms
= (asymbol
**) minisyms
;
1195 dyn_syms
= (asymbol
**) xmalloc (storage
);
1196 dyn_count
= bfd_canonicalize_dynamic_symtab (abfd
, dyn_syms
);
1198 bfd_fatal (bfd_get_filename (abfd
));
1202 synth_count
= bfd_get_synthetic_symtab (abfd
, static_count
, static_syms
,
1203 dyn_count
, dyn_syms
, &synthsyms
);
1204 if (synth_count
> 0)
1209 minisyms
= xrealloc (minisyms
,
1210 (symcount
+ synth_count
+ 1) * sizeof (*symp
));
1211 symp
= (asymbol
**) minisyms
+ symcount
;
1212 for (i
= 0; i
< synth_count
; i
++)
1213 *symp
++ = synthsyms
+ i
;
1215 symcount
+= synth_count
;
1217 if (!dynamic
&& dyn_syms
!= NULL
)
1221 /* lto_slim_object is set to false when a bfd is loaded with a compiler
1223 if (abfd
->lto_slim_object
)
1225 report_plugin_err
= FALSE
;
1226 non_fatal (_("%s: plugin needed to handle lto object"),
1227 bfd_get_filename (abfd
));
1230 /* Discard the symbols we don't want to print.
1231 It's OK to do this in place; we'll free the storage anyway
1232 (after printing). */
1234 symcount
= filter_symbols (abfd
, dynamic
, minisyms
, symcount
, size
);
1240 sort_dynamic
= dynamic
;
1241 sort_x
= bfd_make_empty_symbol (abfd
);
1242 sort_y
= bfd_make_empty_symbol (abfd
);
1243 if (sort_x
== NULL
|| sort_y
== NULL
)
1244 bfd_fatal (bfd_get_filename (abfd
));
1247 qsort (minisyms
, symcount
, size
,
1248 sorters
[sort_numerically
][reverse_sort
]);
1250 symcount
= sort_symbols_by_size (abfd
, dynamic
, minisyms
, symcount
,
1255 print_symbols (abfd
, dynamic
, minisyms
, symcount
, size
, archive_bfd
);
1257 print_size_symbols (abfd
, dynamic
, symsizes
, symcount
, archive_bfd
);
1265 /* Construct a formatting string for printing symbol values. */
1268 get_print_format (void)
1270 const char * padding
;
1271 if (print_format
== FORMAT_POSIX
)
1273 /* POSIX compatible output does not have any padding. */
1276 else if (print_width
== 32)
1280 else /* print_width == 64 */
1285 const char * length
= "l";
1286 if (print_width
== 64)
1288 #if BFD_HOST_64BIT_LONG
1290 #elif BFD_HOST_64BIT_LONG_LONG
1299 const char * radix
= NULL
;
1300 switch (print_radix
)
1302 case 8: radix
= "o"; break;
1303 case 10: radix
= "d"; break;
1304 case 16: radix
= "x"; break;
1307 return concat ("%", padding
, length
, radix
, NULL
);
1311 set_print_width (bfd
*file
)
1313 print_width
= bfd_get_arch_size (file
);
1315 if (print_width
== -1)
1318 Guess the target's bitsize based on its name.
1319 We assume here than any 64-bit format will include
1320 "64" somewhere in its name. The only known exception
1321 is the MMO object file format. */
1322 if (strstr (bfd_get_target (file
), "64") != NULL
1323 || strcmp (bfd_get_target (file
), "mmo") == 0)
1328 free ((char *) print_format_string
);
1329 print_format_string
= get_print_format ();
1333 display_archive (bfd
*file
)
1336 bfd
*last_arfile
= NULL
;
1339 format
->print_archive_filename (bfd_get_filename (file
));
1342 print_symdef_entry (file
);
1348 arfile
= bfd_openr_next_archived_file (file
, arfile
);
1352 if (bfd_get_error () != bfd_error_no_more_archived_files
)
1353 bfd_fatal (bfd_get_filename (file
));
1357 if (bfd_check_format_matches (arfile
, bfd_object
, &matching
))
1359 set_print_width (arfile
);
1360 format
->print_archive_member (bfd_get_filename (file
),
1361 bfd_get_filename (arfile
));
1362 display_rel_file (arfile
, file
);
1366 bfd_nonfatal (bfd_get_filename (arfile
));
1367 if (bfd_get_error () == bfd_error_file_ambiguously_recognized
)
1369 list_matching_formats (matching
);
1374 if (last_arfile
!= NULL
)
1376 bfd_close (last_arfile
);
1377 lineno_cache_bfd
= NULL
;
1378 lineno_cache_rel_bfd
= NULL
;
1379 if (arfile
== last_arfile
)
1382 last_arfile
= arfile
;
1385 if (last_arfile
!= NULL
)
1387 bfd_close (last_arfile
);
1388 lineno_cache_bfd
= NULL
;
1389 lineno_cache_rel_bfd
= NULL
;
1394 display_file (char *filename
)
1396 bfd_boolean retval
= TRUE
;
1400 if (get_file_size (filename
) < 1)
1403 file
= bfd_openr (filename
, target
? target
: plugin_target
);
1406 bfd_nonfatal (filename
);
1410 /* If printing line numbers, decompress the debug sections. */
1412 file
->flags
|= BFD_DECOMPRESS
;
1414 if (bfd_check_format (file
, bfd_archive
))
1416 display_archive (file
);
1418 else if (bfd_check_format_matches (file
, bfd_object
, &matching
))
1420 set_print_width (file
);
1421 format
->print_object_filename (filename
);
1422 display_rel_file (file
, NULL
);
1426 bfd_nonfatal (filename
);
1427 if (bfd_get_error () == bfd_error_file_ambiguously_recognized
)
1429 list_matching_formats (matching
);
1435 if (!bfd_close (file
))
1436 bfd_fatal (filename
);
1438 lineno_cache_bfd
= NULL
;
1439 lineno_cache_rel_bfd
= NULL
;
1444 /* The following 3 groups of functions are called unconditionally,
1445 once at the start of processing each file of the appropriate type.
1446 They should check `filename_per_file' and `filename_per_symbol',
1447 as appropriate for their output format, to determine whether to
1450 /* Print the name of an object file given on the command line. */
1453 print_object_filename_bsd (const char *filename
)
1455 if (filename_per_file
&& !filename_per_symbol
)
1456 printf ("\n%s:\n", filename
);
1460 print_object_filename_sysv (const char *filename
)
1463 printf (_("\n\nUndefined symbols from %s:\n\n"), filename
);
1465 printf (_("\n\nSymbols from %s:\n\n"), filename
);
1466 if (print_width
== 32)
1468 Name Value Class Type Size Line Section\n\n"));
1471 Name Value Class Type Size Line Section\n\n"));
1475 print_object_filename_posix (const char *filename
)
1477 if (filename_per_file
&& !filename_per_symbol
)
1478 printf ("%s:\n", filename
);
1481 /* Print the name of an archive file given on the command line. */
1484 print_archive_filename_bsd (const char *filename
)
1486 if (filename_per_file
)
1487 printf ("\n%s:\n", filename
);
1491 print_archive_filename_sysv (const char *filename ATTRIBUTE_UNUSED
)
1496 print_archive_filename_posix (const char *filename ATTRIBUTE_UNUSED
)
1500 /* Print the name of an archive member file. */
1503 print_archive_member_bsd (const char *archive ATTRIBUTE_UNUSED
,
1504 const char *filename
)
1506 if (!filename_per_symbol
)
1507 printf ("\n%s:\n", filename
);
1511 print_archive_member_sysv (const char *archive
, const char *filename
)
1514 printf (_("\n\nUndefined symbols from %s[%s]:\n\n"), archive
, filename
);
1516 printf (_("\n\nSymbols from %s[%s]:\n\n"), archive
, filename
);
1517 if (print_width
== 32)
1519 Name Value Class Type Size Line Section\n\n"));
1522 Name Value Class Type Size Line Section\n\n"));
1526 print_archive_member_posix (const char *archive
, const char *filename
)
1528 if (!filename_per_symbol
)
1529 printf ("%s[%s]:\n", archive
, filename
);
1532 /* Print the name of the file (and archive, if there is one)
1533 containing a symbol. */
1536 print_symbol_filename_bsd (bfd
*archive_bfd
, bfd
*abfd
)
1538 if (filename_per_symbol
)
1541 printf ("%s:", bfd_get_filename (archive_bfd
));
1542 printf ("%s:", bfd_get_filename (abfd
));
1547 print_symbol_filename_sysv (bfd
*archive_bfd
, bfd
*abfd
)
1549 if (filename_per_symbol
)
1552 printf ("%s:", bfd_get_filename (archive_bfd
));
1553 printf ("%s:", bfd_get_filename (abfd
));
1558 print_symbol_filename_posix (bfd
*archive_bfd
, bfd
*abfd
)
1560 if (filename_per_symbol
)
1563 printf ("%s[%s]: ", bfd_get_filename (archive_bfd
),
1564 bfd_get_filename (abfd
));
1566 printf ("%s: ", bfd_get_filename (abfd
));
1570 /* Print a symbol value. */
1573 print_value (bfd
*abfd ATTRIBUTE_UNUSED
, bfd_vma val
)
1575 switch (print_width
)
1578 printf (print_format_string
, (unsigned long) val
);
1582 #if BFD_HOST_64BIT_LONG || BFD_HOST_64BIT_LONG_LONG
1583 printf (print_format_string
, val
);
1585 /* We have a 64 bit value to print, but the host is only 32 bit. */
1586 if (print_radix
== 16)
1587 bfd_fprintf_vma (abfd
, stdout
, val
);
1593 s
= buf
+ sizeof buf
;
1597 *--s
= (val
% print_radix
) + '0';
1600 while ((buf
+ sizeof buf
- 1) - s
< 16)
1608 fatal (_("Print width has not been initialized (%d)"), print_width
);
1613 /* Print a line of information about a symbol. */
1616 print_symbol_info_bsd (struct extended_symbol_info
*info
, bfd
*abfd
)
1618 if (bfd_is_undefined_symclass (SYM_TYPE (info
)))
1620 if (print_width
== 64)
1626 /* Normally we print the value of the symbol. If we are printing the
1627 size or sorting by size then we print its size, except for the
1628 (weird) special case where both flags are defined, in which case we
1629 print both values. This conforms to documented behaviour. */
1630 if (sort_by_size
&& !print_size
)
1631 print_value (abfd
, SYM_SIZE (info
));
1633 print_value (abfd
, SYM_VALUE (info
));
1634 if (print_size
&& SYM_SIZE (info
))
1637 print_value (abfd
, SYM_SIZE (info
));
1641 printf (" %c", SYM_TYPE (info
));
1643 if (SYM_TYPE (info
) == '-')
1647 printf (other_format
, SYM_STAB_OTHER (info
));
1649 printf (desc_format
, SYM_STAB_DESC (info
));
1650 printf (" %5s", SYM_STAB_NAME (info
));
1652 print_symname (" %s", info
, NULL
, abfd
);
1656 print_symbol_info_sysv (struct extended_symbol_info
*info
, bfd
*abfd
)
1658 print_symname ("%-20s|", info
, NULL
, abfd
);
1660 if (bfd_is_undefined_symclass (SYM_TYPE (info
)))
1662 if (print_width
== 32)
1668 print_value (abfd
, SYM_VALUE (info
));
1670 printf ("| %c |", SYM_TYPE (info
));
1672 if (SYM_TYPE (info
) == '-')
1675 printf ("%18s| ", SYM_STAB_NAME (info
)); /* (C) Type. */
1676 printf (desc_format
, SYM_STAB_DESC (info
)); /* Size. */
1677 printf ("| |"); /* Line, Section. */
1681 /* Type, Size, Line, Section */
1684 get_elf_symbol_type (ELF_ST_TYPE (info
->elfinfo
->internal_elf_sym
.st_info
)));
1685 else if (info
->coffinfo
)
1687 get_coff_symbol_type (&info
->coffinfo
->native
->u
.syment
));
1691 if (SYM_SIZE (info
))
1692 print_value (abfd
, SYM_SIZE (info
));
1695 if (print_width
== 32)
1702 printf("| |%s", info
->elfinfo
->symbol
.section
->name
);
1703 else if (info
->coffinfo
)
1704 printf("| |%s", info
->coffinfo
->symbol
.section
->name
);
1711 print_symbol_info_posix (struct extended_symbol_info
*info
, bfd
*abfd
)
1713 print_symname ("%s ", info
, NULL
, abfd
);
1714 printf ("%c ", SYM_TYPE (info
));
1716 if (bfd_is_undefined_symclass (SYM_TYPE (info
)))
1720 print_value (abfd
, SYM_VALUE (info
));
1722 if (SYM_SIZE (info
))
1723 print_value (abfd
, SYM_SIZE (info
));
1728 main (int argc
, char **argv
)
1733 #if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
1734 setlocale (LC_MESSAGES
, "");
1736 #if defined (HAVE_SETLOCALE)
1737 setlocale (LC_CTYPE
, "");
1738 setlocale (LC_COLLATE
, "");
1740 bindtextdomain (PACKAGE
, LOCALEDIR
);
1741 textdomain (PACKAGE
);
1743 program_name
= *argv
;
1744 xmalloc_set_program_name (program_name
);
1745 bfd_set_error_program_name (program_name
);
1746 #if BFD_SUPPORTS_PLUGINS
1747 bfd_plugin_set_program_name (program_name
);
1750 START_PROGRESS (program_name
, 0);
1752 expandargv (&argc
, &argv
);
1754 if (bfd_init () != BFD_INIT_MAGIC
)
1755 fatal (_("fatal error: libbfd ABI mismatch"));
1756 set_default_bfd_target ();
1758 while ((c
= getopt_long (argc
, argv
, "aABCDef:gHhlnopPrSst:uvVvX:",
1759 long_options
, (int *) 0)) != EOF
)
1764 print_debug_syms
= 1;
1768 filename_per_symbol
= 1;
1770 case 'B': /* For MIPS compatibility. */
1771 set_output_format ("bsd");
1777 enum demangling_styles style
;
1779 style
= cplus_demangle_name_to_style (optarg
);
1780 if (style
== unknown_demangling
)
1781 fatal (_("unknown demangling style `%s'"),
1784 cplus_demangle_set_style (style
);
1787 case OPTION_RECURSE_LIMIT
:
1788 demangle_flags
&= ~ DMGL_NO_RECURSE_LIMIT
;
1790 case OPTION_NO_RECURSE_LIMIT
:
1791 demangle_flags
|= DMGL_NO_RECURSE_LIMIT
;
1800 /* Ignored for HP/UX compatibility. */
1803 set_output_format (optarg
);
1817 sort_numerically
= 1;
1822 sort_numerically
= 0;
1825 case OPTION_SIZE_SORT
:
1827 sort_numerically
= 0;
1831 set_output_format ("posix");
1843 set_print_radix (optarg
);
1852 /* Ignored for (partial) AIX compatibility. On AIX, the
1853 argument has values 32, 64, or 32_64, and specifies that
1854 only 32-bit, only 64-bit, or both kinds of objects should
1855 be examined. The default is 32. So plain AIX nm on a
1856 library archive with both kinds of objects will ignore
1857 the 64-bit ones. For GNU nm, the default is and always
1858 has been -X 32_64, and other options are not supported. */
1859 if (strcmp (optarg
, "32_64") != 0)
1860 fatal (_("Only -X 32_64 is supported"));
1863 case OPTION_TARGET
: /* --target */
1867 case OPTION_PLUGIN
: /* --plugin */
1868 #if BFD_SUPPORTS_PLUGINS
1869 bfd_plugin_set_plugin (optarg
);
1871 fatal (_("sorry - this program has been built without plugin support\n"));
1875 case OPTION_IFUNC_CHARS
:
1876 ifunc_type_chars
= optarg
;
1879 case 0: /* A long option that just sets a flag. */
1888 print_version ("nm");
1890 if (sort_by_size
&& undefined_only
)
1892 non_fatal (_("Using the --size-sort and --undefined-only options together"));
1893 non_fatal (_("will produce no output, since undefined symbols have no size."));
1897 /* OK, all options now parsed. If no filename specified, do a.out. */
1899 return !display_file ("a.out");
1903 if (argc
- optind
> 1)
1904 filename_per_file
= 1;
1906 /* We were given several filenames to do. */
1907 while (optind
< argc
)
1910 if (!display_file (argv
[optind
++]))
1914 END_PROGRESS (program_name
);