Changeset 609 for branches/GNU/src/binutils/bfd/syms.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/bfd/syms.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* Generic symbol-table support for the BFD library. 2 2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 3 2000 3 2000, 2001, 2002, 2003 4 4 Free Software Foundation, Inc. 5 5 Written by Cygnus Support. 6 6 7 This file is part of BFD, the Binary File Descriptor library.8 9 This program is free software; you can redistribute it and/or modify10 it under the terms of the GNU General Public License as published by11 the Free Software Foundation; either version 2 of the License, or12 (at your option) any later version.13 14 This program is distributed in the hope that it will be useful,15 but WITHOUT ANY WARRANTY; without even the implied warranty of16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the17 GNU General Public License for more details.18 19 You should have received a copy of the GNU General Public License20 along with this program; if not, write to the Free Software21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */7 This file is part of BFD, the Binary File Descriptor library. 8 9 This program is free software; you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation; either version 2 of the License, or 12 (at your option) any later version. 13 14 This program is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program; if not, write to the Free Software 21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 22 22 23 23 /* … … 75 75 | FAIL 76 76 | 77 | if (storage_needed == 0) {78 | return;79 | }77 | if (storage_needed == 0) 78 | return; 79 | 80 80 | symbol_table = (asymbol **) xmalloc (storage_needed); 81 81 | ... … … 86 86 | FAIL 87 87 | 88 | for (i = 0; i < number_of_symbols; i++) { 89 | process_symbol (symbol_table[i]); 90 | } 88 | for (i = 0; i < number_of_symbols; i++) 89 | process_symbol (symbol_table[i]); 91 90 92 91 All storage for the symbols themselves is in an objalloc … … 109 108 110 109 | #include "bfd.h" 111 | main()110 | int main (void) 112 111 | { 113 112 | bfd *abfd; … … 115 114 | asymbol *new; 116 115 | 117 | abfd = bfd_openw ("foo","a.out-sunos-big");118 | bfd_set_format (abfd, bfd_object);119 | new = bfd_make_empty_symbol (abfd);116 | abfd = bfd_openw ("foo","a.out-sunos-big"); 117 | bfd_set_format (abfd, bfd_object); 118 | new = bfd_make_empty_symbol (abfd); 120 119 | new->name = "dummy_symbol"; 121 | new->section = bfd_make_section_old_way (abfd, ".text");120 | new->section = bfd_make_section_old_way (abfd, ".text"); 122 121 | new->flags = BSF_GLOBAL; 123 122 | new->value = 0x12345; … … 126 125 | ptrs[1] = (asymbol *)0; 127 126 | 128 | bfd_set_symtab(abfd, ptrs, 1); 129 | bfd_close(abfd); 127 | bfd_set_symtab (abfd, ptrs, 1); 128 | bfd_close (abfd); 129 | return 0; 130 130 | } 131 131 | … … 184 184 .typedef struct symbol_cache_entry 185 185 .{ 186 . {* A pointer to the BFD which owns the symbol. This information 187 . is necessary so that a back end can work out what additional 188 . information (invisible to the application writer) is carried 189 . with the symbol. 190 . 191 . This field is *almost* redundant, since you can use section->owner 192 . instead, except that some symbols point to the global sections 193 . bfd_{abs,com,und}_section. This could be fixed by making 194 . these globals be per-bfd (or per-target-flavor). FIXME. *} 195 . 196 . struct _bfd *the_bfd; {* Use bfd_asymbol_bfd(sym) to access this field. *} 197 . 198 . {* The text of the symbol. The name is left alone, and not copied; the 199 . application may not alter it. *} 200 . CONST char *name; 201 . 202 . {* The value of the symbol. This really should be a union of a 203 . numeric value with a pointer, since some flags indicate that 204 . a pointer to another symbol is stored here. *} 186 . {* A pointer to the BFD which owns the symbol. This information 187 . is necessary so that a back end can work out what additional 188 . information (invisible to the application writer) is carried 189 . with the symbol. 190 . 191 . This field is *almost* redundant, since you can use section->owner 192 . instead, except that some symbols point to the global sections 193 . bfd_{abs,com,und}_section. This could be fixed by making 194 . these globals be per-bfd (or per-target-flavor). FIXME. *} 195 . struct bfd *the_bfd; {* Use bfd_asymbol_bfd(sym) to access this field. *} 196 . 197 . {* The text of the symbol. The name is left alone, and not copied; the 198 . application may not alter it. *} 199 . const char *name; 200 . 201 . {* The value of the symbol. This really should be a union of a 202 . numeric value with a pointer, since some flags indicate that 203 . a pointer to another symbol is stored here. *} 205 204 . symvalue value; 206 205 . 207 . {* Attributes of a symbol: *} 208 . 206 . {* Attributes of a symbol. *} 209 207 .#define BSF_NO_FLAGS 0x00 210 208 . 211 . 212 . is the offset into the section of the data.*}209 . {* The symbol has local scope; <<static>> in <<C>>. The value 210 . is the offset into the section of the data. *} 213 211 .#define BSF_LOCAL 0x01 214 212 . 215 . 216 . value is the offset into the section of the data.*}213 . {* The symbol has global scope; initialized data in <<C>>. The 214 . value is the offset into the section of the data. *} 217 215 .#define BSF_GLOBAL 0x02 218 216 . 219 . 220 . the offset into the section of the data.*}221 .#define BSF_EXPORT BSF_GLOBAL {* no real difference*}222 . 223 . 224 . 225 . <<BSF_GLOBAL>>*}226 . 227 . 228 . 217 . {* The symbol has global scope and is exported. The value is 218 . the offset into the section of the data. *} 219 .#define BSF_EXPORT BSF_GLOBAL {* No real difference. *} 220 . 221 . {* A normal C symbol would be one of: 222 . <<BSF_LOCAL>>, <<BSF_FORT_COMM>>, <<BSF_UNDEFINED>> or 223 . <<BSF_GLOBAL>>. *} 224 . 225 . {* The symbol is a debugging record. The value has an arbitary 226 . meaning, unless BSF_DEBUGGING_RELOC is also set. *} 229 227 .#define BSF_DEBUGGING 0x08 230 228 . 231 . 232 . 229 . {* The symbol denotes a function entry point. Used in ELF, 230 . perhaps others someday. *} 233 231 .#define BSF_FUNCTION 0x10 234 232 . 235 . {* Used by the linker.*}233 . {* Used by the linker. *} 236 234 .#define BSF_KEEP 0x20 237 235 .#define BSF_KEEP_G 0x40 238 236 . 239 . 240 . 237 . {* A weak global symbol, overridable without warnings by 238 . a regular global symbol of the same name. *} 241 239 .#define BSF_WEAK 0x80 242 240 . 243 . 244 . 241 . {* This symbol was created to point to a section, e.g. ELF's 242 . STT_SECTION symbols. *} 245 243 .#define BSF_SECTION_SYM 0x100 246 244 . 247 . 248 . allocated.*}245 . {* The symbol used to be a common symbol, but now it is 246 . allocated. *} 249 247 .#define BSF_OLD_COMMON 0x200 250 248 . 251 . {* The default value for common data.*}249 . {* The default value for common data. *} 252 250 .#define BFD_FORT_COMM_DEFAULT_VALUE 0 253 251 . 254 . {* In some files the type of a symbol sometimes alters its 255 . location in an output file - ie in coff a <<ISFCN>> symbol 256 . which is also <<C_EXT>> symbol appears where it was 257 . declared and not at the end of a section. This bit is set 258 . by the target BFD part to convey this information. *} 259 . 252 . {* In some files the type of a symbol sometimes alters its 253 . location in an output file - ie in coff a <<ISFCN>> symbol 254 . which is also <<C_EXT>> symbol appears where it was 255 . declared and not at the end of a section. This bit is set 256 . by the target BFD part to convey this information. *} 260 257 .#define BSF_NOT_AT_END 0x400 261 258 . 262 . {* Signal that the symbol is the label of constructor section.*}259 . {* Signal that the symbol is the label of constructor section. *} 263 260 .#define BSF_CONSTRUCTOR 0x800 264 261 . 265 . 266 . 267 . 268 . symbol, a warning is issued by the linker.*}262 . {* Signal that the symbol is a warning symbol. The name is a 263 . warning. The name of the next symbol is the one to warn about; 264 . if a reference is made to a symbol with the same name as the next 265 . symbol, a warning is issued by the linker. *} 269 266 .#define BSF_WARNING 0x1000 270 267 . 271 . 272 . pointer to the symbol with the same name as the next symbol.*}268 . {* Signal that the symbol is indirect. This symbol is an indirect 269 . pointer to the symbol with the same name as the next symbol. *} 273 270 .#define BSF_INDIRECT 0x2000 274 271 . 275 . 276 . 272 . {* BSF_FILE marks symbols that contain a file name. This is used 273 . for ELF STT_FILE symbols. *} 277 274 .#define BSF_FILE 0x4000 278 275 . 279 . 276 . {* Symbol is from dynamic linking information. *} 280 277 .#define BSF_DYNAMIC 0x8000 281 278 . 282 . 283 . 279 . {* The symbol denotes a data object. Used in ELF, and perhaps 280 . others someday. *} 284 281 .#define BSF_OBJECT 0x10000 285 282 . 286 . 287 . 288 . 283 . {* This symbol is a debugging symbol. The value is the offset 284 . into the section of the data. BSF_DEBUGGING should be set 285 . as well. *} 289 286 .#define BSF_DEBUGGING_RELOC 0x20000 290 287 . 288 . {* This symbol is thread local. Used in ELF. *} 289 .#define BSF_THREAD_LOCAL 0x40000 290 . 291 291 . flagword flags; 292 292 . 293 . 294 . 295 . 293 . {* A pointer to the section to which this symbol is 294 . relative. This will always be non NULL, there are special 295 . sections for undefined and absolute symbols. *} 296 296 . struct sec *section; 297 297 . 298 . 298 . {* Back end special data. *} 299 299 . union 300 300 . { 301 301 . PTR p; 302 302 . bfd_vma i; 303 . } udata; 304 . 305 .} asymbol; 303 . } 304 . udata; 305 .} 306 .asymbol; 307 . 306 308 */ 307 309 … … 309 311 #include "sysdep.h" 310 312 #include "libbfd.h" 313 #include "safe-ctype.h" 311 314 #include "bfdlink.h" 312 315 #include "aout/stab_gnu.h" 313 316 314 317 static char coff_section_type PARAMS ((const char *)); 318 static char decode_section_type PARAMS ((const struct sec *)); 319 static int cmpindexentry PARAMS ((const PTR, const PTR)); 315 320 316 321 /* … … 334 339 .#define bfd_get_symtab_upper_bound(abfd) \ 335 340 . BFD_SEND (abfd, _bfd_get_symtab_upper_bound, (abfd)) 336 341 . 337 342 */ 338 343 … … 342 347 343 348 SYNOPSIS 344 b oolean bfd_is_local_label(bfd *abfd, asymbol *sym);349 bfd_boolean bfd_is_local_label (bfd *abfd, asymbol *sym); 345 350 346 351 DESCRIPTION 347 Return trueif the given symbol @var{sym} in the BFD @var{abfd} is348 a compiler generated local label, else return false.349 */ 350 351 b oolean352 Return TRUE if the given symbol @var{sym} in the BFD @var{abfd} is 353 a compiler generated local label, else return FALSE. 354 */ 355 356 bfd_boolean 352 357 bfd_is_local_label (abfd, sym) 353 358 bfd *abfd; 354 359 asymbol *sym; 355 360 { 356 if ((sym->flags & (BSF_GLOBAL | BSF_WEAK)) != 0) 357 return false; 361 /* The BSF_SECTION_SYM check is needed for IA-64, where every label that 362 starts with '.' is local. This would accidentally catch section names 363 if we didn't reject them here. */ 364 if ((sym->flags & (BSF_GLOBAL | BSF_WEAK | BSF_SECTION_SYM)) != 0) 365 return FALSE; 358 366 if (sym->name == NULL) 359 return false;367 return FALSE; 360 368 return bfd_is_local_label_name (abfd, sym->name); 361 369 } … … 366 374 367 375 SYNOPSIS 368 b oolean bfd_is_local_label_name(bfd *abfd, const char *name);376 bfd_boolean bfd_is_local_label_name (bfd *abfd, const char *name); 369 377 370 378 DESCRIPTION 371 Return trueif a symbol with the name @var{name} in the BFD379 Return TRUE if a symbol with the name @var{name} in the BFD 372 380 @var{abfd} is a compiler generated local label, else return 373 false. This just checks whether the name has the form of a381 FALSE. This just checks whether the name has the form of a 374 382 local label. 375 383 376 384 .#define bfd_is_local_label_name(abfd, name) \ 377 385 . BFD_SEND (abfd, _bfd_is_local_label_name, (abfd, name)) 386 . 378 387 */ 379 388 … … 392 401 . BFD_SEND (abfd, _bfd_canonicalize_symtab,\ 393 402 . (abfd, location)) 394 403 . 395 404 */ 396 405 … … 400 409 401 410 SYNOPSIS 402 b oolean bfd_set_symtab (bfd *abfd, asymbol **location, unsigned int count);411 bfd_boolean bfd_set_symtab (bfd *abfd, asymbol **location, unsigned int count); 403 412 404 413 DESCRIPTION … … 408 417 */ 409 418 410 b oolean419 bfd_boolean 411 420 bfd_set_symtab (abfd, location, symcount) 412 421 bfd *abfd; … … 417 426 { 418 427 bfd_set_error (bfd_error_invalid_operation); 419 return false;428 return FALSE; 420 429 } 421 430 422 431 bfd_get_outsymbols (abfd) = location; 423 432 bfd_get_symcount (abfd) = symcount; 424 return true;433 return TRUE; 425 434 } 426 435 … … 430 439 431 440 SYNOPSIS 432 void bfd_print_symbol_vandf (PTR file, asymbol *symbol);441 void bfd_print_symbol_vandf (bfd *abfd, PTR file, asymbol *symbol); 433 442 434 443 DESCRIPTION … … 437 446 */ 438 447 void 439 bfd_print_symbol_vandf (arg, symbol) 448 bfd_print_symbol_vandf (abfd, arg, symbol) 449 bfd *abfd; 440 450 PTR arg; 441 451 asymbol *symbol; 442 452 { 443 453 FILE *file = (FILE *) arg; 454 444 455 flagword type = symbol->flags; 456 445 457 if (symbol->section != (asection *) NULL) 446 { 447 fprintf_vma (file, symbol->value + symbol->section->vma); 448 } 458 bfd_fprintf_vma (abfd, file, 459 symbol->value + symbol->section->vma); 449 460 else 450 { 451 fprintf_vma (file, symbol->value); 452 } 461 bfd_fprintf_vma (abfd, file, symbol->value); 453 462 454 463 /* This presumes that a symbol can not be both BSF_DEBUGGING and … … 486 495 .#define bfd_make_empty_symbol(abfd) \ 487 496 . BFD_SEND (abfd, _bfd_make_empty_symbol, (abfd)) 488 */ 497 . 498 */ 499 500 /* 501 FUNCTION 502 _bfd_generic_make_empty_symbol 503 504 SYNOPSIS 505 asymbol * _bfd_generic_make_empty_symbol (bfd *); 506 507 DESCRIPTION 508 Create a new <<asymbol>> structure for the BFD @var{abfd} 509 and return a pointer to it. Used by core file routines, 510 binary back-end and anywhere else where no private info 511 is needed. 512 */ 513 514 asymbol * 515 _bfd_generic_make_empty_symbol (abfd) 516 bfd *abfd; 517 { 518 bfd_size_type amt = sizeof (asymbol); 519 asymbol *new = (asymbol *) bfd_zalloc (abfd, amt); 520 if (new) 521 new->the_bfd = abfd; 522 return new; 523 } 489 524 490 525 /* … … 499 534 .#define bfd_make_debug_symbol(abfd,ptr,size) \ 500 535 . BFD_SEND (abfd, _bfd_make_debug_symbol, (abfd, ptr, size)) 536 . 501 537 */ 502 538 503 539 struct section_to_type 504 540 { 505 CONSTchar *section;541 const char *section; 506 542 char type; 507 543 }; … … 510 546 This table is probably incomplete. It is sorted for convenience of 511 547 adding entries. Since it is so short, a linear search is used. */ 512 static CONST struct section_to_type stt[] = 513 { 548 static const struct section_to_type stt[] = 549 { 550 {".bss", 'b'}, 551 {"code", 't'}, /* MRI .text */ 552 {".data", 'd'}, 514 553 {"*DEBUG*", 'N'}, 515 {".bss", 'b'}, 516 {"zerovars", 'b'}, /* MRI .bss */ 517 {".data", 'd'}, 518 {"vars", 'd'}, /* MRI .data */ 554 {".debug", 'N'}, /* MSVC's .debug (non-standard debug syms) */ 555 {".drectve", 'i'}, /* MSVC's .drective section */ 556 {".edata", 'e'}, /* MSVC's .edata (export) section */ 557 {".fini", 't'}, /* ELF fini section */ 558 {".idata", 'i'}, /* MSVC's .idata (import) section */ 559 {".init", 't'}, /* ELF init section */ 560 {".pdata", 'p'}, /* MSVC's .pdata (stack unwind) section */ 519 561 {".rdata", 'r'}, /* Read only data. */ 520 562 {".rodata", 'r'}, /* Read only data. */ … … 523 565 {".sdata", 'g'}, /* Small initialized data. */ 524 566 {".text", 't'}, 525 {"code", 't'}, /* MRI .text */ 526 {".drectve", 'i'}, /* MSVC's .drective section */ 527 {".idata", 'i'}, /* MSVC's .idata (import) section */ 528 {".edata", 'e'}, /* MSVC's .edata (export) section */ 529 {".pdata", 'p'}, /* MSVC's .pdata (stack unwind) section */ 530 {".debug", 'N'}, /* MSVC's .debug (non-standard debug syms) */ 567 {"vars", 'd'}, /* MRI .data */ 568 {"zerovars", 'b'}, /* MRI .bss */ 531 569 {0, 0} 532 570 }; … … 542 580 const char *s; 543 581 { 544 CONSTstruct section_to_type *t;582 const struct section_to_type *t; 545 583 546 584 for (t = &stt[0]; t->section; t++) … … 551 589 } 552 590 553 #ifndef islower 554 #define islower(c) ((c) >= 'a' && (c) <= 'z') 555 #endif 556 #ifndef toupper 557 #define toupper(c) (islower(c) ? ((c) & ~0x20) : (c)) 558 #endif 591 /* Return the single-character symbol type corresponding to section 592 SECTION, or '?' for an unknown section. This uses section flags to 593 identify sections. 594 595 FIXME These types are unhandled: c, i, e, p. If we handled these also, 596 we could perhaps obsolete coff_section_type. */ 597 598 static char 599 decode_section_type (section) 600 const struct sec *section; 601 { 602 if (section->flags & SEC_CODE) 603 return 't'; 604 if (section->flags & SEC_DATA) 605 { 606 if (section->flags & SEC_READONLY) 607 return 'r'; 608 else if (section->flags & SEC_SMALL_DATA) 609 return 'g'; 610 else 611 return 'd'; 612 } 613 if ((section->flags & SEC_HAS_CONTENTS) == 0) 614 { 615 if (section->flags & SEC_SMALL_DATA) 616 return 's'; 617 else 618 return 'b'; 619 } 620 if (section->flags & SEC_DEBUGGING) 621 return 'N'; 622 623 return '?'; 624 } 559 625 560 626 /* … … 567 633 568 634 SYNOPSIS 569 int bfd_decode_symclass (asymbol *symbol);635 int bfd_decode_symclass (asymbol *symbol); 570 636 */ 571 637 int … … 608 674 c = 'a'; 609 675 else if (symbol->section) 610 c = coff_section_type (symbol->section->name); 676 { 677 c = coff_section_type (symbol->section->name); 678 if (c == '?') 679 c = decode_section_type (symbol->section); 680 } 611 681 else 612 682 return '?'; 613 683 if (symbol->flags & BSF_GLOBAL) 614 c = toupper(c);684 c = TOUPPER (c); 615 685 return c; 616 686 … … 635 705 636 706 SYNOPSIS 637 b oolean bfd_is_undefined_symclass (int symclass);638 */ 639 640 b oolean707 bfd_boolean bfd_is_undefined_symclass (int symclass); 708 */ 709 710 bfd_boolean 641 711 bfd_is_undefined_symclass (symclass) 642 712 int symclass; … … 655 725 656 726 SYNOPSIS 657 void bfd_symbol_info (asymbol *symbol, symbol_info *ret);727 void bfd_symbol_info (asymbol *symbol, symbol_info *ret); 658 728 */ 659 729 … … 678 748 679 749 SYNOPSIS 680 b oolean bfd_copy_private_symbol_data(bfd *ibfd, asymbol *isym, bfd *obfd, asymbol *osym);750 bfd_boolean bfd_copy_private_symbol_data (bfd *ibfd, asymbol *isym, bfd *obfd, asymbol *osym); 681 751 682 752 DESCRIPTION 683 753 Copy private symbol information from @var{isym} in the BFD 684 754 @var{ibfd} to the symbol @var{osym} in the BFD @var{obfd}. 685 Return << true>> on success, <<false>> on error. Possible error755 Return <<TRUE>> on success, <<FALSE>> on error. Possible error 686 756 returns are: 687 757 … … 692 762 . BFD_SEND (obfd, _bfd_copy_private_symbol_data, \ 693 763 . (ibfd, isymbol, obfd, osymbol)) 694 764 . 695 765 */ 696 766 … … 702 772 _bfd_generic_read_minisymbols (abfd, dynamic, minisymsp, sizep) 703 773 bfd *abfd; 704 b oolean dynamic;774 bfd_boolean dynamic; 705 775 PTR *minisymsp; 706 776 unsigned int *sizep; … … 716 786 if (storage < 0) 717 787 goto error_return; 718 719 syms = (asymbol **) bfd_malloc ((size_t) storage); 788 if (storage == 0) 789 return 0; 790 791 syms = (asymbol **) bfd_malloc ((bfd_size_type) storage); 720 792 if (syms == NULL) 721 793 goto error_return; … … 733 805 734 806 error_return: 807 bfd_set_error (bfd_error_no_symbols); 735 808 if (syms != NULL) 736 809 free (syms); … … 742 815 we just return the asymbol the minisymbol points to. */ 743 816 744 /*ARGSUSED*/745 817 asymbol * 746 818 _bfd_generic_minisymbol_to_symbol (abfd, dynamic, minisym, sym) 747 819 bfd *abfd ATTRIBUTE_UNUSED; 748 b oolean dynamic ATTRIBUTE_UNUSED;820 bfd_boolean dynamic ATTRIBUTE_UNUSED; 749 821 const PTR minisym; 750 822 asymbol *sym ATTRIBUTE_UNUSED; … … 756 828 sections to find the source file and line closest to a desired 757 829 location. This is used by COFF and ELF targets. It sets *pfound 758 to trueif it finds some information. The *pinfo field is used to830 to TRUE if it finds some information. The *pinfo field is used to 759 831 pass cached information in and out of this routine; this first time 760 832 the routine is called for a BFD, *pinfo should be NULL. The value … … 828 900 }; 829 901 830 b oolean902 bfd_boolean 831 903 _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound, 832 904 pfilename, pfnname, pline, pinfo) … … 835 907 asection *section; 836 908 bfd_vma offset; 837 b oolean *pfound;909 bfd_boolean *pfound; 838 910 const char **pfilename; 839 911 const char **pfnname; … … 847 919 bfd_size_type stroff; 848 920 struct indexentry *indexentry; 849 char *directory_name, *file_name; 921 char *file_name; 922 char *directory_name; 850 923 int saw_fun; 851 852 *pfound = false; 924 bfd_boolean saw_line, saw_func; 925 926 *pfound = FALSE; 853 927 *pfilename = bfd_get_filename (abfd); 854 928 *pfnname = NULL; … … 881 955 { 882 956 /* No stabs debugging information. */ 883 return true;957 return TRUE; 884 958 } 885 959 … … 893 967 int i; 894 968 char *name; 895 char *file_name;896 char *directory_name;897 969 char *function_name; 898 899 info = (struct stab_find_info *) bfd_zalloc (abfd, sizeof *info); 970 bfd_size_type amt = sizeof *info; 971 972 info = (struct stab_find_info *) bfd_zalloc (abfd, amt); 900 973 if (info == NULL) 901 return false;974 return FALSE; 902 975 903 976 /* FIXME: When using the linker --split-by-file or … … 913 986 can return quickly in the info != NULL case above. */ 914 987 *pinfo = (PTR) info; 915 return true;988 return TRUE; 916 989 } 917 990 … … 922 995 info->strs = (bfd_byte *) bfd_alloc (abfd, strsize); 923 996 if (info->stabs == NULL || info->strs == NULL) 924 return false;925 926 if (! bfd_get_section_contents (abfd, info->stabsec, info->stabs, 0,927 stabsize)928 || ! bfd_get_section_contents (abfd, info->strsec, info->strs, 0,929 strsize))930 return false;997 return FALSE; 998 999 if (! bfd_get_section_contents (abfd, info->stabsec, info->stabs, 1000 (bfd_vma) 0, stabsize) 1001 || ! bfd_get_section_contents (abfd, info->strsec, info->strs, 1002 (bfd_vma) 0, strsize)) 1003 return FALSE; 931 1004 932 1005 /* If this is a relocateable object file, we have to relocate … … 936 1009 reloc_size = bfd_get_reloc_upper_bound (abfd, info->stabsec); 937 1010 if (reloc_size < 0) 938 return false;939 reloc_vector = (arelent **) bfd_malloc ( reloc_size);1011 return FALSE; 1012 reloc_vector = (arelent **) bfd_malloc ((bfd_size_type) reloc_size); 940 1013 if (reloc_vector == NULL && reloc_size != 0) 941 return false;1014 return FALSE; 942 1015 reloc_count = bfd_canonicalize_reloc (abfd, info->stabsec, reloc_vector, 943 1016 symbols); … … 946 1019 if (reloc_vector != NULL) 947 1020 free (reloc_vector); 948 return false;1021 return FALSE; 949 1022 } 950 1023 if (reloc_count > 0) … … 971 1044 if (reloc_vector != NULL) 972 1045 free (reloc_vector); 973 return false;1046 return FALSE; 974 1047 } 975 1048 … … 978 1051 sym = *r->sym_ptr_ptr; 979 1052 val += sym->value + sym->section->vma + r->addend; 980 bfd_put_32 (abfd, val, info->stabs + r->address);1053 bfd_put_32 (abfd, (bfd_vma) val, info->stabs + r->address); 981 1054 } 982 1055 } … … 995 1068 for (stab = info->stabs; stab < info->stabs + stabsize; stab += STABSIZE) 996 1069 { 997 if (stab[TYPEOFF] == N_SO)1070 if (stab[TYPEOFF] == (bfd_byte) N_SO) 998 1071 { 999 1072 /* N_SO with null name indicates EOF */ … … 1009 1082 /* two N_SO's in a row is a filename and directory. Skip */ 1010 1083 if (stab + STABSIZE < info->stabs + stabsize 1011 && *(stab + STABSIZE + TYPEOFF) == N_SO)1084 && *(stab + STABSIZE + TYPEOFF) == (bfd_byte) N_SO) 1012 1085 { 1013 1086 stab += STABSIZE; 1014 1087 } 1015 1088 } 1016 else if (stab[TYPEOFF] == N_FUN)1089 else if (stab[TYPEOFF] == (bfd_byte) N_FUN) 1017 1090 { 1018 1091 saw_fun = 1; … … 1025 1098 1026 1099 if (info->indextablesize == 0) 1027 return true;1100 return TRUE; 1028 1101 ++info->indextablesize; 1029 1102 1030 info->indextable = ((struct indexentry *) 1031 bfd_alloc (abfd, 1032 (sizeof (struct indexentry) 1033 * info->indextablesize))); 1103 amt = info->indextablesize; 1104 amt *= sizeof (struct indexentry); 1105 info->indextable = (struct indexentry *) bfd_alloc (abfd, amt); 1034 1106 if (info->indextable == NULL) 1035 return false;1107 return FALSE; 1036 1108 1037 1109 file_name = NULL; … … 1084 1156 last_stab = stab; 1085 1157 if (stab + STABSIZE >= info->stabs + stabsize 1086 || *(stab + STABSIZE + TYPEOFF) != N_SO)1158 || *(stab + STABSIZE + TYPEOFF) != (bfd_byte) N_SO) 1087 1159 { 1088 1160 directory_name = NULL; … … 1149 1221 1150 1222 info->indextablesize = i; 1151 qsort (info->indextable, i, sizeof (struct indexentry), cmpindexentry); 1223 qsort (info->indextable, (size_t) i, sizeof (struct indexentry), 1224 cmpindexentry); 1152 1225 1153 1226 *pinfo = (PTR) info; … … 1170 1243 #endif 1171 1244 { 1245 long low, high; 1246 long mid = -1; 1247 1172 1248 /* Cache non-existant or invalid. Do binary search on 1173 1249 indextable. */ 1174 1175 long low, high;1176 long mid = -1;1177 1178 1250 indexentry = NULL; 1179 1251 … … 1197 1269 1198 1270 if (indexentry == NULL) 1199 return true;1271 return TRUE; 1200 1272 1201 1273 stab = indexentry->stab + STABSIZE; … … 1206 1278 str = indexentry->str; 1207 1279 1280 saw_line = FALSE; 1281 saw_func = FALSE; 1208 1282 for (; stab < (indexentry+1)->stab; stab += STABSIZE) 1209 1283 { 1210 b oolean done;1284 bfd_boolean done; 1211 1285 bfd_vma val; 1212 1286 1213 done = false;1287 done = FALSE; 1214 1288 1215 1289 switch (stab[TYPEOFF]) … … 1228 1302 case N_DSLINE: 1229 1303 case N_BSLINE: 1230 /* A line number. The value is relative to the start of the 1231 current function. */ 1232 val = indexentry->val + bfd_get_32 (abfd, stab + VALOFF); 1233 if (val <= offset) 1304 /* A line number. If the function was specified, then the value 1305 is relative to the start of the function. Otherwise, the 1306 value is an absolute address. */ 1307 val = ((indexentry->function_name ? indexentry->val : 0) 1308 + bfd_get_32 (abfd, stab + VALOFF)); 1309 /* If this line starts before our desired offset, or if it's 1310 the first line we've been able to find, use it. The 1311 !saw_line check works around a bug in GCC 2.95.3, which emits 1312 the first N_SLINE late. */ 1313 if (!saw_line || val <= offset) 1234 1314 { 1235 1315 *pline = bfd_get_16 (abfd, stab + DESCOFF); … … 1243 1323 } 1244 1324 if (val > offset) 1245 done = true; 1325 done = TRUE; 1326 saw_line = TRUE; 1246 1327 break; 1247 1328 1248 1329 case N_FUN: 1249 1330 case N_SO: 1250 done = true; 1331 if (saw_func || saw_line) 1332 done = TRUE; 1333 saw_func = TRUE; 1251 1334 break; 1252 1335 } … … 1256 1339 } 1257 1340 1258 *pfound = true; 1259 1260 if (IS_ABSOLUTE_PATH(file_name) || directory_name == NULL) 1341 *pfound = TRUE; 1342 1343 if (file_name == NULL || IS_ABSOLUTE_PATH (file_name) 1344 || directory_name == NULL) 1261 1345 *pfilename = file_name; 1262 1346 else … … 1269 1353 || strcmp (info->filename + dirlen, file_name) != 0) 1270 1354 { 1355 size_t len; 1356 1271 1357 if (info->filename != NULL) 1272 1358 free (info->filename); 1273 info->filename = (char *) bfd_malloc (dirlen + 1274 strlen (file_name) 1275 + 1); 1359 len = strlen (file_name) + 1; 1360 info->filename = (char *) bfd_malloc ((bfd_size_type) dirlen + len); 1276 1361 if (info->filename == NULL) 1277 return false;1278 strcpy (info->filename, directory_name);1279 strcpy (info->filename + dirlen, file_name);1362 return FALSE; 1363 memcpy (info->filename, directory_name, dirlen); 1364 memcpy (info->filename + dirlen, file_name, len); 1280 1365 } 1281 1366 … … 1290 1375 to clobber the colon. It's OK to change the name, since the 1291 1376 string is in our own local storage anyhow. */ 1292 1293 1377 s = strchr (indexentry->function_name, ':'); 1294 1378 if (s != NULL) … … 1298 1382 } 1299 1383 1300 return true;1384 return TRUE; 1301 1385 } -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.