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