Changeset 618 for trunk/src/binutils/bfd/syms.c
- Timestamp:
- Aug 16, 2003, 11:33:53 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/binutils/bfd/syms.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r617 r618 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 . 291 . {* Symbol is an emx import reference. *} 288 . {* This symbol is thread local. Used in ELF. *} 289 .#define BSF_THREAD_LOCAL 0x40000 290 . 291 . {* Symbol is an emx import reference. *} 292 292 .#define BSF_EMX_IMPORT1 0x20000000 293 293 . 294 . 294 . {* Symbol is an emx import definition. *} 295 295 .#define BSF_EMX_IMPORT2 0x40000000 296 296 . 297 297 . flagword flags; 298 298 . 299 . 300 . 301 . 299 . {* A pointer to the section to which this symbol is 300 . relative. This will always be non NULL, there are special 301 . sections for undefined and absolute symbols. *} 302 302 . struct sec *section; 303 303 . 304 . 304 . {* Back end special data. *} 305 305 . union 306 306 . { 307 307 . PTR p; 308 308 . bfd_vma i; 309 . } udata; 310 . 311 .} asymbol; 309 . } 310 . udata; 311 .} 312 .asymbol; 313 . 312 314 */ 313 315 … … 315 317 #include "sysdep.h" 316 318 #include "libbfd.h" 319 #include "safe-ctype.h" 317 320 #include "bfdlink.h" 318 321 #include "aout/stab_gnu.h" 319 322 320 323 static char coff_section_type PARAMS ((const char *)); 324 static char decode_section_type PARAMS ((const struct sec *)); 325 static int cmpindexentry PARAMS ((const PTR, const PTR)); 321 326 322 327 /* … … 340 345 .#define bfd_get_symtab_upper_bound(abfd) \ 341 346 . BFD_SEND (abfd, _bfd_get_symtab_upper_bound, (abfd)) 342 347 . 343 348 */ 344 349 … … 348 353 349 354 SYNOPSIS 350 b oolean bfd_is_local_label(bfd *abfd, asymbol *sym);355 bfd_boolean bfd_is_local_label (bfd *abfd, asymbol *sym); 351 356 352 357 DESCRIPTION 353 Return trueif the given symbol @var{sym} in the BFD @var{abfd} is354 a compiler generated local label, else return false.355 */ 356 357 b oolean358 Return TRUE if the given symbol @var{sym} in the BFD @var{abfd} is 359 a compiler generated local label, else return FALSE. 360 */ 361 362 bfd_boolean 358 363 bfd_is_local_label (abfd, sym) 359 364 bfd *abfd; 360 365 asymbol *sym; 361 366 { 362 if ((sym->flags & (BSF_GLOBAL | BSF_WEAK)) != 0) 363 return false; 367 /* The BSF_SECTION_SYM check is needed for IA-64, where every label that 368 starts with '.' is local. This would accidentally catch section names 369 if we didn't reject them here. */ 370 if ((sym->flags & (BSF_GLOBAL | BSF_WEAK | BSF_SECTION_SYM)) != 0) 371 return FALSE; 364 372 if (sym->name == NULL) 365 return false;373 return FALSE; 366 374 return bfd_is_local_label_name (abfd, sym->name); 367 375 } … … 372 380 373 381 SYNOPSIS 374 b oolean bfd_is_local_label_name(bfd *abfd, const char *name);382 bfd_boolean bfd_is_local_label_name (bfd *abfd, const char *name); 375 383 376 384 DESCRIPTION 377 Return trueif a symbol with the name @var{name} in the BFD385 Return TRUE if a symbol with the name @var{name} in the BFD 378 386 @var{abfd} is a compiler generated local label, else return 379 false. This just checks whether the name has the form of a387 FALSE. This just checks whether the name has the form of a 380 388 local label. 381 389 382 390 .#define bfd_is_local_label_name(abfd, name) \ 383 391 . BFD_SEND (abfd, _bfd_is_local_label_name, (abfd, name)) 392 . 384 393 */ 385 394 … … 398 407 . BFD_SEND (abfd, _bfd_canonicalize_symtab,\ 399 408 . (abfd, location)) 400 409 . 401 410 */ 402 411 … … 406 415 407 416 SYNOPSIS 408 b oolean bfd_set_symtab (bfd *abfd, asymbol **location, unsigned int count);417 bfd_boolean bfd_set_symtab (bfd *abfd, asymbol **location, unsigned int count); 409 418 410 419 DESCRIPTION … … 414 423 */ 415 424 416 b oolean425 bfd_boolean 417 426 bfd_set_symtab (abfd, location, symcount) 418 427 bfd *abfd; … … 423 432 { 424 433 bfd_set_error (bfd_error_invalid_operation); 425 return false;434 return FALSE; 426 435 } 427 436 428 437 bfd_get_outsymbols (abfd) = location; 429 438 bfd_get_symcount (abfd) = symcount; 430 return true;439 return TRUE; 431 440 } 432 441 … … 436 445 437 446 SYNOPSIS 438 void bfd_print_symbol_vandf (PTR file, asymbol *symbol);447 void bfd_print_symbol_vandf (bfd *abfd, PTR file, asymbol *symbol); 439 448 440 449 DESCRIPTION … … 443 452 */ 444 453 void 445 bfd_print_symbol_vandf (arg, symbol) 454 bfd_print_symbol_vandf (abfd, arg, symbol) 455 bfd *abfd; 446 456 PTR arg; 447 457 asymbol *symbol; 448 458 { 449 459 FILE *file = (FILE *) arg; 460 450 461 flagword type = symbol->flags; 462 451 463 if (symbol->section != (asection *) NULL) 452 { 453 fprintf_vma (file, symbol->value + symbol->section->vma); 454 } 464 bfd_fprintf_vma (abfd, file, 465 symbol->value + symbol->section->vma); 455 466 else 456 { 457 fprintf_vma (file, symbol->value); 458 } 467 bfd_fprintf_vma (abfd, file, symbol->value); 459 468 460 469 /* This presumes that a symbol can not be both BSF_DEBUGGING and … … 496 505 .#define bfd_make_empty_symbol(abfd) \ 497 506 . BFD_SEND (abfd, _bfd_make_empty_symbol, (abfd)) 498 */ 507 . 508 */ 509 510 /* 511 FUNCTION 512 _bfd_generic_make_empty_symbol 513 514 SYNOPSIS 515 asymbol * _bfd_generic_make_empty_symbol (bfd *); 516 517 DESCRIPTION 518 Create a new <<asymbol>> structure for the BFD @var{abfd} 519 and return a pointer to it. Used by core file routines, 520 binary back-end and anywhere else where no private info 521 is needed. 522 */ 523 524 asymbol * 525 _bfd_generic_make_empty_symbol (abfd) 526 bfd *abfd; 527 { 528 bfd_size_type amt = sizeof (asymbol); 529 asymbol *new = (asymbol *) bfd_zalloc (abfd, amt); 530 if (new) 531 new->the_bfd = abfd; 532 return new; 533 } 499 534 500 535 /* … … 509 544 .#define bfd_make_debug_symbol(abfd,ptr,size) \ 510 545 . BFD_SEND (abfd, _bfd_make_debug_symbol, (abfd, ptr, size)) 546 . 511 547 */ 512 548 513 549 struct section_to_type 514 550 { 515 CONSTchar *section;551 const char *section; 516 552 char type; 517 553 }; … … 520 556 This table is probably incomplete. It is sorted for convenience of 521 557 adding entries. Since it is so short, a linear search is used. */ 522 static CONST struct section_to_type stt[] = 523 { 558 static const struct section_to_type stt[] = 559 { 560 {".bss", 'b'}, 561 {"code", 't'}, /* MRI .text */ 562 {".data", 'd'}, 524 563 {"*DEBUG*", 'N'}, 525 {".bss", 'b'}, 526 {"zerovars", 'b'}, /* MRI .bss */ 527 {".data", 'd'}, 528 {"vars", 'd'}, /* MRI .data */ 564 {".debug", 'N'}, /* MSVC's .debug (non-standard debug syms) */ 565 {".drectve", 'i'}, /* MSVC's .drective section */ 566 {".edata", 'e'}, /* MSVC's .edata (export) section */ 567 {".fini", 't'}, /* ELF fini section */ 568 {".idata", 'i'}, /* MSVC's .idata (import) section */ 569 {".init", 't'}, /* ELF init section */ 570 {".pdata", 'p'}, /* MSVC's .pdata (stack unwind) section */ 529 571 {".rdata", 'r'}, /* Read only data. */ 530 572 {".rodata", 'r'}, /* Read only data. */ … … 533 575 {".sdata", 'g'}, /* Small initialized data. */ 534 576 {".text", 't'}, 535 {"code", 't'}, /* MRI .text */ 536 {".drectve", 'i'}, /* MSVC's .drective section */ 537 {".idata", 'i'}, /* MSVC's .idata (import) section */ 538 {".edata", 'e'}, /* MSVC's .edata (export) section */ 539 {".pdata", 'p'}, /* MSVC's .pdata (stack unwind) section */ 540 {".debug", 'N'}, /* MSVC's .debug (non-standard debug syms) */ 577 {"vars", 'd'}, /* MRI .data */ 578 {"zerovars", 'b'}, /* MRI .bss */ 541 579 {0, 0} 542 580 }; … … 552 590 const char *s; 553 591 { 554 CONSTstruct section_to_type *t;592 const struct section_to_type *t; 555 593 556 594 for (t = &stt[0]; t->section; t++) … … 561 599 } 562 600 563 #ifndef islower 564 #define islower(c) ((c) >= 'a' && (c) <= 'z') 565 #endif 566 #ifndef toupper 567 #define toupper(c) (islower(c) ? ((c) & ~0x20) : (c)) 568 #endif 601 /* Return the single-character symbol type corresponding to section 602 SECTION, or '?' for an unknown section. This uses section flags to 603 identify sections. 604 605 FIXME These types are unhandled: c, i, e, p. If we handled these also, 606 we could perhaps obsolete coff_section_type. */ 607 608 static char 609 decode_section_type (section) 610 const struct sec *section; 611 { 612 if (section->flags & SEC_CODE) 613 return 't'; 614 if (section->flags & SEC_DATA) 615 { 616 if (section->flags & SEC_READONLY) 617 return 'r'; 618 else if (section->flags & SEC_SMALL_DATA) 619 return 'g'; 620 else 621 return 'd'; 622 } 623 if ((section->flags & SEC_HAS_CONTENTS) == 0) 624 { 625 if (section->flags & SEC_SMALL_DATA) 626 return 's'; 627 else 628 return 'b'; 629 } 630 if (section->flags & SEC_DEBUGGING) 631 return 'N'; 632 633 return '?'; 634 } 569 635 570 636 /* … … 577 643 578 644 SYNOPSIS 579 int bfd_decode_symclass (asymbol *symbol);645 int bfd_decode_symclass (asymbol *symbol); 580 646 */ 581 647 int … … 624 690 c = 'a'; 625 691 else if (symbol->section) 626 c = coff_section_type (symbol->section->name); 692 { 693 c = coff_section_type (symbol->section->name); 694 if (c == '?') 695 c = decode_section_type (symbol->section); 696 } 627 697 else 628 698 return '?'; 629 699 if (symbol->flags & BSF_GLOBAL) 630 c = toupper(c);700 c = TOUPPER (c); 631 701 return c; 632 702 … … 651 721 652 722 SYNOPSIS 653 b oolean bfd_is_undefined_symclass (int symclass);654 */ 655 656 b oolean723 bfd_boolean bfd_is_undefined_symclass (int symclass); 724 */ 725 726 bfd_boolean 657 727 bfd_is_undefined_symclass (symclass) 658 728 int symclass; … … 671 741 672 742 SYNOPSIS 673 void bfd_symbol_info (asymbol *symbol, symbol_info *ret);743 void bfd_symbol_info (asymbol *symbol, symbol_info *ret); 674 744 */ 675 745 … … 694 764 695 765 SYNOPSIS 696 b oolean bfd_copy_private_symbol_data(bfd *ibfd, asymbol *isym, bfd *obfd, asymbol *osym);766 bfd_boolean bfd_copy_private_symbol_data (bfd *ibfd, asymbol *isym, bfd *obfd, asymbol *osym); 697 767 698 768 DESCRIPTION 699 769 Copy private symbol information from @var{isym} in the BFD 700 770 @var{ibfd} to the symbol @var{osym} in the BFD @var{obfd}. 701 Return << true>> on success, <<false>> on error. Possible error771 Return <<TRUE>> on success, <<FALSE>> on error. Possible error 702 772 returns are: 703 773 … … 708 778 . BFD_SEND (obfd, _bfd_copy_private_symbol_data, \ 709 779 . (ibfd, isymbol, obfd, osymbol)) 710 780 . 711 781 */ 712 782 … … 718 788 _bfd_generic_read_minisymbols (abfd, dynamic, minisymsp, sizep) 719 789 bfd *abfd; 720 b oolean dynamic;790 bfd_boolean dynamic; 721 791 PTR *minisymsp; 722 792 unsigned int *sizep; … … 732 802 if (storage < 0) 733 803 goto error_return; 734 735 syms = (asymbol **) bfd_malloc ((size_t) storage); 804 if (storage == 0) 805 return 0; 806 807 syms = (asymbol **) bfd_malloc ((bfd_size_type) storage); 736 808 if (syms == NULL) 737 809 goto error_return; … … 749 821 750 822 error_return: 823 bfd_set_error (bfd_error_no_symbols); 751 824 if (syms != NULL) 752 825 free (syms); … … 758 831 we just return the asymbol the minisymbol points to. */ 759 832 760 /*ARGSUSED*/761 833 asymbol * 762 834 _bfd_generic_minisymbol_to_symbol (abfd, dynamic, minisym, sym) 763 835 bfd *abfd ATTRIBUTE_UNUSED; 764 b oolean dynamic ATTRIBUTE_UNUSED;836 bfd_boolean dynamic ATTRIBUTE_UNUSED; 765 837 const PTR minisym; 766 838 asymbol *sym ATTRIBUTE_UNUSED; … … 772 844 sections to find the source file and line closest to a desired 773 845 location. This is used by COFF and ELF targets. It sets *pfound 774 to trueif it finds some information. The *pinfo field is used to846 to TRUE if it finds some information. The *pinfo field is used to 775 847 pass cached information in and out of this routine; this first time 776 848 the routine is called for a BFD, *pinfo should be NULL. The value … … 844 916 }; 845 917 846 b oolean918 bfd_boolean 847 919 _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound, 848 920 pfilename, pfnname, pline, pinfo) … … 851 923 asection *section; 852 924 bfd_vma offset; 853 b oolean *pfound;925 bfd_boolean *pfound; 854 926 const char **pfilename; 855 927 const char **pfnname; … … 863 935 bfd_size_type stroff; 864 936 struct indexentry *indexentry; 865 char *directory_name, *file_name; 937 char *file_name; 938 char *directory_name; 866 939 int saw_fun; 867 868 *pfound = false; 940 bfd_boolean saw_line, saw_func; 941 942 *pfound = FALSE; 869 943 *pfilename = bfd_get_filename (abfd); 870 944 *pfnname = NULL; … … 897 971 { 898 972 /* No stabs debugging information. */ 899 return true;973 return TRUE; 900 974 } 901 975 … … 909 983 int i; 910 984 char *name; 911 char *file_name;912 char *directory_name;913 985 char *function_name; 914 915 info = (struct stab_find_info *) bfd_zalloc (abfd, sizeof *info); 986 bfd_size_type amt = sizeof *info; 987 988 info = (struct stab_find_info *) bfd_zalloc (abfd, amt); 916 989 if (info == NULL) 917 return false;990 return FALSE; 918 991 919 992 /* FIXME: When using the linker --split-by-file or … … 929 1002 can return quickly in the info != NULL case above. */ 930 1003 *pinfo = (PTR) info; 931 return true;1004 return TRUE; 932 1005 } 933 1006 … … 938 1011 info->strs = (bfd_byte *) bfd_alloc (abfd, strsize); 939 1012 if (info->stabs == NULL || info->strs == NULL) 940 return false;941 942 if (! bfd_get_section_contents (abfd, info->stabsec, info->stabs, 0,943 stabsize)944 || ! bfd_get_section_contents (abfd, info->strsec, info->strs, 0,945 strsize))946 return false;1013 return FALSE; 1014 1015 if (! bfd_get_section_contents (abfd, info->stabsec, info->stabs, 1016 (bfd_vma) 0, stabsize) 1017 || ! bfd_get_section_contents (abfd, info->strsec, info->strs, 1018 (bfd_vma) 0, strsize)) 1019 return FALSE; 947 1020 948 1021 /* If this is a relocateable object file, we have to relocate … … 952 1025 reloc_size = bfd_get_reloc_upper_bound (abfd, info->stabsec); 953 1026 if (reloc_size < 0) 954 return false;955 reloc_vector = (arelent **) bfd_malloc ( reloc_size);1027 return FALSE; 1028 reloc_vector = (arelent **) bfd_malloc ((bfd_size_type) reloc_size); 956 1029 if (reloc_vector == NULL && reloc_size != 0) 957 return false;1030 return FALSE; 958 1031 reloc_count = bfd_canonicalize_reloc (abfd, info->stabsec, reloc_vector, 959 1032 symbols); … … 962 1035 if (reloc_vector != NULL) 963 1036 free (reloc_vector); 964 return false;1037 return FALSE; 965 1038 } 966 1039 if (reloc_count > 0) … … 987 1060 if (reloc_vector != NULL) 988 1061 free (reloc_vector); 989 return false;1062 return FALSE; 990 1063 } 991 1064 … … 994 1067 sym = *r->sym_ptr_ptr; 995 1068 val += sym->value + sym->section->vma + r->addend; 996 bfd_put_32 (abfd, val, info->stabs + r->address);1069 bfd_put_32 (abfd, (bfd_vma) val, info->stabs + r->address); 997 1070 } 998 1071 } … … 1011 1084 for (stab = info->stabs; stab < info->stabs + stabsize; stab += STABSIZE) 1012 1085 { 1013 if (stab[TYPEOFF] == N_SO)1086 if (stab[TYPEOFF] == (bfd_byte) N_SO) 1014 1087 { 1015 1088 /* N_SO with null name indicates EOF */ … … 1025 1098 /* two N_SO's in a row is a filename and directory. Skip */ 1026 1099 if (stab + STABSIZE < info->stabs + stabsize 1027 && *(stab + STABSIZE + TYPEOFF) == N_SO)1100 && *(stab + STABSIZE + TYPEOFF) == (bfd_byte) N_SO) 1028 1101 { 1029 1102 stab += STABSIZE; 1030 1103 } 1031 1104 } 1032 else if (stab[TYPEOFF] == N_FUN)1105 else if (stab[TYPEOFF] == (bfd_byte) N_FUN) 1033 1106 { 1034 1107 saw_fun = 1; … … 1041 1114 1042 1115 if (info->indextablesize == 0) 1043 return true;1116 return TRUE; 1044 1117 ++info->indextablesize; 1045 1118 1046 info->indextable = ((struct indexentry *) 1047 bfd_alloc (abfd, 1048 (sizeof (struct indexentry) 1049 * info->indextablesize))); 1119 amt = info->indextablesize; 1120 amt *= sizeof (struct indexentry); 1121 info->indextable = (struct indexentry *) bfd_alloc (abfd, amt); 1050 1122 if (info->indextable == NULL) 1051 return false;1123 return FALSE; 1052 1124 1053 1125 file_name = NULL; … … 1100 1172 last_stab = stab; 1101 1173 if (stab + STABSIZE >= info->stabs + stabsize 1102 || *(stab + STABSIZE + TYPEOFF) != N_SO)1174 || *(stab + STABSIZE + TYPEOFF) != (bfd_byte) N_SO) 1103 1175 { 1104 1176 directory_name = NULL; … … 1165 1237 1166 1238 info->indextablesize = i; 1167 qsort (info->indextable, i, sizeof (struct indexentry), cmpindexentry); 1239 qsort (info->indextable, (size_t) i, sizeof (struct indexentry), 1240 cmpindexentry); 1168 1241 1169 1242 *pinfo = (PTR) info; … … 1186 1259 #endif 1187 1260 { 1261 long low, high; 1262 long mid = -1; 1263 1188 1264 /* Cache non-existant or invalid. Do binary search on 1189 1265 indextable. */ 1190 1191 long low, high;1192 long mid = -1;1193 1194 1266 indexentry = NULL; 1195 1267 … … 1213 1285 1214 1286 if (indexentry == NULL) 1215 return true;1287 return TRUE; 1216 1288 1217 1289 stab = indexentry->stab + STABSIZE; … … 1222 1294 str = indexentry->str; 1223 1295 1296 saw_line = FALSE; 1297 saw_func = FALSE; 1224 1298 for (; stab < (indexentry+1)->stab; stab += STABSIZE) 1225 1299 { 1226 b oolean done;1300 bfd_boolean done; 1227 1301 bfd_vma val; 1228 1302 1229 done = false;1303 done = FALSE; 1230 1304 1231 1305 switch (stab[TYPEOFF]) … … 1244 1318 case N_DSLINE: 1245 1319 case N_BSLINE: 1246 /* A line number. The value is relative to the start of the 1247 current function. */ 1248 val = indexentry->val + bfd_get_32 (abfd, stab + VALOFF); 1249 if (val <= offset) 1320 /* A line number. If the function was specified, then the value 1321 is relative to the start of the function. Otherwise, the 1322 value is an absolute address. */ 1323 val = ((indexentry->function_name ? indexentry->val : 0) 1324 + bfd_get_32 (abfd, stab + VALOFF)); 1325 /* If this line starts before our desired offset, or if it's 1326 the first line we've been able to find, use it. The 1327 !saw_line check works around a bug in GCC 2.95.3, which emits 1328 the first N_SLINE late. */ 1329 if (!saw_line || val <= offset) 1250 1330 { 1251 1331 *pline = bfd_get_16 (abfd, stab + DESCOFF); … … 1259 1339 } 1260 1340 if (val > offset) 1261 done = true; 1341 done = TRUE; 1342 saw_line = TRUE; 1262 1343 break; 1263 1344 1264 1345 case N_FUN: 1265 1346 case N_SO: 1266 done = true; 1347 if (saw_func || saw_line) 1348 done = TRUE; 1349 saw_func = TRUE; 1267 1350 break; 1268 1351 } … … 1272 1355 } 1273 1356 1274 *pfound = true; 1275 1276 if (IS_ABSOLUTE_PATH(file_name) || directory_name == NULL) 1357 *pfound = TRUE; 1358 1359 if (file_name == NULL || IS_ABSOLUTE_PATH (file_name) 1360 || directory_name == NULL) 1277 1361 *pfilename = file_name; 1278 1362 else … … 1285 1369 || strcmp (info->filename + dirlen, file_name) != 0) 1286 1370 { 1371 size_t len; 1372 1287 1373 if (info->filename != NULL) 1288 1374 free (info->filename); 1289 info->filename = (char *) bfd_malloc (dirlen + 1290 strlen (file_name) 1291 + 1); 1375 len = strlen (file_name) + 1; 1376 info->filename = (char *) bfd_malloc ((bfd_size_type) dirlen + len); 1292 1377 if (info->filename == NULL) 1293 return false;1294 strcpy (info->filename, directory_name);1295 strcpy (info->filename + dirlen, file_name);1378 return FALSE; 1379 memcpy (info->filename, directory_name, dirlen); 1380 memcpy (info->filename + dirlen, file_name, len); 1296 1381 } 1297 1382 … … 1306 1391 to clobber the colon. It's OK to change the name, since the 1307 1392 string is in our own local storage anyhow. */ 1308 1309 1393 s = strchr (indexentry->function_name, ':'); 1310 1394 if (s != NULL) … … 1314 1398 } 1315 1399 1316 return true;1400 return TRUE; 1317 1401 } -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.