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