Changeset 609 for branches/GNU/src/binutils/binutils/nm.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/binutils/nm.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* nm.c -- Describe symbol table of a rel file. 2 2 Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 3 2001 3 2001, 2002, 2003 4 4 Free Software Foundation, Inc. 5 5 … … 24 24 #include "progress.h" 25 25 #include "bucomm.h" 26 #include "budemang.h" 26 27 #include "getopt.h" 27 28 #include "aout/stab_gnu.h" … … 29 30 #include "demangle.h" 30 31 #include "libiberty.h" 32 #include "elf-bfd.h" 33 #include "elf/common.h" 31 34 32 35 /* When sorting by size, we use this structure to hold the size and a … … 50 53 }; 51 54 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)); 55 struct 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 71 static void usage 72 PARAMS ((FILE *, int)); 73 static void set_print_radix 74 PARAMS ((char *)); 75 static void set_output_format 76 PARAMS ((char *)); 77 static void display_archive 78 PARAMS ((bfd *)); 79 static bfd_boolean display_file 80 PARAMS ((char *)); 81 static void display_rel_file 82 PARAMS ((bfd *, bfd *)); 83 static long filter_symbols 84 PARAMS ((bfd *, bfd_boolean, PTR, long, unsigned int)); 85 static long sort_symbols_by_size 86 PARAMS ((bfd *, bfd_boolean, PTR, long, unsigned int, struct size_sym **)); 87 static void print_symbols 88 PARAMS ((bfd *, bfd_boolean, PTR, long, unsigned int, bfd *)); 89 static void print_size_symbols 90 PARAMS ((bfd *, bfd_boolean, struct size_sym *, long, bfd *)); 91 static void print_symname 92 PARAMS ((const char *, const char *, bfd *)); 93 static void print_symbol 94 PARAMS ((bfd *, asymbol *, bfd_vma ssize, bfd *)); 95 static void print_symdef_entry 96 PARAMS ((bfd *)); 91 97 92 98 /* 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)); 99 static int numeric_forward 100 PARAMS ((const PTR, const PTR)); 101 static int numeric_reverse 102 PARAMS ((const PTR, const PTR)); 103 static int non_numeric_forward 104 PARAMS ((const PTR, const PTR)); 105 static int non_numeric_reverse 106 PARAMS ((const PTR, const PTR)); 107 static int size_forward1 108 PARAMS ((const PTR, const PTR)); 109 static int size_forward2 110 PARAMS ((const PTR, const PTR)); 111 111 112 112 /* 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)); 113 static void print_object_filename_bsd 114 PARAMS ((char *)); 115 static void print_object_filename_sysv 116 PARAMS ((char *)); 117 static void print_object_filename_posix 118 PARAMS ((char *)); 119 static void print_archive_filename_bsd 120 PARAMS ((char *)); 121 static void print_archive_filename_sysv 122 PARAMS ((char *)); 123 static void print_archive_filename_posix 124 PARAMS ((char *)); 125 static void print_archive_member_bsd 126 PARAMS ((char *, const char *)); 127 static void print_archive_member_sysv 128 PARAMS ((char *, const char *)); 129 static void print_archive_member_posix 130 PARAMS ((char *, const char *)); 131 static void print_symbol_filename_bsd 132 PARAMS ((bfd *, bfd *)); 133 static void print_symbol_filename_sysv 134 PARAMS ((bfd *, bfd *)); 135 static void print_symbol_filename_posix 136 PARAMS ((bfd *, bfd *)); 137 static void print_value 138 PARAMS ((bfd *, bfd_vma)); 139 static void print_symbol_info_bsd 140 PARAMS ((struct extended_symbol_info *, bfd *)); 141 static void print_symbol_info_sysv 142 PARAMS ((struct extended_symbol_info *, bfd *)); 143 static void print_symbol_info_posix 144 PARAMS ((struct extended_symbol_info *, bfd *)); 145 static void get_relocs 146 PARAMS ((bfd *, asection *, PTR)); 147 static const char * get_symbol_type 148 PARAMS ((unsigned int)); 168 149 169 150 /* Support for different output formats. */ … … 171 152 { 172 153 /* 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 *)); 174 155 175 156 /* 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 *)); 177 158 178 159 /* 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 *)); 180 161 181 162 /* Print the name of the file (and archive, if there is one) 182 163 containing a symbol. */ 183 void (*print_symbol_filename) PARAMS ((bfd * archive_bfd, bfd * abfd));164 void (*print_symbol_filename) PARAMS ((bfd *, bfd *)); 184 165 185 166 /* Print a line of information about a symbol. */ 186 void (*print_symbol_info) PARAMS ((s ymbol_info * info, bfd * abfd));167 void (*print_symbol_info) PARAMS ((struct extended_symbol_info *, bfd *)); 187 168 }; 169 188 170 static struct output_fns formats[] = 189 171 { … … 214 196 static struct output_fns *format = &formats[FORMAT_DEFAULT]; 215 197 216 217 198 /* Command options. */ 218 199 219 200 static 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 */ 201 static int external_only = 0; /* Print external symbols only. */ 202 static int defined_only = 0; /* Print defined symbols only. */ 203 static int no_sort = 0; /* Don't sort; print syms in order found. */ 204 static int print_debug_syms = 0;/* Print debugger-only symbols too. */ 205 static int print_armap = 0; /* Describe __.SYMDEF data in archive files. */ 206 static int print_size = 0; /* Print size of defined symbols. */ 207 static int reverse_sort = 0; /* Sort in downward(alpha or numeric) order. */ 208 static int sort_numerically = 0;/* Sort in numeric rather than alpha order. */ 209 static int sort_by_size = 0; /* Sort by size of symbol. */ 210 static int undefined_only = 0; /* Print undefined symbols only. */ 211 static int dynamic = 0; /* Print dynamic symbols. */ 212 static int show_version = 0; /* Show the version number. */ 213 static int show_stats = 0; /* Show statistics. */ 214 static int line_numbers = 0; /* Print line numbers for symbols. */ 233 215 234 216 /* When to print the names of files. Not mutually exclusive in SYSV format. */ … … 245 227 /* We don't use value_format for this case. */ 246 228 #endif 229 #endif 230 #ifdef BFD64 231 static int print_width = 16; 232 #else 233 static int print_width = 8; 247 234 #endif 248 235 static int print_radix = 16; … … 275 262 {"print-armap", no_argument, &print_armap, 1}, 276 263 {"print-file-name", no_argument, 0, 'o'}, 264 {"print-size", no_argument, 0, 'S'}, 277 265 {"radix", required_argument, 0, 't'}, 278 266 {"reverse-sort", no_argument, &reverse_sort, 1}, … … 287 275 288 276 289 /* Some error-reporting functions */277 /* Some error-reporting functions. */ 290 278 291 279 static void … … 294 282 int status; 295 283 { 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\ 299 287 -a, --debug-syms Display debugger-only symbols\n\ 300 288 -A, --print-file-name Print name of the input file before every symbol\n\ … … 302 290 -C, --demangle[=STYLE] Decode low-level symbol names into user-level names\n\ 303 291 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\ 305 294 --no-demangle Do not demangle low-level symbol names\n\ 306 295 -D, --dynamic Display dynamic symbols instead of normal symbols\n\ … … 310 299 `sysv' or `posix'. The default is `bsd'\n\ 311 300 -g, --extern-only Display only external symbols\n\ 312 -h, --help Display this information\n\313 301 -l, --line-numbers Use debugging information to find a filename and\n\ 314 302 line number for each symbol\n\ … … 318 306 -P, --portability Same as --format=posix\n\ 319 307 -r, --reverse-sort Reverse the sense of the sort\n\ 308 -S, --print-size Print size of defined symbols\n\ 320 309 -s, --print-armap Include index for symbols from archive members\n\ 321 310 --size-sort Sort symbols by size\n\ … … 323 312 --target=BFDNAME Specify the target object format as BFDNAME\n\ 324 313 -u, --undefined-only Display only undefined symbols\n\ 314 -X 32_64 (ignored)\n\ 315 -h, --help Display this information\n\ 325 316 -V, --version Display this program's version number\n\ 326 -X 32_64 (ignored)\n\327 317 \n")); 328 318 list_supported_targets (program_name, stream); … … 392 382 393 383 384 int main PARAMS ((int, char **)); 385 394 386 int 395 387 main (argc, argv) … … 403 395 setlocale (LC_MESSAGES, ""); 404 396 #endif 397 #if defined (HAVE_SETLOCALE) 398 setlocale (LC_CTYPE, ""); 399 setlocale (LC_COLLATE, ""); 400 #endif 405 401 bindtextdomain (PACKAGE, LOCALEDIR); 406 402 textdomain (PACKAGE); … … 414 410 set_default_bfd_target (); 415 411 416 while ((c = getopt_long (argc, argv, "aABCDef:g lnopPrst:uvVX:",412 while ((c = getopt_long (argc, argv, "aABCDef:gHhlnopPrSst:uvVvX:", 417 413 long_options, (int *) 0)) != EOF) 418 414 { … … 434 430 { 435 431 enum demangling_styles style; 436 432 437 433 style = cplus_demangle_name_to_style (optarg); 438 if (style == unknown_demangling) 434 if (style == unknown_demangling) 439 435 fatal (_("unknown demangling style `%s'"), 440 436 optarg); 441 437 442 438 cplus_demangle_set_style (style); 443 439 } 444 440 break; 445 441 case 'D': … … 455 451 external_only = 1; 456 452 break; 453 case 'H': 457 454 case 'h': 458 455 usage (stdout, 0); … … 475 472 case 's': 476 473 print_armap = 1; 474 break; 475 case 'S': 476 print_size = 1; 477 477 break; 478 478 case 't': … … 512 512 print_version ("nm"); 513 513 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 514 521 /* OK, all options now parsed. If no filename specified, do a.out. */ 515 522 if (optind == argc) … … 545 552 546 553 554 static const char * 555 get_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 547 580 static void 548 581 display_archive (file) … … 573 606 if (bfd_check_format_matches (arfile, bfd_object, &matching)) 574 607 { 608 char buf[30]; 609 610 bfd_sprintf_vma (arfile, buf, (bfd_vma) -1); 611 print_width = strlen (buf); 575 612 (*format->print_archive_member) (bfd_get_filename (file), 576 613 bfd_get_filename (arfile)); … … 604 641 } 605 642 606 static b oolean643 static bfd_boolean 607 644 display_file (filename) 608 645 char *filename; 609 646 { 610 b oolean retval = true;647 bfd_boolean retval = TRUE; 611 648 bfd *file; 612 649 char **matching; … … 616 653 { 617 654 bfd_nonfatal (filename); 618 return false;655 return FALSE; 619 656 } 620 657 … … 625 662 else if (bfd_check_format_matches (file, bfd_object, &matching)) 626 663 { 664 char buf[30]; 665 666 bfd_sprintf_vma (file, buf, (bfd_vma) -1); 667 print_width = strlen (buf); 627 668 (*format->print_object_filename) (filename); 628 669 display_rel_file (file, NULL); … … 636 677 free (matching); 637 678 } 638 retval = false;639 } 640 641 if ( bfd_close (file) == false)679 retval = FALSE; 680 } 681 682 if (!bfd_close (file)) 642 683 bfd_fatal (filename); 643 684 … … 652 693 routines. */ 653 694 static bfd *sort_bfd; 654 static b oolean sort_dynamic;695 static bfd_boolean sort_dynamic; 655 696 static asymbol *sort_x; 656 697 static asymbol *sort_y; … … 716 757 yn = bfd_asymbol_name (y); 717 758 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 720 776 } 721 777 … … 833 889 } 834 890 835 /* Sort the symbols by size. We guess the size by assuming that the836 difference between the address of a symbol and the address ofthe837 next higher symbol is the size. FIXME: ELF actually stores a size838 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. */ 839 895 840 896 static long 841 897 sort_symbols_by_size (abfd, dynamic, minisyms, symcount, size, symsizesp) 842 898 bfd *abfd; 843 b oolean dynamic;899 bfd_boolean dynamic; 844 900 PTR minisyms; 845 901 long symcount; … … 862 918 undefined symbols. Here we remove all symbols whose size winds 863 919 up as zero. */ 864 865 920 from = (bfd_byte *) minisyms; 866 921 fromend = from + symcount * size; … … 898 953 sec = bfd_get_section (sym); 899 954 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)) 901 958 sz = sym->value; 902 959 else … … 1005 1062 filter_symbols (abfd, dynamic, minisyms, symcount, size) 1006 1063 bfd *abfd; 1007 b oolean dynamic;1064 bfd_boolean dynamic; 1008 1065 PTR minisyms; 1009 1066 long symcount; … … 1027 1084 1028 1085 PROGRESS (1); 1029 1086 1030 1087 sym = bfd_minisymbol_to_symbol (abfd, dynamic, (const PTR) from, store); 1031 1088 if (sym == NULL) … … 1082 1139 if (do_demangle && *name) 1083 1140 { 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; 1099 1146 } 1100 1147 … … 1108 1155 print_symbols (abfd, dynamic, minisyms, symcount, size, archive_bfd) 1109 1156 bfd *abfd; 1110 b oolean dynamic;1157 bfd_boolean dynamic; 1111 1158 PTR minisyms; 1112 1159 long symcount; … … 1131 1178 bfd_fatal (bfd_get_filename (abfd)); 1132 1179 1133 print_symbol (abfd, sym, archive_bfd);1180 print_symbol (abfd, sym, (bfd_vma) 0, archive_bfd); 1134 1181 } 1135 1182 } … … 1137 1184 /* Print the symbols when sorting by size. */ 1138 1185 1139 static void 1186 static void 1140 1187 print_size_symbols (abfd, dynamic, symsizes, symcount, archive_bfd) 1141 1188 bfd *abfd; 1142 b oolean dynamic;1189 bfd_boolean dynamic; 1143 1190 struct size_sym *symsizes; 1144 1191 long symcount; … … 1157 1204 { 1158 1205 asymbol *sym; 1206 bfd_vma ssize; 1159 1207 1160 1208 sym = bfd_minisymbol_to_symbol (abfd, dynamic, from->minisym, store); … … 1162 1210 bfd_fatal (bfd_get_filename (abfd)); 1163 1211 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); 1169 1219 } 1170 1220 } … … 1173 1223 1174 1224 static void 1175 print_symbol (abfd, sym, archive_bfd)1225 print_symbol (abfd, sym, ssize, archive_bfd) 1176 1226 bfd *abfd; 1177 1227 asymbol *sym; 1228 bfd_vma ssize; 1178 1229 bfd *archive_bfd; 1179 1230 { 1231 symbol_info syminfo; 1232 struct extended_symbol_info info; 1233 1180 1234 PROGRESS (1); 1181 1235 1182 1236 (*format->print_symbol_filename) (archive_bfd, abfd); 1183 1237 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; 1189 1243 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); 1196 1246 1197 1247 if (line_numbers) … … 1235 1285 /* For an undefined symbol, we try to find a reloc for the 1236 1286 symbol, and print the line number of the reloc. */ 1237 1238 1287 if (abfd != lineno_cache_rel_bfd && relocs != NULL) 1239 1288 { … … 1284 1333 && bfd_find_nearest_line (abfd, secs[i], syms, 1285 1334 r->address, &filename, 1286 &functionname, &lineno)) 1335 &functionname, &lineno) 1336 && filename != NULL) 1287 1337 { 1288 1338 /* We only print the first one we find. */ … … 1336 1386 else 1337 1387 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 (_("\ 1390 Name Value Class Type Size Line Section\n\n")); 1391 else 1392 printf (_("\ 1393 Name Value Class Type Size Line Section\n\n")); 1340 1394 } 1341 1395 … … 1377 1431 print_archive_member_bsd (archive, filename) 1378 1432 char *archive ATTRIBUTE_UNUSED; 1379 CONSTchar *filename;1433 const char *filename; 1380 1434 { 1381 1435 if (!filename_per_symbol) … … 1386 1440 print_archive_member_sysv (archive, filename) 1387 1441 char *archive; 1388 CONSTchar *filename;1442 const char *filename; 1389 1443 { 1390 1444 if (undefined_only) … … 1392 1446 else 1393 1447 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 (_("\ 1450 Name Value Class Type Size Line Section\n\n")); 1451 else 1452 printf (_("\ 1453 Name Value Class Type Size Line Section\n\n")); 1396 1454 } 1397 1455 … … 1399 1457 print_archive_member_posix (archive, filename) 1400 1458 char *archive; 1401 CONSTchar *filename;1459 const char *filename; 1402 1460 { 1403 1461 if (!filename_per_symbol) … … 1451 1509 1452 1510 static void 1453 print_value (val) 1511 print_value (abfd, val) 1512 bfd *abfd ATTRIBUTE_UNUSED; 1454 1513 bfd_vma val; 1455 1514 { … … 1459 1518 /* We have a 64 bit value to print, but the host is only 32 bit. */ 1460 1519 if (print_radix == 16) 1461 fprintf_vma (stdout, val);1520 bfd_fprintf_vma (abfd, stdout, val); 1462 1521 else 1463 1522 { … … 1483 1542 static void 1484 1543 print_symbol_info_bsd (info, abfd) 1485 s ymbol_info *info;1544 struct extended_symbol_info *info; 1486 1545 bfd *abfd; 1487 1546 { 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 (" "); 1491 1551 printf (" "); 1492 #endif1493 printf (" ");1494 1552 } 1495 1553 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) == '-') 1499 1574 { 1500 1575 /* A stab. */ 1501 1576 printf (" "); 1502 printf (other_format, info->stab_other);1577 printf (other_format, SYM_STAB_OTHER (info)); 1503 1578 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); 1508 1583 } 1509 1584 1510 1585 static void 1511 1586 print_symbol_info_sysv (info, abfd) 1512 s ymbol_info *info;1587 struct extended_symbol_info *info; 1513 1588 bfd *abfd; 1514 1589 { 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 } 1518 1599 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) == '-') 1522 1605 { 1523 1606 /* 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. */ 1527 1610 } 1528 1611 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 } 1530 1635 } 1531 1636 1532 1637 static void 1533 1638 print_symbol_info_posix (info, abfd) 1534 s ymbol_info *info;1639 struct extended_symbol_info *info; 1535 1640 bfd *abfd; 1536 1641 { 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))) 1540 1646 printf (" "); 1541 1647 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 } 1546 1654 } 1547 1655 … … 1553 1661 symindex idx = BFD_NO_MORE_SYMBOLS; 1554 1662 carsym *thesym; 1555 b oolean everprinted = false;1663 bfd_boolean everprinted = FALSE; 1556 1664 1557 1665 for (idx = bfd_get_next_mapent (abfd, idx, &thesym); … … 1563 1671 { 1564 1672 printf (_("\nArchive index:\n")); 1565 everprinted = true;1673 everprinted = TRUE; 1566 1674 } 1567 1675 elt = bfd_get_elt_at_index (abfd, idx); -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.