* nm.c: HOST_64_BIT was renamed to BFD_HOST_64_BIT.
[external/binutils.git] / binutils / nm.c
1 /* nm.c -- Describe symbol table of a rel file.
2    Copyright 1991, 92, 93, 94 Free Software Foundation, Inc.
3
4    This file is part of GNU Binutils.
5
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 2 of the License, or
9    (at your option) any later version.
10
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.
15
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., 675 Mass Ave, Cambridge, MA 02139, USA.  */
19
20 #include "bfd.h"
21 #include "sysdep.h"
22 #include "bucomm.h"
23 #include "getopt.h"
24 #include "aout/stab_gnu.h"
25 #include "aout/ranlib.h"
26 #include "demangle.h"
27
28 static boolean
29 display_file PARAMS ((char *filename));
30
31 static void
32 display_rel_file PARAMS ((bfd * file, bfd * archive));
33
34 static unsigned int
35 filter_symbols PARAMS ((bfd * file, asymbol ** syms, unsigned long symcount));
36
37 static void
38 print_symbols PARAMS ((bfd * file, asymbol ** syms, unsigned long symcount,
39                        bfd * archive));
40
41 static void
42 print_symdef_entry PARAMS ((bfd * abfd));
43
44
45 /* The output formatting functions.  */
46
47 static void
48 print_object_filename_bsd PARAMS ((char *filename));
49
50 static void
51 print_object_filename_sysv PARAMS ((char *filename));
52
53 static void
54 print_object_filename_posix PARAMS ((char *filename));
55
56
57 static void
58 print_archive_filename_bsd PARAMS ((char *filename));
59
60 static void
61 print_archive_filename_sysv PARAMS ((char *filename));
62
63 static void
64 print_archive_filename_posix PARAMS ((char *filename));
65
66
67 static void
68 print_archive_member_bsd PARAMS ((char *archive, CONST char *filename));
69
70 static void
71 print_archive_member_sysv PARAMS ((char *archive, CONST char *filename));
72
73 static void
74 print_archive_member_posix PARAMS ((char *archive, CONST char *filename));
75
76
77 static void
78 print_symbol_filename_bsd PARAMS ((bfd * archive_bfd, bfd * abfd));
79
80 static void
81 print_symbol_filename_sysv PARAMS ((bfd * archive_bfd, bfd * abfd));
82
83 static void
84 print_symbol_filename_posix PARAMS ((bfd * archive_bfd, bfd * abfd));
85
86
87 static void
88 print_symbol_info_bsd PARAMS ((symbol_info * info, bfd * abfd));
89
90 static void
91 print_symbol_info_sysv PARAMS ((symbol_info * info, bfd * abfd));
92
93 static void
94 print_symbol_info_posix PARAMS ((symbol_info * info, bfd * abfd));
95
96
97 /* Support for different output formats.  */
98 struct output_fns
99   {
100     /* Print the name of an object file given on the command line.  */
101     void (*print_object_filename) PARAMS ((char *filename));
102
103     /* Print the name of an archive file given on the command line.  */
104     void (*print_archive_filename) PARAMS ((char *filename));
105
106     /* Print the name of an archive member file.  */
107     void (*print_archive_member) PARAMS ((char *archive, CONST char *filename));
108
109     /* Print the name of the file (and archive, if there is one)
110        containing a symbol.  */
111     void (*print_symbol_filename) PARAMS ((bfd * archive_bfd, bfd * abfd));
112
113     /* Print a line of information about a symbol.  */
114     void (*print_symbol_info) PARAMS ((symbol_info * info, bfd * abfd));
115   };
116 static struct output_fns formats[] =
117 {
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}
133 };
134
135 /* Indices in `formats'.  */
136 #define FORMAT_BSD 0
137 #define FORMAT_SYSV 1
138 #define FORMAT_POSIX 2
139 #define FORMAT_DEFAULT FORMAT_BSD
140
141 /* The output format to use.  */
142 static struct output_fns *format = &formats[FORMAT_DEFAULT];
143
144
145 /* Command options.  */
146
147 static int do_demangle = 0;     /* Pretty print C++ symbol names.  */
148 static int external_only = 0;   /* print external symbols only */
149 static int no_sort = 0;         /* don't sort; print syms in order found */
150 static int print_debug_syms = 0;        /* print debugger-only symbols too */
151 static int print_armap = 0;     /* describe __.SYMDEF data in archive files.  */
152 static int reverse_sort = 0;    /* sort in downward(alpha or numeric) order */
153 static int sort_numerically = 0;        /* sort in numeric rather than alpha order */
154 static int undefined_only = 0;  /* print undefined symbols only */
155 static int dynamic = 0;         /* print dynamic symbols.  */
156 static int show_version = 0;    /* show the version number */
157
158 /* When to print the names of files.  Not mutually exclusive in SYSV format.  */
159 static int filename_per_file = 0;       /* Once per file, on its own line.  */
160 static int filename_per_symbol = 0;     /* Once per symbol, at start of line.  */
161
162 /* Print formats for printing a symbol value.  */
163 #ifdef  BFD_HOST_64_BIT
164 static char value_format[] = "%08x%08x";
165 #else
166 static char value_format[] = "%08lx";
167 #endif
168 /* Print formats for printing stab info.  */
169 static char other_format[] = "%02x";
170 static char desc_format[] = "%04x";
171
172 /* IMPORT */
173 extern char *program_name;
174 extern char *program_version;
175 extern char *target;
176 extern int print_version;
177
178 static struct option long_options[] =
179 {
180   {"debug-syms", no_argument, &print_debug_syms, 1},
181   {"demangle", no_argument, &do_demangle, 1},
182   {"dynamic", no_argument, &dynamic, 1},
183   {"extern-only", no_argument, &external_only, 1},
184   {"format", required_argument, 0, 'f'},
185   {"help", no_argument, 0, 'h'},
186   {"no-sort", no_argument, &no_sort, 1},
187   {"numeric-sort", no_argument, &sort_numerically, 1},
188   {"portability", no_argument, 0, 'P'},
189   {"print-armap", no_argument, &print_armap, 1},
190   {"print-file-name", no_argument, 0, 'o'},
191   {"radix", required_argument, 0, 't'},
192   {"reverse-sort", no_argument, &reverse_sort, 1},
193   {"target", required_argument, 0, 200},
194   {"undefined-only", no_argument, &undefined_only, 1},
195   {"version", no_argument, &show_version, 1},
196   {0, no_argument, 0, 0}
197 };
198 \f
199 /* Some error-reporting functions */
200
201 void
202 usage (stream, status)
203      FILE *stream;
204      int status;
205 {
206   fprintf (stream, "\
207 Usage: %s [-aABCDgnopPrsuvV] [-t radix] [--radix=radix] [--target=bfdname]\n\
208        [--debug-syms] [--extern-only] [--print-armap] [--print-file-name]\n\
209        [--numeric-sort] [--no-sort] [--reverse-sort] [--undefined-only]\n\
210        [--portability] [-f {bsd,sysv,posix}] [--format={bsd,sysv,posix}]\n\
211        [--demangle] [--dynamic] [--version] [--help] [file...]\n",
212            program_name);
213   exit (status);
214 }
215
216 /* Set the radix for the symbol value and size according to RADIX.  */
217
218 void
219 set_print_radix (radix)
220      char *radix;
221 {
222   switch (*radix)
223     {
224     case 'd':
225     case 'o':
226     case 'x':
227 #ifdef  BFD_HOST_64_BIT
228       value_format[3] = value_format[7] = *radix;
229 #else
230       value_format[4] = *radix;
231 #endif
232       other_format[3] = desc_format[3] = *radix;
233       break;
234     default:
235       fprintf (stderr, "%s: %s: invalid radix\n", program_name, radix);
236       exit (1);
237     }
238 }
239
240 void
241 set_output_format (f)
242      char *f;
243 {
244   int i;
245
246   switch (*f)
247     {
248     case 'b':
249     case 'B':
250       i = FORMAT_BSD;
251       break;
252     case 'p':
253     case 'P':
254       i = FORMAT_POSIX;
255       break;
256     case 's':
257     case 'S':
258       i = FORMAT_SYSV;
259       break;
260     default:
261       fprintf (stderr, "%s: %s: invalid output format\n", program_name, f);
262       exit (1);
263     }
264   format = &formats[i];
265 }
266 \f
267 int
268 main (argc, argv)
269      int argc;
270      char **argv;
271 {
272   int c;
273   int retval;
274
275   program_name = *argv;
276   xmalloc_set_program_name (program_name);
277
278   bfd_init ();
279
280   while ((c = getopt_long (argc, argv, "aABCDf:gnopPrst:uvV", long_options, (int *) 0)) != EOF)
281     {
282       switch (c)
283         {
284         case 'a':
285           print_debug_syms = 1;
286           break;
287         case 'A':
288         case 'o':
289           filename_per_symbol = 1;
290           break;
291         case 'B':               /* For MIPS compatibility.  */
292           set_output_format ("bsd");
293           break;
294         case 'C':
295           do_demangle = 1;
296           break;
297         case 'D':
298           dynamic = 1;
299           break;
300         case 'f':
301           set_output_format (optarg);
302           break;
303         case 'g':
304           external_only = 1;
305           break;
306         case 'h':
307           usage (stdout, 0);
308         case 'n':
309         case 'v':
310           sort_numerically = 1;
311           break;
312         case 'p':
313           no_sort = 1;
314           break;
315         case 'P':
316           set_output_format ("posix");
317           break;
318         case 'r':
319           reverse_sort = 1;
320           break;
321         case 's':
322           print_armap = 1;
323           break;
324         case 't':
325           set_print_radix (optarg);
326           break;
327         case 'u':
328           undefined_only = 1;
329           break;
330         case 'V':
331           show_version = 1;
332           break;
333
334         case 200:               /* --target */
335           target = optarg;
336           break;
337
338         case 0:         /* A long option that just sets a flag.  */
339           break;
340
341         default:
342           usage (stderr, 1);
343         }
344     }
345
346   if (show_version)
347     {
348       printf ("GNU %s version %s\n", program_name, program_version);
349       exit (0);
350     }
351
352   /* OK, all options now parsed.  If no filename specified, do a.out.  */
353   if (optind == argc)
354     return !display_file ("a.out");
355
356   retval = 0;
357
358   if (argc - optind > 1)
359     filename_per_file = 1;
360
361   /* We were given several filenames to do.  */
362   while (optind < argc)
363     {
364       if (!display_file (argv[optind++]))
365         retval++;
366     }
367
368   exit (retval);
369   return retval;
370 }
371 \f
372 static void
373 display_archive (file)
374      bfd *file;
375 {
376   bfd *arfile = NULL;
377   bfd *last_arfile = NULL;
378   char **matching;
379
380   (*format->print_archive_filename) (bfd_get_filename (file));
381
382   if (print_armap)
383     print_symdef_entry (file);
384
385   for (;;)
386     {
387       arfile = bfd_openr_next_archived_file (file, arfile);
388
389       if (arfile == NULL)
390         {
391           if (bfd_get_error () != bfd_error_no_more_archived_files)
392             bfd_fatal (bfd_get_filename (file));
393           break;
394         }
395
396       if (bfd_check_format_matches (arfile, bfd_object, &matching))
397         {
398           (*format->print_archive_member) (bfd_get_filename (file),
399                                            bfd_get_filename (arfile));
400           display_rel_file (arfile, file);
401         }
402       else
403         {
404           bfd_nonfatal (bfd_get_filename (arfile));
405           if (bfd_get_error () == bfd_error_file_ambiguously_recognized)
406             {
407               list_matching_formats (matching);
408               free (matching);
409             }
410         }
411
412       if (last_arfile != NULL)
413         bfd_close (last_arfile);
414       last_arfile = arfile;
415     }
416
417   if (last_arfile != NULL)
418     bfd_close (last_arfile);
419 }
420
421 static boolean
422 display_file (filename)
423      char *filename;
424 {
425   boolean retval = true;
426   bfd *file;
427   char **matching;
428
429   file = bfd_openr (filename, target);
430   if (file == NULL)
431     {
432       bfd_nonfatal (filename);
433       return false;
434     }
435
436   if (bfd_check_format (file, bfd_archive))
437     {
438       display_archive (file);
439     }
440   else if (bfd_check_format_matches (file, bfd_object, &matching))
441     {
442       (*format->print_object_filename) (filename);
443       display_rel_file (file, NULL);
444     }
445   else
446     {
447       bfd_nonfatal (filename);
448       if (bfd_get_error () == bfd_error_file_ambiguously_recognized)
449         {
450           list_matching_formats (matching);
451           free (matching);
452         }
453       retval = false;
454     }
455
456   if (bfd_close (file) == false)
457     bfd_fatal (filename);
458
459   return retval;
460 }
461 \f
462 /* Symbol-sorting predicates */
463 #define valueof(x) ((x)->section->vma + (x)->value)
464 int
465 numeric_forward (x, y)
466      CONST void *x;
467      CONST void *y;
468 {
469   return (valueof (*(asymbol **) x) - valueof (*(asymbol **) y));
470 }
471
472 int
473 numeric_reverse (x, y)
474      CONST void *x;
475      CONST void *y;
476 {
477   return (valueof (*(asymbol **) y) - valueof (*(asymbol **) x));
478 }
479
480 int
481 non_numeric_forward (x, y)
482      CONST void *x;
483      CONST void *y;
484 {
485   CONST char *xn = (*(asymbol **) x)->name;
486   CONST char *yn = (*(asymbol **) y)->name;
487
488   return ((xn == NULL) ? ((yn == NULL) ? 0 : -1) :
489           ((yn == NULL) ? 1 : strcmp (xn, yn)));
490 }
491
492 int
493 non_numeric_reverse (x, y)
494      CONST void *x;
495      CONST void *y;
496 {
497   return -(non_numeric_forward (x, y));
498 }
499
500 static int (*(sorters[2][2])) PARAMS ((CONST void *, CONST void *)) =
501 {
502   { non_numeric_forward, non_numeric_reverse },
503   { numeric_forward, numeric_reverse }
504 };
505 \f
506 /* If ARCHIVE_BFD is non-NULL, it is the archive containing ABFD.  */
507
508 static void
509 display_rel_file (abfd, archive_bfd)
510      bfd *abfd;
511      bfd *archive_bfd;
512 {
513   long storage;
514   asymbol **syms;
515   long symcount = 0;
516
517   if (dynamic)
518     {
519       if (!(bfd_get_file_flags (abfd) & DYNAMIC))
520         {
521           printf ("\"%s\" is not a dynamic object.\n",
522                   bfd_get_filename (abfd));
523           return;
524         }
525     }
526   else
527     {
528       if (!(bfd_get_file_flags (abfd) & HAS_SYMS))
529         {
530           printf ("No symbols in \"%s\".\n", bfd_get_filename (abfd));
531           return;
532         }
533     }
534
535   if (dynamic)
536     storage = bfd_get_dynamic_symtab_upper_bound (abfd);
537   else
538     storage = bfd_get_symtab_upper_bound (abfd);
539   if (storage < 0)
540     bfd_fatal (bfd_get_filename (abfd));
541   if (storage == 0)
542     {
543     nosymz:
544       if (dynamic)
545         fprintf (stderr, "%s: no symbols\n", bfd_get_filename (abfd));
546       else
547         fprintf (stderr, "%s: Symflags set but there are none?\n",
548                  bfd_get_filename (abfd));
549       return;
550     }
551
552   syms = (asymbol **) xmalloc (storage);
553
554   if (dynamic)
555     symcount = bfd_canonicalize_dynamic_symtab (abfd, syms);
556   else
557     symcount = bfd_canonicalize_symtab (abfd, syms);
558   if (symcount < 0)
559     bfd_fatal (bfd_get_filename (abfd));
560   if (symcount == 0)
561     {
562       free (syms);
563       goto nosymz;
564     }
565
566   /* Discard the symbols we don't want to print.
567      It's OK to do this in place; we'll free the storage anyway
568      (after printing).  */
569
570   symcount = filter_symbols (abfd, syms, symcount);
571
572   if (!no_sort)
573     qsort ((char *) syms, symcount, sizeof (asymbol *),
574            sorters[sort_numerically][reverse_sort]);
575
576   print_symbols (abfd, syms, symcount, archive_bfd);
577   free (syms);
578 }
579 \f
580 /* Choose which symbol entries to print;
581    compact them downward to get rid of the rest.
582    Return the number of symbols to be printed.  */
583
584 static unsigned int
585 filter_symbols (abfd, syms, symcount)
586      bfd *abfd;                 /* Unused.  */
587      asymbol **syms;
588      unsigned long symcount;
589 {
590   asymbol **from, **to;
591   unsigned int src_count;
592   unsigned int dst_count = 0;
593   asymbol *sym;
594
595   for (from = to = syms, src_count = 0; src_count < symcount; src_count++)
596     {
597       int keep = 0;
598       flagword flags = (from[src_count])->flags;
599
600       sym = from[src_count];
601       if (undefined_only)
602         keep = sym->section == &bfd_und_section;
603       else if (external_only)
604         keep = ((flags & BSF_GLOBAL)
605                 || (sym->section == &bfd_und_section)
606                 || (bfd_is_com_section (sym->section)));
607       else
608         keep = 1;
609
610       if (!print_debug_syms && ((flags & BSF_DEBUGGING) != 0))
611         keep = 0;
612
613       if (keep)
614         to[dst_count++] = from[src_count];
615     }
616
617   return dst_count;
618 }
619 \f
620 /* Print symbol name NAME, read from ABFD, with printf format FORMAT,
621    demangling it if requested.  */
622
623 static void
624 print_symname (format, name, abfd)
625      char *format, *name;
626      bfd *abfd;
627 {
628   if (do_demangle)
629     {
630       char *res;
631
632       /* In this mode, give a user-level view of the symbol name
633          even if it's not mangled; strip off any leading
634          underscore.  */
635       if (bfd_get_symbol_leading_char (abfd) == name[0])
636         name++;
637
638       res = cplus_demangle (name, DMGL_ANSI | DMGL_PARAMS);
639       if (res)
640         {
641           printf (format, res);
642           free (res);
643           return;
644         }
645     }
646
647   printf (format, name);
648 }
649
650 /* If ARCHIVE_BFD is non-NULL, it is the archive containing ABFD.  */
651
652 static void
653 print_symbols (abfd, syms, symcount, archive_bfd)
654      bfd *abfd;
655      asymbol **syms;
656      unsigned long symcount;
657      bfd *archive_bfd;
658 {
659   asymbol **sym = syms, **end = syms + symcount;
660   symbol_info syminfo;
661
662   for (; sym < end; ++sym)
663     {
664       (*format->print_symbol_filename) (archive_bfd, abfd);
665
666       if (undefined_only)
667         {
668           if ((*sym)->section == &bfd_und_section)
669             {
670               print_symname ("%s\n", (*sym)->name, abfd);
671             }
672         }
673       else
674         {
675           asymbol *p = *sym;
676           if (p)
677             {
678               bfd_get_symbol_info (abfd, p, &syminfo);
679               (*format->print_symbol_info) (&syminfo, abfd);
680               putchar ('\n');
681             }
682         }
683     }
684 }
685 \f
686 /* The following 3 groups of functions are called unconditionally,
687    once at the start of processing each file of the appropriate type.
688    They should check `filename_per_file' and `filename_per_symbol',
689    as appropriate for their output format, to determine whether to
690    print anything.  */
691 \f
692 /* Print the name of an object file given on the command line.  */
693
694 static void
695 print_object_filename_bsd (filename)
696      char *filename;
697 {
698   if (filename_per_file && !filename_per_symbol)
699     printf ("\n%s:\n", filename);
700 }
701
702 static void
703 print_object_filename_sysv (filename)
704      char *filename;
705 {
706   if (undefined_only)
707     printf ("\n\nUndefined symbols from %s:\n\n", filename);
708   else
709     printf ("\n\nSymbols from %s:\n\n", filename);
710   printf ("\
711 Name                  Value   Class        Type         Size   Line  Section\n\n");
712 }
713
714 static void
715 print_object_filename_posix (filename)
716      char *filename;
717 {
718   if (filename_per_file && !filename_per_symbol)
719     printf ("%s:\n", filename);
720 }
721 \f
722 /* Print the name of an archive file given on the command line.  */
723
724 static void
725 print_archive_filename_bsd (filename)
726      char *filename;
727 {
728   if (filename_per_file)
729     printf ("\n%s:\n", filename);
730 }
731
732 static void
733 print_archive_filename_sysv (filename)
734      char *filename;
735 {
736 }
737
738 static void
739 print_archive_filename_posix (filename)
740      char *filename;
741 {
742 }
743 \f
744 /* Print the name of an archive member file.  */
745
746 static void
747 print_archive_member_bsd (archive, filename)
748      char *archive;
749      CONST char *filename;
750 {
751   if (!filename_per_symbol)
752     printf ("\n%s:\n", filename);
753 }
754
755 static void
756 print_archive_member_sysv (archive, filename)
757      char *archive;
758      CONST char *filename;
759 {
760   if (undefined_only)
761     printf ("\n\nUndefined symbols from %s[%s]:\n\n", archive, filename);
762   else
763     printf ("\n\nSymbols from %s[%s]:\n\n", archive, filename);
764   printf ("\
765 Name                  Value   Class        Type         Size   Line  Section\n\n");
766 }
767
768 static void
769 print_archive_member_posix (archive, filename)
770      char *archive;
771      CONST char *filename;
772 {
773   if (!filename_per_symbol)
774     printf ("%s[%s]:\n", archive, filename);
775 }
776 \f
777 /* Print the name of the file (and archive, if there is one)
778    containing a symbol.  */
779
780 static void
781 print_symbol_filename_bsd (archive_bfd, abfd)
782      bfd *archive_bfd, *abfd;
783 {
784   if (filename_per_symbol)
785     {
786       if (archive_bfd)
787         printf ("%s:", bfd_get_filename (archive_bfd));
788       printf ("%s:", bfd_get_filename (abfd));
789     }
790 }
791
792 static void
793 print_symbol_filename_sysv (archive_bfd, abfd)
794      bfd *archive_bfd, *abfd;
795 {
796   if (filename_per_symbol)
797     {
798       if (archive_bfd)
799         printf ("%s:", bfd_get_filename (archive_bfd));
800       printf ("%s:", bfd_get_filename (abfd));
801     }
802 }
803
804 static void
805 print_symbol_filename_posix (archive_bfd, abfd)
806      bfd *archive_bfd, *abfd;
807 {
808   if (filename_per_symbol)
809     {
810       if (archive_bfd)
811         printf ("%s[%s]: ", bfd_get_filename (archive_bfd),
812                 bfd_get_filename (abfd));
813       else
814         printf ("%s: ", bfd_get_filename (abfd));
815     }
816 }
817 \f
818 /* Print a line of information about a symbol.  */
819
820 static void
821 print_symbol_info_bsd (info, abfd)
822      symbol_info *info;
823      bfd *abfd;
824 {
825   if (info->type == 'U')
826     printf ("        ");
827   else
828     {
829 #ifdef BFD_HOST_64_BIT
830       printf (value_format, uint64_typeHIGH (info->value),
831               uint64_typeLOW (info->value));
832 #else
833       printf (value_format, info->value);
834 #endif
835     }
836   printf (" %c", info->type);
837   if (info->type == '-')
838     {
839       /* A stab.  */
840       printf (" ");
841       printf (other_format, info->stab_other);
842       printf (" ");
843       printf (desc_format, info->stab_desc);
844       printf (" %5s", info->stab_name);
845     }
846   print_symname (" %s", info->name, abfd);
847 }
848
849 static void
850 print_symbol_info_sysv (info, abfd)
851      symbol_info *info;
852      bfd *abfd;
853 {
854   print_symname ("%-20s|", info->name, abfd);   /* Name */
855   if (info->type == 'U')
856     printf ("        ");        /* Value */
857   else
858     {
859 #ifdef BFD_HOST_64_BIT
860       printf (value_format, uint64_typeHIGH (info->value),
861               uint64_typeLOW (info->value));
862 #else
863       printf (value_format, info->value);
864 #endif
865     }
866   printf ("|   %c  |", info->type);     /* Class */
867   if (info->type == '-')
868     {
869       /* A stab.  */
870       printf ("%18s|  ", info->stab_name);      /* (C) Type */
871       printf (desc_format, info->stab_desc);    /* Size */
872       printf ("|     |");       /* Line, Section */
873     }
874   else
875     printf ("                  |      |     |");        /* Type, Size, Line, Section */
876 }
877
878 static void
879 print_symbol_info_posix (info, abfd)
880      symbol_info *info;
881      bfd *abfd;
882 {
883   print_symname ("%s ", info->name, abfd);
884   printf ("%c ", info->type);
885   if (info->type == 'U')
886     printf ("        ");
887   else
888     {
889 #ifdef BFD_HOST_64_BIT
890       printf (value_format, uint64_typeHIGH (info->value),
891               uint64_typeLOW (info->value));
892 #else
893       printf (value_format, info->value);
894 #endif
895     }
896   /* POSIX.2 wants the symbol size printed here, when applicable;
897      BFD currently doesn't provide it, so we take the easy way out by
898      considering it to never be applicable.  */
899 }
900 \f
901 static void
902 print_symdef_entry (abfd)
903      bfd *abfd;
904 {
905   symindex idx = BFD_NO_MORE_SYMBOLS;
906   carsym *thesym;
907   boolean everprinted = false;
908
909   for (idx = bfd_get_next_mapent (abfd, idx, &thesym);
910        idx != BFD_NO_MORE_SYMBOLS;
911        idx = bfd_get_next_mapent (abfd, idx, &thesym))
912     {
913       bfd *elt;
914       if (!everprinted)
915         {
916           printf ("\nArchive index:\n");
917           everprinted = true;
918         }
919       elt = bfd_get_elt_at_index (abfd, idx);
920       if (thesym->name != (char *) NULL)
921         {
922           printf ("%s in %s\n", thesym->name, bfd_get_filename (elt));
923         }
924     }
925 }