Ignore:
Timestamp:
Aug 16, 2003, 6:59:22 PM (22 years ago)
Author:
bird
Message:

binutils v2.14 - offical sources.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/binutils/binutils/nm.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* nm.c -- Describe symbol table of a rel file.
    22   Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
    3    2001
     3   2001, 2002, 2003
    44   Free Software Foundation, Inc.
    55
     
    2424#include "progress.h"
    2525#include "bucomm.h"
     26#include "budemang.h"
    2627#include "getopt.h"
    2728#include "aout/stab_gnu.h"
     
    2930#include "demangle.h"
    3031#include "libiberty.h"
     32#include "elf-bfd.h"
     33#include "elf/common.h"
    3134
    3235/* When sorting by size, we use this structure to hold the size and a
     
    5053};
    5154
    52 static void
    53 usage PARAMS ((FILE *, int));
    54 
    55 static void
    56 set_print_radix PARAMS ((char *));
    57 
    58 static void
    59 set_output_format PARAMS ((char *));
    60 
    61 static void
    62 display_archive PARAMS ((bfd *));
    63 
    64 static boolean
    65 display_file PARAMS ((char *filename));
    66 
    67 static void
    68 display_rel_file PARAMS ((bfd * file, bfd * archive));
    69 
    70 static long
    71 filter_symbols PARAMS ((bfd *, boolean, PTR, long, unsigned int));
    72 
    73 static long
    74 sort_symbols_by_size PARAMS ((bfd *, boolean, PTR, long, unsigned int,
    75                               struct size_sym **));
    76 
    77 static void
    78 print_symbols PARAMS ((bfd *, boolean, PTR, long, unsigned int, bfd *));
    79 
    80 static void
    81 print_size_symbols PARAMS ((bfd *, boolean, struct size_sym *, long, bfd *));
    82 
    83 static void
    84 print_symname PARAMS ((const char *, const char *, bfd *));
    85 
    86 static void
    87 print_symbol PARAMS ((bfd *, asymbol *, bfd *));
    88 
    89 static void
    90 print_symdef_entry PARAMS ((bfd * abfd));
     55struct extended_symbol_info
     56{
     57  symbol_info *sinfo;
     58  bfd_vma ssize;
     59  elf_symbol_type *elfinfo;
     60  /* FIXME: We should add more fields for Type, Line, Section.  */
     61};
     62#define SYM_NAME(sym)        (sym->sinfo->name)
     63#define SYM_VALUE(sym)       (sym->sinfo->value)
     64#define SYM_TYPE(sym)        (sym->sinfo->type)
     65#define SYM_STAB_NAME(sym)   (sym->sinfo->stab_name)
     66#define SYM_STAB_DESC(sym)   (sym->sinfo->stab_desc)
     67#define SYM_STAB_OTHER(sym)  (sym->sinfo->stab_other)
     68#define SYM_SIZE(sym) \
     69  (sym->elfinfo ? sym->elfinfo->internal_elf_sym.st_size: sym->ssize)
     70
     71static void usage
     72  PARAMS ((FILE *, int));
     73static void set_print_radix
     74  PARAMS ((char *));
     75static void set_output_format
     76  PARAMS ((char *));
     77static void display_archive
     78  PARAMS ((bfd *));
     79static bfd_boolean display_file
     80  PARAMS ((char *));
     81static void display_rel_file
     82  PARAMS ((bfd *, bfd *));
     83static long filter_symbols
     84  PARAMS ((bfd *, bfd_boolean, PTR, long, unsigned int));
     85static long sort_symbols_by_size
     86  PARAMS ((bfd *, bfd_boolean, PTR, long, unsigned int, struct size_sym **));
     87static void print_symbols
     88  PARAMS ((bfd *, bfd_boolean, PTR, long, unsigned int, bfd *));
     89static void print_size_symbols
     90  PARAMS ((bfd *, bfd_boolean, struct size_sym *, long, bfd *));
     91static void print_symname
     92  PARAMS ((const char *, const char *, bfd *));
     93static void print_symbol
     94  PARAMS ((bfd *, asymbol *, bfd_vma ssize, bfd *));
     95static void print_symdef_entry
     96  PARAMS ((bfd *));
    9197
    9298/* The sorting functions.  */
    93 
    94 static int
    95 numeric_forward PARAMS ((const PTR, const PTR));
    96 
    97 static int
    98 numeric_reverse PARAMS ((const PTR, const PTR));
    99 
    100 static int
    101 non_numeric_forward PARAMS ((const PTR, const PTR));
    102 
    103 static int
    104 non_numeric_reverse PARAMS ((const PTR, const PTR));
    105 
    106 static int
    107 size_forward1 PARAMS ((const PTR, const PTR));
    108 
    109 static int
    110 size_forward2 PARAMS ((const PTR, const PTR));
     99static int numeric_forward
     100  PARAMS ((const PTR, const PTR));
     101static int numeric_reverse
     102  PARAMS ((const PTR, const PTR));
     103static int non_numeric_forward
     104  PARAMS ((const PTR, const PTR));
     105static int non_numeric_reverse
     106  PARAMS ((const PTR, const PTR));
     107static int size_forward1
     108  PARAMS ((const PTR, const PTR));
     109static int size_forward2
     110  PARAMS ((const PTR, const PTR));
    111111
    112112/* The output formatting functions.  */
    113 
    114 static void
    115 print_object_filename_bsd PARAMS ((char *filename));
    116 
    117 static void
    118 print_object_filename_sysv PARAMS ((char *filename));
    119 
    120 static void
    121 print_object_filename_posix PARAMS ((char *filename));
    122 
    123 
    124 static void
    125 print_archive_filename_bsd PARAMS ((char *filename));
    126 
    127 static void
    128 print_archive_filename_sysv PARAMS ((char *filename));
    129 
    130 static void
    131 print_archive_filename_posix PARAMS ((char *filename));
    132 
    133 
    134 static void
    135 print_archive_member_bsd PARAMS ((char *archive, CONST char *filename));
    136 
    137 static void
    138 print_archive_member_sysv PARAMS ((char *archive, CONST char *filename));
    139 
    140 static void
    141 print_archive_member_posix PARAMS ((char *archive, CONST char *filename));
    142 
    143 
    144 static void
    145 print_symbol_filename_bsd PARAMS ((bfd * archive_bfd, bfd * abfd));
    146 
    147 static void
    148 print_symbol_filename_sysv PARAMS ((bfd * archive_bfd, bfd * abfd));
    149 
    150 static void
    151 print_symbol_filename_posix PARAMS ((bfd * archive_bfd, bfd * abfd));
    152 
    153 
    154 static void
    155 print_value PARAMS ((bfd_vma));
    156 
    157 static void
    158 print_symbol_info_bsd PARAMS ((symbol_info * info, bfd * abfd));
    159 
    160 static void
    161 print_symbol_info_sysv PARAMS ((symbol_info * info, bfd * abfd));
    162 
    163 static void
    164 print_symbol_info_posix PARAMS ((symbol_info * info, bfd * abfd));
    165 
    166 static void
    167 get_relocs PARAMS ((bfd *, asection *, PTR));
     113static void print_object_filename_bsd
     114  PARAMS ((char *));
     115static void print_object_filename_sysv
     116  PARAMS ((char *));
     117static void print_object_filename_posix
     118  PARAMS ((char *));
     119static void print_archive_filename_bsd
     120  PARAMS ((char *));
     121static void print_archive_filename_sysv
     122  PARAMS ((char *));
     123static void print_archive_filename_posix
     124  PARAMS ((char *));
     125static void print_archive_member_bsd
     126  PARAMS ((char *, const char *));
     127static void print_archive_member_sysv
     128  PARAMS ((char *, const char *));
     129static void print_archive_member_posix
     130  PARAMS ((char *, const char *));
     131static void print_symbol_filename_bsd
     132  PARAMS ((bfd *, bfd *));
     133static void print_symbol_filename_sysv
     134  PARAMS ((bfd *, bfd *));
     135static void print_symbol_filename_posix
     136  PARAMS ((bfd *, bfd *));
     137static void print_value
     138  PARAMS ((bfd *, bfd_vma));
     139static void print_symbol_info_bsd
     140  PARAMS ((struct extended_symbol_info *, bfd *));
     141static void print_symbol_info_sysv
     142  PARAMS ((struct extended_symbol_info *, bfd *));
     143static void print_symbol_info_posix
     144  PARAMS ((struct extended_symbol_info *, bfd *));
     145static void get_relocs
     146  PARAMS ((bfd *, asection *, PTR));
     147static const char * get_symbol_type
     148  PARAMS ((unsigned int));
    168149
    169150/* Support for different output formats.  */
     
    171152  {
    172153    /* Print the name of an object file given on the command line.  */
    173     void (*print_object_filename) PARAMS ((char *filename));
     154    void (*print_object_filename) PARAMS ((char *));
    174155
    175156    /* Print the name of an archive file given on the command line.  */
    176     void (*print_archive_filename) PARAMS ((char *filename));
     157    void (*print_archive_filename) PARAMS ((char *));
    177158
    178159    /* Print the name of an archive member file.  */
    179     void (*print_archive_member) PARAMS ((char *archive, CONST char *filename));
     160    void (*print_archive_member) PARAMS ((char *, const char *));
    180161
    181162    /* Print the name of the file (and archive, if there is one)
    182163       containing a symbol.  */
    183     void (*print_symbol_filename) PARAMS ((bfd * archive_bfd, bfd * abfd));
     164    void (*print_symbol_filename) PARAMS ((bfd *, bfd *));
    184165
    185166    /* Print a line of information about a symbol.  */
    186     void (*print_symbol_info) PARAMS ((symbol_info * info, bfd * abfd));
     167    void (*print_symbol_info) PARAMS ((struct extended_symbol_info *, bfd *));
    187168  };
     169
    188170static struct output_fns formats[] =
    189171{
     
    214196static struct output_fns *format = &formats[FORMAT_DEFAULT];
    215197
    216 
    217198/* Command options.  */
    218199
    219200static int do_demangle = 0;     /* Pretty print C++ symbol names.  */
    220 static int external_only = 0;   /* print external symbols only */
    221 static int defined_only = 0;    /* Print defined symbols only */
    222 static int no_sort = 0;         /* don't sort; print syms in order found */
    223 static int print_debug_syms = 0;        /* print debugger-only symbols too */
    224 static int print_armap = 0;     /* describe __.SYMDEF data in archive files.  */
    225 static int reverse_sort = 0;    /* sort in downward(alpha or numeric) order */
    226 static int sort_numerically = 0;        /* sort in numeric rather than alpha order */
    227 static int sort_by_size = 0;    /* sort by size of symbol */
    228 static int undefined_only = 0;  /* print undefined symbols only */
    229 static int dynamic = 0;         /* print dynamic symbols.  */
    230 static int show_version = 0;    /* show the version number */
    231 static int show_stats = 0;      /* show statistics */
    232 static int line_numbers = 0;    /* print line numbers for symbols */
     201static int external_only = 0;   /* Print external symbols only.  */
     202static int defined_only = 0;    /* Print defined symbols only.  */
     203static int no_sort = 0;         /* Don't sort; print syms in order found.  */
     204static int print_debug_syms = 0;/* Print debugger-only symbols too.  */
     205static int print_armap = 0;     /* Describe __.SYMDEF data in archive files.  */
     206static int print_size = 0;      /* Print size of defined symbols.  */
     207static int reverse_sort = 0;    /* Sort in downward(alpha or numeric) order.  */
     208static int sort_numerically = 0;/* Sort in numeric rather than alpha order.  */
     209static int sort_by_size = 0;    /* Sort by size of symbol.  */
     210static int undefined_only = 0;  /* Print undefined symbols only.  */
     211static int dynamic = 0;         /* Print dynamic symbols.  */
     212static int show_version = 0;    /* Show the version number.  */
     213static int show_stats = 0;      /* Show statistics.  */
     214static int line_numbers = 0;    /* Print line numbers for symbols.  */
    233215
    234216/* When to print the names of files.  Not mutually exclusive in SYSV format.  */
     
    245227/* We don't use value_format for this case.  */
    246228#endif
     229#endif
     230#ifdef BFD64
     231static int print_width = 16;
     232#else
     233static int print_width = 8;
    247234#endif
    248235static int print_radix = 16;
     
    275262  {"print-armap", no_argument, &print_armap, 1},
    276263  {"print-file-name", no_argument, 0, 'o'},
     264  {"print-size", no_argument, 0, 'S'},
    277265  {"radix", required_argument, 0, 't'},
    278266  {"reverse-sort", no_argument, &reverse_sort, 1},
     
    287275
    288276
    289 /* Some error-reporting functions */
     277/* Some error-reporting functions. */
    290278
    291279static void
     
    294282     int status;
    295283{
    296   fprintf (stream, _("Usage: %s [OPTION]... [FILE]...\n"), program_name);
    297   fprintf (stream, _("List symbols from FILEs (a.out by default).\n"));
    298   fprintf (stream, _("\n\
     284  fprintf (stream, _("Usage: %s [option(s)] [file(s)]\n"), program_name);
     285  fprintf (stream, _(" List symbols in [file(s)] (a.out by default).\n"));
     286  fprintf (stream, _(" The options are:\n\
    299287  -a, --debug-syms       Display debugger-only symbols\n\
    300288  -A, --print-file-name  Print name of the input file before every symbol\n\
     
    302290  -C, --demangle[=STYLE] Decode low-level symbol names into user-level names\n\
    303291                          The STYLE, if specified, can be `auto' (the default),\n\
    304                           `gnu', 'lucid', 'arm', 'hp', 'edg' or 'gnu-new-abi'\n\
     292                          `gnu', `lucid', `arm', `hp', `edg', `gnu-v3', `java'\n\
     293                          or `gnat'\n\
    305294      --no-demangle      Do not demangle low-level symbol names\n\
    306295  -D, --dynamic          Display dynamic symbols instead of normal symbols\n\
     
    310299                           `sysv' or `posix'.  The default is `bsd'\n\
    311300  -g, --extern-only      Display only external symbols\n\
    312   -h, --help             Display this information\n\
    313301  -l, --line-numbers     Use debugging information to find a filename and\n\
    314302                           line number for each symbol\n\
     
    318306  -P, --portability      Same as --format=posix\n\
    319307  -r, --reverse-sort     Reverse the sense of the sort\n\
     308  -S, --print-size       Print size of defined symbols\n\
    320309  -s, --print-armap      Include index for symbols from archive members\n\
    321310      --size-sort        Sort symbols by size\n\
     
    323312      --target=BFDNAME   Specify the target object format as BFDNAME\n\
    324313  -u, --undefined-only   Display only undefined symbols\n\
     314  -X 32_64               (ignored)\n\
     315  -h, --help             Display this information\n\
    325316  -V, --version          Display this program's version number\n\
    326   -X 32_64               (ignored)\n\
    327317\n"));
    328318  list_supported_targets (program_name, stream);
     
    392382
    393383
     384int main PARAMS ((int, char **));
     385
    394386int
    395387main (argc, argv)
     
    403395  setlocale (LC_MESSAGES, "");
    404396#endif
     397#if defined (HAVE_SETLOCALE)
     398  setlocale (LC_CTYPE, "");
     399  setlocale (LC_COLLATE, "");
     400#endif
    405401  bindtextdomain (PACKAGE, LOCALEDIR);
    406402  textdomain (PACKAGE);
     
    414410  set_default_bfd_target ();
    415411
    416   while ((c = getopt_long (argc, argv, "aABCDef:glnopPrst:uvVX:",
     412  while ((c = getopt_long (argc, argv, "aABCDef:gHhlnopPrSst:uvVvX:",
    417413                           long_options, (int *) 0)) != EOF)
    418414    {
     
    434430            {
    435431              enum demangling_styles style;
    436              
     432
    437433              style = cplus_demangle_name_to_style (optarg);
    438               if (style == unknown_demangling) 
     434              if (style == unknown_demangling)
    439435                fatal (_("unknown demangling style `%s'"),
    440436                       optarg);
    441              
     437
    442438              cplus_demangle_set_style (style);
    443            }
     439            }
    444440          break;
    445441        case 'D':
     
    455451          external_only = 1;
    456452          break;
     453        case 'H':
    457454        case 'h':
    458455          usage (stdout, 0);
     
    475472        case 's':
    476473          print_armap = 1;
     474          break;
     475        case 'S':
     476          print_size = 1;
    477477          break;
    478478        case 't':
     
    512512    print_version ("nm");
    513513
     514  if (sort_by_size && undefined_only)
     515    {
     516      non_fatal (_("Using the --size-sort and --undefined-only options together"));
     517      non_fatal (_("will produce no output, since undefined symbols have no size."));
     518      return 0;
     519    }
     520
    514521  /* OK, all options now parsed.  If no filename specified, do a.out.  */
    515522  if (optind == argc)
     
    545552
    546553
     554static const char *
     555get_symbol_type (type)
     556     unsigned int type;
     557{
     558  static char buff [32];
     559
     560  switch (type)
     561    {
     562    case STT_NOTYPE:   return "NOTYPE";
     563    case STT_OBJECT:   return "OBJECT";
     564    case STT_FUNC:     return "FUNC";
     565    case STT_SECTION:  return "SECTION";
     566    case STT_FILE:     return "FILE";
     567    case STT_COMMON:   return "COMMON";
     568    case STT_TLS:      return "TLS";
     569    default:
     570      if (type >= STT_LOPROC && type <= STT_HIPROC)
     571        sprintf (buff, _("<processor specific>: %d"), type);
     572      else if (type >= STT_LOOS && type <= STT_HIOS)
     573        sprintf (buff, _("<OS specific>: %d"), type);
     574      else
     575        sprintf (buff, _("<unknown>: %d"), type);
     576      return buff;
     577    }
     578}
     579
    547580static void
    548581display_archive (file)
     
    573606      if (bfd_check_format_matches (arfile, bfd_object, &matching))
    574607        {
     608          char buf[30];
     609
     610          bfd_sprintf_vma (arfile, buf, (bfd_vma) -1);
     611          print_width = strlen (buf);
    575612          (*format->print_archive_member) (bfd_get_filename (file),
    576613                                           bfd_get_filename (arfile));
     
    604641}
    605642
    606 static boolean
     643static bfd_boolean
    607644display_file (filename)
    608645     char *filename;
    609646{
    610   boolean retval = true;
     647  bfd_boolean retval = TRUE;
    611648  bfd *file;
    612649  char **matching;
     
    616653    {
    617654      bfd_nonfatal (filename);
    618       return false;
     655      return FALSE;
    619656    }
    620657
     
    625662  else if (bfd_check_format_matches (file, bfd_object, &matching))
    626663    {
     664      char buf[30];
     665
     666      bfd_sprintf_vma (file, buf, (bfd_vma) -1);
     667      print_width = strlen (buf);
    627668      (*format->print_object_filename) (filename);
    628669      display_rel_file (file, NULL);
     
    636677          free (matching);
    637678        }
    638       retval = false;
    639     }
    640 
    641   if (bfd_close (file) == false)
     679      retval = FALSE;
     680    }
     681
     682  if (!bfd_close (file))
    642683    bfd_fatal (filename);
    643684
     
    652693   routines.  */
    653694static bfd *sort_bfd;
    654 static boolean sort_dynamic;
     695static bfd_boolean sort_dynamic;
    655696static asymbol *sort_x;
    656697static asymbol *sort_y;
     
    716757  yn = bfd_asymbol_name (y);
    717758
    718   return ((xn == NULL) ? ((yn == NULL) ? 0 : -1) :
    719           ((yn == NULL) ? 1 : strcmp (xn, yn)));
     759  if (yn == NULL)
     760    return xn != NULL;
     761  if (xn == NULL)
     762    return -1;
     763
     764#ifdef HAVE_STRCOLL
     765  /* Solaris 2.5 has a bug in strcoll.
     766     strcoll returns invalid values when confronted with empty strings.  */
     767  if (*yn == '\0')
     768    return *xn != '\0';
     769  if (*xn == '\0')
     770    return -1;
     771
     772  return strcoll (xn, yn);
     773#else
     774  return strcmp (xn, yn);
     775#endif
    720776}
    721777
     
    833889}
    834890
    835 /* Sort the symbols by size.  We guess the size by assuming that the
    836    difference between the address of a symbol and the address of the
    837    next higher symbol is the size.  FIXME: ELF actually stores a size
    838    with each symbol.  We should use it.  */
     891/* Sort the symbols by size.  ELF provides a size but for other formats
     892   we have to make a guess by assuming that the difference between the
     893   address of a symbol and the address of the next higher symbol is the
     894   size.  */
    839895
    840896static long
    841897sort_symbols_by_size (abfd, dynamic, minisyms, symcount, size, symsizesp)
    842898     bfd *abfd;
    843      boolean dynamic;
     899     bfd_boolean dynamic;
    844900     PTR minisyms;
    845901     long symcount;
     
    862918     undefined symbols.  Here we remove all symbols whose size winds
    863919     up as zero.  */
    864 
    865920  from = (bfd_byte *) minisyms;
    866921  fromend = from + symcount * size;
     
    898953      sec = bfd_get_section (sym);
    899954
    900       if (bfd_is_com_section (sec))
     955      if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
     956        sz = ((elf_symbol_type *) sym)->internal_elf_sym.st_size;
     957      else if (bfd_is_com_section (sec))
    901958        sz = sym->value;
    902959      else
     
    10051062filter_symbols (abfd, dynamic, minisyms, symcount, size)
    10061063     bfd *abfd;
    1007      boolean dynamic;
     1064     bfd_boolean dynamic;
    10081065     PTR minisyms;
    10091066     long symcount;
     
    10271084
    10281085      PROGRESS (1);
    1029      
     1086
    10301087      sym = bfd_minisymbol_to_symbol (abfd, dynamic, (const PTR) from, store);
    10311088      if (sym == NULL)
     
    10821139  if (do_demangle && *name)
    10831140    {
    1084       char *res;
    1085 
    1086       /* In this mode, give a user-level view of the symbol name
    1087          even if it's not mangled; strip off any leading
    1088          underscore.  */
    1089       if (bfd_get_symbol_leading_char (abfd) == name[0])
    1090         name++;
    1091 
    1092       res = cplus_demangle (name, DMGL_ANSI | DMGL_PARAMS);
    1093       if (res)
    1094         {
    1095           printf (format, res);
    1096           free (res);
    1097           return;
    1098         }
     1141      char *res = demangle (abfd, name);
     1142
     1143      printf (format, res);
     1144      free (res);
     1145      return;
    10991146    }
    11001147
     
    11081155print_symbols (abfd, dynamic, minisyms, symcount, size, archive_bfd)
    11091156     bfd *abfd;
    1110      boolean dynamic;
     1157     bfd_boolean dynamic;
    11111158     PTR minisyms;
    11121159     long symcount;
     
    11311178        bfd_fatal (bfd_get_filename (abfd));
    11321179
    1133       print_symbol (abfd, sym, archive_bfd);
     1180      print_symbol (abfd, sym, (bfd_vma) 0, archive_bfd);
    11341181    }
    11351182}
     
    11371184/* Print the symbols when sorting by size.  */
    11381185
    1139 static void 
     1186static void
    11401187print_size_symbols (abfd, dynamic, symsizes, symcount, archive_bfd)
    11411188     bfd *abfd;
    1142      boolean dynamic;
     1189     bfd_boolean dynamic;
    11431190     struct size_sym *symsizes;
    11441191     long symcount;
     
    11571204    {
    11581205      asymbol *sym;
     1206      bfd_vma ssize;
    11591207
    11601208      sym = bfd_minisymbol_to_symbol (abfd, dynamic, from->minisym, store);
     
    11621210        bfd_fatal (bfd_get_filename (abfd));
    11631211
    1164       /* Set the symbol value so that we actually display the symbol
    1165          size.  */
    1166       sym->value = from->size - bfd_section_vma (abfd, bfd_get_section (sym));
    1167 
    1168       print_symbol (abfd, sym, archive_bfd);
     1212      /* For elf we have already computed the correct symbol size.  */
     1213      if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
     1214        ssize = from->size;
     1215      else
     1216        ssize = from->size - bfd_section_vma (abfd, bfd_get_section (sym));
     1217
     1218      print_symbol (abfd, sym, ssize, archive_bfd);
    11691219    }
    11701220}
     
    11731223
    11741224static void
    1175 print_symbol (abfd, sym, archive_bfd)
     1225print_symbol (abfd, sym, ssize, archive_bfd)
    11761226     bfd *abfd;
    11771227     asymbol *sym;
     1228     bfd_vma ssize;
    11781229     bfd *archive_bfd;
    11791230{
     1231  symbol_info syminfo;
     1232  struct extended_symbol_info info;
     1233   
    11801234  PROGRESS (1);
    11811235
    11821236  (*format->print_symbol_filename) (archive_bfd, abfd);
    11831237
    1184   if (undefined_only)
    1185     {
    1186       if (bfd_is_und_section (bfd_get_section (sym)))
    1187         print_symname ("%s", bfd_asymbol_name (sym), abfd);
    1188     }
     1238  bfd_get_symbol_info (abfd, sym, &syminfo);
     1239  info.sinfo = &syminfo;
     1240  info.ssize = ssize;
     1241  if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
     1242    info.elfinfo = (elf_symbol_type *) sym;
    11891243  else
    1190     {
    1191       symbol_info syminfo;
    1192 
    1193       bfd_get_symbol_info (abfd, sym, &syminfo);
    1194       (*format->print_symbol_info) (&syminfo, abfd);
    1195     }
     1244    info.elfinfo = NULL;
     1245  (*format->print_symbol_info) (&info, abfd);
    11961246
    11971247  if (line_numbers)
     
    12351285          /* For an undefined symbol, we try to find a reloc for the
    12361286             symbol, and print the line number of the reloc.  */
    1237 
    12381287          if (abfd != lineno_cache_rel_bfd && relocs != NULL)
    12391288            {
     
    12841333                      && bfd_find_nearest_line (abfd, secs[i], syms,
    12851334                                                r->address, &filename,
    1286                                                 &functionname, &lineno))
     1335                                                &functionname, &lineno)
     1336                      && filename != NULL)
    12871337                    {
    12881338                      /* We only print the first one we find.  */
     
    13361386  else
    13371387    printf (_("\n\nSymbols from %s:\n\n"), filename);
    1338   printf (_("\
    1339 Name                  Value   Class        Type         Size   Line  Section\n\n"));
     1388  if (print_width == 8)
     1389    printf (_("\
     1390Name                  Value   Class        Type         Size     Line  Section\n\n"));
     1391  else
     1392    printf (_("\
     1393Name                  Value           Class        Type         Size             Line  Section\n\n"));
    13401394}
    13411395
     
    13771431print_archive_member_bsd (archive, filename)
    13781432     char *archive ATTRIBUTE_UNUSED;
    1379      CONST char *filename;
     1433     const char *filename;
    13801434{
    13811435  if (!filename_per_symbol)
     
    13861440print_archive_member_sysv (archive, filename)
    13871441     char *archive;
    1388      CONST char *filename;
     1442     const char *filename;
    13891443{
    13901444  if (undefined_only)
     
    13921446  else
    13931447    printf (_("\n\nSymbols from %s[%s]:\n\n"), archive, filename);
    1394   printf (_("\
    1395 Name                  Value   Class        Type         Size   Line  Section\n\n"));
     1448  if (print_width == 8)
     1449    printf (_("\
     1450Name                  Value   Class        Type         Size     Line  Section\n\n"));
     1451  else
     1452    printf (_("\
     1453Name                  Value           Class        Type         Size             Line  Section\n\n"));
    13961454}
    13971455
     
    13991457print_archive_member_posix (archive, filename)
    14001458     char *archive;
    1401      CONST char *filename;
     1459     const char *filename;
    14021460{
    14031461  if (!filename_per_symbol)
     
    14511509
    14521510static void
    1453 print_value (val)
     1511print_value (abfd, val)
     1512     bfd *abfd ATTRIBUTE_UNUSED;
    14541513     bfd_vma val;
    14551514{
     
    14591518  /* We have a 64 bit value to print, but the host is only 32 bit.  */
    14601519  if (print_radix == 16)
    1461     fprintf_vma (stdout, val);
     1520    bfd_fprintf_vma (abfd, stdout, val);
    14621521  else
    14631522    {
     
    14831542static void
    14841543print_symbol_info_bsd (info, abfd)
    1485      symbol_info *info;
     1544     struct extended_symbol_info *info;
    14861545     bfd *abfd;
    14871546{
    1488   if (bfd_is_undefined_symclass (info->type))
    1489     {
    1490 #ifdef BFD64
     1547  if (bfd_is_undefined_symclass (SYM_TYPE (info)))
     1548    {
     1549      if (print_width == 16)
     1550        printf ("        ");
    14911551      printf ("        ");
    1492 #endif
    1493       printf ("        ");
    14941552    }
    14951553  else
    1496     print_value (info->value);
    1497   printf (" %c", info->type);
    1498   if (info->type == '-')
     1554    {
     1555      /* Normally we print the value of the symbol.  If we are printing the
     1556         size or sorting by size then we print its size, execpt for the
     1557         (weird) special case where both flags are defined, in which case we
     1558         print both values.  This conforms to documented behaviour.  */
     1559      if (sort_by_size && !print_size)
     1560        print_value (abfd, SYM_SIZE (info));
     1561      else
     1562        print_value (abfd, SYM_VALUE (info));
     1563
     1564      if (print_size && SYM_SIZE (info))
     1565        {
     1566          printf (" ");
     1567          print_value (abfd, SYM_SIZE (info));
     1568        }
     1569    }
     1570
     1571  printf (" %c", SYM_TYPE (info));
     1572
     1573  if (SYM_TYPE (info) == '-')
    14991574    {
    15001575      /* A stab.  */
    15011576      printf (" ");
    1502       printf (other_format, info->stab_other);
     1577      printf (other_format, SYM_STAB_OTHER (info));
    15031578      printf (" ");
    1504       printf (desc_format, info->stab_desc);
    1505       printf (" %5s", info->stab_name);
    1506     }
    1507   print_symname (" %s", info->name, abfd);
     1579      printf (desc_format, SYM_STAB_DESC (info));
     1580      printf (" %5s", SYM_STAB_NAME (info));
     1581    }
     1582  print_symname (" %s", SYM_NAME (info), abfd);
    15081583}
    15091584
    15101585static void
    15111586print_symbol_info_sysv (info, abfd)
    1512      symbol_info *info;
     1587     struct extended_symbol_info *info;
    15131588     bfd *abfd;
    15141589{
    1515   print_symname ("%-20s|", info->name, abfd);   /* Name */
    1516   if (bfd_is_undefined_symclass (info->type))
    1517     printf ("        ");        /* Value */
     1590  print_symname ("%-20s|", SYM_NAME (info), abfd);
     1591
     1592  if (bfd_is_undefined_symclass (SYM_TYPE (info)))
     1593    {
     1594      if (print_width == 8)
     1595        printf ("        ");
     1596      else
     1597        printf ("                ");
     1598    }
    15181599  else
    1519     print_value (info->value);
    1520   printf ("|   %c  |", info->type);     /* Class */
    1521   if (info->type == '-')
     1600    print_value (abfd, SYM_VALUE (info));
     1601
     1602  printf ("|   %c  |", SYM_TYPE (info));
     1603
     1604  if (SYM_TYPE (info) == '-')
    15221605    {
    15231606      /* A stab.  */
    1524       printf ("%18s|  ", info->stab_name);      /* (C) Type */
    1525       printf (desc_format, info->stab_desc);    /* Size */
    1526       printf ("|     |");       /* Line, Section */
     1607      printf ("%18s|  ", SYM_STAB_NAME (info));         /* (C) Type. */
     1608      printf (desc_format, SYM_STAB_DESC (info));       /* Size. */
     1609      printf ("|     |");                               /* Line, Section. */
    15271610    }
    15281611  else
    1529     printf ("                  |      |     |");        /* Type, Size, Line, Section */
     1612    {
     1613      /* Type, Size, Line, Section */
     1614      if (info->elfinfo)
     1615        printf ("%18s|",
     1616                get_symbol_type (ELF_ST_TYPE (info->elfinfo->internal_elf_sym.st_info)));
     1617      else
     1618        printf ("                  |");
     1619
     1620      if (SYM_SIZE (info))
     1621        print_value (abfd, SYM_SIZE (info));
     1622      else
     1623        {
     1624          if (print_width == 8)
     1625            printf ("        ");
     1626          else
     1627            printf ("                ");
     1628        }
     1629
     1630      if (info->elfinfo)
     1631        printf("|     |%s", info->elfinfo->symbol.section->name);
     1632      else
     1633        printf("|     |");
     1634    }
    15301635}
    15311636
    15321637static void
    15331638print_symbol_info_posix (info, abfd)
    1534      symbol_info *info;
     1639     struct extended_symbol_info *info;
    15351640     bfd *abfd;
    15361641{
    1537   print_symname ("%s ", info->name, abfd);
    1538   printf ("%c ", info->type);
    1539   if (bfd_is_undefined_symclass (info->type))
     1642  print_symname ("%s ", SYM_NAME (info), abfd);
     1643  printf ("%c ", SYM_TYPE (info));
     1644
     1645  if (bfd_is_undefined_symclass (SYM_TYPE (info)))
    15401646    printf ("        ");
    15411647  else
    1542     print_value (info->value);
    1543   /* POSIX.2 wants the symbol size printed here, when applicable;
    1544      BFD currently doesn't provide it, so we take the easy way out by
    1545      considering it to never be applicable.  */
     1648    {
     1649      print_value (abfd, SYM_VALUE (info));
     1650      printf (" ");
     1651      if (SYM_SIZE (info))
     1652        print_value (abfd, SYM_SIZE (info));
     1653    }
    15461654}
    15471655
     
    15531661  symindex idx = BFD_NO_MORE_SYMBOLS;
    15541662  carsym *thesym;
    1555   boolean everprinted = false;
     1663  bfd_boolean everprinted = FALSE;
    15561664
    15571665  for (idx = bfd_get_next_mapent (abfd, idx, &thesym);
     
    15631671        {
    15641672          printf (_("\nArchive index:\n"));
    1565           everprinted = true;
     1673          everprinted = TRUE;
    15661674        }
    15671675      elt = bfd_get_elt_at_index (abfd, idx);
Note: See TracChangeset for help on using the changeset viewer.