Changeset 609 for branches/GNU/src/binutils/bfd/versados.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/bfd/versados.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* BFD back-end for VERSAdos-E objects. 2 Copyright 1995, 1996, 1998, 1999, 2000 Free Software Foundation, Inc. 2 Copyright 1995, 1996, 1998, 1999, 2000, 2001, 2002 3 Free Software Foundation, Inc. 3 4 Written by Steve Chamberlain of Cygnus Support <sac@cygnus.com>. 4 5 … … 44 45 #include "libiberty.h" 45 46 46 static b oolean versados_mkobject PARAMS ((bfd *));47 static b oolean versados_scan PARAMS ((bfd *));47 static bfd_boolean versados_mkobject PARAMS ((bfd *)); 48 static bfd_boolean versados_scan PARAMS ((bfd *)); 48 49 static const bfd_target *versados_object_p PARAMS ((bfd *)); 50 static asymbol *versados_new_symbol 51 PARAMS ((bfd *, int, const char *, bfd_vma, asection *)); 52 static char *new_symbol_string PARAMS ((bfd *, const char *)); 53 static const bfd_target *versados_object_p PARAMS ((bfd *)); 54 static bfd_boolean versados_pass_2 PARAMS ((bfd *)); 55 static bfd_boolean versados_get_section_contents 56 PARAMS ((bfd *, asection *, void *, file_ptr, bfd_size_type)); 57 static bfd_boolean versados_set_section_contents 58 PARAMS ((bfd *, sec_ptr, void *, file_ptr, bfd_size_type)); 59 static int versados_sizeof_headers PARAMS ((bfd *, bfd_boolean)); 60 static long int versados_get_symtab_upper_bound PARAMS ((bfd *)); 61 static long int versados_get_symtab PARAMS ((bfd *, asymbol **)); 62 static void versados_get_symbol_info 63 PARAMS ((bfd *, asymbol *, symbol_info *)); 64 static void versados_print_symbol 65 PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type)); 66 static long versados_get_reloc_upper_bound 67 PARAMS ((bfd *, sec_ptr)); 68 static long versados_canonicalize_reloc 69 PARAMS ((bfd *, sec_ptr, arelent **, asymbol **)); 49 70 50 71 #define VHEADER '1' … … 142 163 }; 143 164 165 static int get_record PARAMS ((bfd *, union ext_any *)); 166 static int get_4 PARAMS ((unsigned char **)); 167 static void get_10 PARAMS ((unsigned char **, char *)); 168 static void process_esd PARAMS ((bfd *, struct ext_esd *, int)); 169 static int get_offset PARAMS ((int, unsigned char *)); 170 static void process_otr PARAMS ((bfd *, struct ext_otr *, int)); 171 144 172 /* Initialize by filling in the hex conversion array. */ 145 173 146 174 /* Set up the tdata information. */ 147 175 148 static b oolean176 static bfd_boolean 149 177 versados_mkobject (abfd) 150 178 bfd *abfd; … … 152 180 if (abfd->tdata.versados_data == NULL) 153 181 { 154 tdata_type *tdata = (tdata_type *) bfd_alloc (abfd, sizeof (tdata_type)); 182 bfd_size_type amt = sizeof (tdata_type); 183 tdata_type *tdata = (tdata_type *) bfd_alloc (abfd, amt); 155 184 if (tdata == NULL) 156 return false;185 return FALSE; 157 186 abfd->tdata.versados_data = tdata; 158 187 tdata->symbols = NULL; … … 161 190 162 191 bfd_default_set_arch_mach (abfd, bfd_arch_m68k, 0); 163 return true;192 return TRUE; 164 193 } 165 194 … … 190 219 union ext_any *ptr; 191 220 { 192 bfd_read (&ptr->size, 1, 1, abfd); 193 if (bfd_read ((char *) ptr + 1, 1, ptr->size, abfd) != ptr->size) 221 if (bfd_bread (&ptr->size, (bfd_size_type) 1, abfd) != 1 222 || (bfd_bread ((char *) ptr + 1, (bfd_size_type) ptr->size, abfd) 223 != ptr->size)) 194 224 return 0; 195 225 return 1; 196 226 } 197 227 198 int228 static int 199 229 get_4 (pp) 200 230 unsigned char **pp; … … 205 235 } 206 236 207 void237 static void 208 238 get_10 (pp, name) 209 239 unsigned char **pp; … … 225 255 new_symbol_string (abfd, name) 226 256 bfd *abfd; 227 c har *name;257 const char *name; 228 258 { 229 259 char *n = VDATA (abfd)->strings; … … 276 306 asymbol *s; 277 307 char *n = new_symbol_string (abfd, name); 278 s = versados_new_symbol (abfd, snum, n, 0,279 &bfd_und_section, scn);308 s = versados_new_symbol (abfd, snum, n, (bfd_vma) 0, 309 bfd_und_section_ptr); 280 310 esidx = VDATA (abfd)->es_done++; 281 311 RDATA (abfd, esidx - ES_BASE) = s; … … 300 330 { 301 331 int snum = VDATA (abfd)->def_idx++; 302 longval;332 bfd_vma val; 303 333 get_10 (&ptr, name); 304 334 val = get_4 (&ptr); … … 312 342 asymbol *s; 313 343 char *n = new_symbol_string (abfd, name); 314 s = versados_new_symbol (abfd, snum + VDATA (abfd)->nrefs, n, val, sec, scn); 344 s = versados_new_symbol (abfd, snum + VDATA (abfd)->nrefs, n, 345 val, sec); 315 346 s->flags |= BSF_GLOBAL; 316 347 } … … 328 359 reloc_howto_type versados_howto_table[] = 329 360 { 330 HOWTO (R_RELWORD, 0, 1, 16, false,361 HOWTO (R_RELWORD, 0, 1, 16, FALSE, 331 362 0, complain_overflow_dont, 0, 332 "+v16", true, 0x0000ffff, 0x0000ffff, false),333 HOWTO (R_RELLONG, 0, 2, 32, false,363 "+v16", TRUE, 0x0000ffff, 0x0000ffff, FALSE), 364 HOWTO (R_RELLONG, 0, 2, 32, FALSE, 334 365 0, complain_overflow_dont, 0, 335 "+v32", true, 0xffffffff, 0xffffffff, false),336 337 HOWTO (R_RELWORD_NEG, 0, -1, 16, false,366 "+v32", TRUE, 0xffffffff, 0xffffffff, FALSE), 367 368 HOWTO (R_RELWORD_NEG, 0, -1, 16, FALSE, 338 369 0, complain_overflow_dont, 0, 339 "-v16", true, 0x0000ffff, 0x0000ffff, false),340 HOWTO (R_RELLONG_NEG, 0, -2, 32, false,370 "-v16", TRUE, 0x0000ffff, 0x0000ffff, FALSE), 371 HOWTO (R_RELLONG_NEG, 0, -2, 32, FALSE, 341 372 0, complain_overflow_dont, 0, 342 "-v32", true, 0xffffffff, 0xffffffff, false),373 "-v32", TRUE, 0xffffffff, 0xffffffff, FALSE), 343 374 }; 344 375 … … 381 412 unsigned int dst_idx = esdid->pc; 382 413 383 for (shift = ( 1 << 31); shift && srcp < endp; shift >>= 1)414 for (shift = ((unsigned long) 1 << 31); shift && srcp < endp; shift >>= 1) 384 415 { 385 416 if (bits & shift) … … 454 485 455 486 if (!contents && need_contents) 456 esdid->contents = (unsigned char *) bfd_alloc (abfd, esdid->section->_raw_size); 457 458 } 459 460 static boolean 487 { 488 bfd_size_type size = esdid->section->_raw_size; 489 esdid->contents = (unsigned char *) bfd_alloc (abfd, size); 490 } 491 } 492 493 static bfd_boolean 461 494 versados_scan (abfd) 462 495 bfd *abfd; … … 466 499 int j; 467 500 int nsecs = 0; 501 bfd_size_type amt; 468 502 469 503 VDATA (abfd)->stringlen = 0; … … 478 512 union ext_any any; 479 513 if (!get_record (abfd, &any)) 480 return true;514 return TRUE; 481 515 switch (any.header.type) 482 516 { … … 509 543 if (esdid->section) 510 544 { 511 esdid->section->relocation512 = (arelent *) bfd_alloc (abfd, sizeof (arelent) * esdid->relocs);545 amt = (bfd_size_type) esdid->relocs * sizeof (arelent); 546 esdid->section->relocation = (arelent *) bfd_alloc (abfd, amt); 513 547 514 548 esdid->pc = 0; … … 531 565 abfd->symcount += nsecs; 532 566 533 VDATA (abfd)->symbols = (asymbol *) bfd_alloc (abfd, 534 sizeof (asymbol) * (abfd->symcount)); 535 536 VDATA (abfd)->strings = bfd_alloc (abfd, VDATA (abfd)->stringlen); 567 amt = abfd->symcount; 568 amt *= sizeof (asymbol); 569 VDATA (abfd)->symbols = (asymbol *) bfd_alloc (abfd, amt); 570 571 amt = VDATA (abfd)->stringlen; 572 VDATA (abfd)->strings = bfd_alloc (abfd, amt); 537 573 538 574 if ((VDATA (abfd)->symbols == NULL && abfd->symcount > 0) 539 575 || (VDATA (abfd)->strings == NULL && VDATA (abfd)->stringlen > 0)) 540 return false;576 return FALSE; 541 577 542 578 /* Actually fill in the section symbols, … … 578 614 struct ext_vheader ext; 579 615 unsigned char len; 616 tdata_type *tdata_save; 580 617 581 618 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) 582 619 return NULL; 583 620 584 if (bfd_ read (&len, 1,1, abfd) != 1)621 if (bfd_bread (&len, (bfd_size_type) 1, abfd) != 1) 585 622 { 586 623 if (bfd_get_error () != bfd_error_system_call) … … 589 626 } 590 627 591 if (bfd_ read (&ext.type, 1,len, abfd) != len)628 if (bfd_bread (&ext.type, (bfd_size_type) len, abfd) != len) 592 629 { 593 630 if (bfd_get_error () != bfd_error_system_call) … … 608 645 /* OK, looks like a record, build the tdata and read in. */ 609 646 610 if (!versados_mkobject (abfd) 611 || !versados_scan (abfd)) 612 return NULL; 647 tdata_save = abfd->tdata.versados_data; 648 if (!versados_mkobject (abfd) || !versados_scan (abfd)) 649 { 650 abfd->tdata.versados_data = tdata_save; 651 return NULL; 652 } 613 653 614 654 return abfd->xvec; 615 655 } 616 656 617 static b oolean657 static bfd_boolean 618 658 versados_pass_2 (abfd) 619 659 bfd *abfd; … … 624 664 return 1; 625 665 626 if (bfd_seek (abfd, 0, SEEK_SET) != 0)666 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) 627 667 return 0; 628 668 … … 649 689 } 650 690 651 static b oolean691 static bfd_boolean 652 692 versados_get_section_contents (abfd, section, location, offset, count) 653 693 bfd *abfd; … … 658 698 { 659 699 if (!versados_pass_2 (abfd)) 660 return false;700 return FALSE; 661 701 662 702 memcpy (location, … … 664 704 (size_t) count); 665 705 666 return true;706 return TRUE; 667 707 } 668 708 … … 670 710 _bfd_generic_get_section_contents_in_window 671 711 672 static b oolean712 static bfd_boolean 673 713 versados_set_section_contents (abfd, section, location, offset, bytes_to_do) 674 714 bfd *abfd ATTRIBUTE_UNUSED; … … 678 718 bfd_size_type bytes_to_do ATTRIBUTE_UNUSED; 679 719 { 680 return false;720 return FALSE; 681 721 } 682 722 … … 684 724 versados_sizeof_headers (abfd, exec) 685 725 bfd *abfd ATTRIBUTE_UNUSED; 686 b oolean exec ATTRIBUTE_UNUSED;726 bfd_boolean exec ATTRIBUTE_UNUSED; 687 727 { 688 728 return 0; 689 }690 691 static asymbol *692 versados_make_empty_symbol (abfd)693 bfd *abfd;694 {695 asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));696 if (new)697 new->the_bfd = abfd;698 return new;699 729 } 700 730 … … 733 763 } 734 764 735 void765 static void 736 766 versados_get_symbol_info (ignore_abfd, symbol, ret) 737 767 bfd *ignore_abfd ATTRIBUTE_UNUSED; … … 742 772 } 743 773 744 void745 versados_print_symbol ( ignore_abfd, afile, symbol, how)746 bfd * ignore_abfd ATTRIBUTE_UNUSED;774 static void 775 versados_print_symbol (abfd, afile, symbol, how) 776 bfd *abfd; 747 777 PTR afile; 748 778 asymbol *symbol; … … 756 786 break; 757 787 default: 758 bfd_print_symbol_vandf ( (PTR) file, symbol);788 bfd_print_symbol_vandf (abfd, (PTR) file, symbol); 759 789 fprintf (file, " %-5s %s", 760 790 symbol->section->name, … … 764 794 } 765 795 766 long796 static long 767 797 versados_get_reloc_upper_bound (abfd, asect) 768 798 bfd *abfd ATTRIBUTE_UNUSED; … … 772 802 } 773 803 774 long804 static long 775 805 versados_canonicalize_reloc (abfd, section, relptr, symbols) 776 806 bfd *abfd; … … 829 859 #define versados_get_lineno _bfd_nosymbols_get_lineno 830 860 #define versados_find_nearest_line _bfd_nosymbols_find_nearest_line 861 #define versados_make_empty_symbol _bfd_generic_make_empty_symbol 831 862 #define versados_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol 832 863 #define versados_read_minisymbols _bfd_generic_read_minisymbols … … 841 872 #define versados_bfd_relax_section bfd_generic_relax_section 842 873 #define versados_bfd_gc_sections bfd_generic_gc_sections 874 #define versados_bfd_merge_sections bfd_generic_merge_sections 875 #define versados_bfd_discard_group bfd_generic_discard_group 843 876 #define versados_bfd_link_hash_table_create _bfd_generic_link_hash_table_create 877 #define versados_bfd_link_hash_table_free _bfd_generic_link_hash_table_free 844 878 #define versados_bfd_link_add_symbols _bfd_generic_link_add_symbols 879 #define versados_bfd_link_just_syms _bfd_generic_link_just_syms 845 880 #define versados_bfd_final_link _bfd_generic_final_link 846 881 #define versados_bfd_link_split_section _bfd_generic_link_split_section -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.