Changeset 609 for branches/GNU/src/binutils/bfd/tekhex.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/bfd/tekhex.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* BFD backend for Extended Tektronix Hex Format objects. 2 Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000 2 Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 3 3 Free Software Foundation, Inc. 4 4 Written by Steve Chamberlain of Cygnus Support <sac@cygnus.com>. … … 105 105 static void tekhex_get_symbol_info PARAMS ((bfd *, asymbol *, symbol_info *)); 106 106 static asymbol *tekhex_make_empty_symbol PARAMS ((bfd *)); 107 static int tekhex_sizeof_headers PARAMS ((bfd *, b oolean));108 static b oolean tekhex_write_object_contents PARAMS ((bfd *));107 static int tekhex_sizeof_headers PARAMS ((bfd *, bfd_boolean)); 108 static bfd_boolean tekhex_write_object_contents PARAMS ((bfd *)); 109 109 static void out PARAMS ((bfd *, int, char *, char *)); 110 static void writesym PARAMS ((char **, CONSTchar *));110 static void writesym PARAMS ((char **, const char *)); 111 111 static void writevalue PARAMS ((char **, bfd_vma)); 112 static b oolean tekhex_set_section_contents112 static bfd_boolean tekhex_set_section_contents 113 113 PARAMS ((bfd*, sec_ptr, PTR, file_ptr, bfd_size_type)); 114 static b oolean tekhex_set_arch_mach114 static bfd_boolean tekhex_set_arch_mach 115 115 PARAMS ((bfd *, enum bfd_architecture, unsigned long)); 116 static b oolean tekhex_get_section_contents116 static bfd_boolean tekhex_get_section_contents 117 117 PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type)); 118 118 static void move_section_contents 119 PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type, b oolean));119 PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type, bfd_boolean)); 120 120 static const bfd_target *tekhex_object_p PARAMS ((bfd *)); 121 static b oolean tekhex_mkobject PARAMS ((bfd *));121 static bfd_boolean tekhex_mkobject PARAMS ((bfd *)); 122 122 static long tekhex_get_symtab_upper_bound PARAMS ((bfd *)); 123 123 static long tekhex_get_symtab PARAMS ((bfd *, asymbol **)); … … 240 240 { 241 241 unsigned int i; 242 static b oolean inited = false;242 static bfd_boolean inited = FALSE; 243 243 int val; 244 244 245 if ( inited == false)246 { 247 inited = true;245 if (! inited) 246 { 247 inited = TRUE; 248 248 hex_init (); 249 249 val = 0; … … 355 355 if (!d) 356 356 { 357 char *sname = bfd_alloc (abfd, 12);358 359 357 /* No chunk for this address, so make one up */ 360 d = ( struct data_struct *)361 bfd_alloc (abfd, sizeof (struct data_struct));362 363 if (! sname || !d)358 d = ((struct data_struct *) 359 bfd_zalloc (abfd, (bfd_size_type) sizeof (struct data_struct))); 360 361 if (!d) 364 362 return NULL; 365 363 366 memset (d->chunk_init, 0, CHUNK_MASK + 1);367 memset (d->chunk_data, 0, CHUNK_MASK + 1);368 364 d->next = abfd->tdata.tekhex_data->data; 369 365 d->vma = vma; … … 395 391 { 396 392 asection *section = bfd_abs_section_ptr; 397 int len;393 unsigned int len; 398 394 char sym[17]; /* A symbol can only be 16chars long */ 399 395 … … 420 416 if (section == (asection *) NULL) 421 417 { 422 char *n = bfd_alloc (abfd, len + 1);418 char *n = bfd_alloc (abfd, (bfd_size_type) len + 1); 423 419 424 420 if (!n) … … 446 442 /* Symbols, add to section */ 447 443 { 444 bfd_size_type amt = sizeof (tekhex_symbol_type); 448 445 tekhex_symbol_type *new = 449 (tekhex_symbol_type *) bfd_alloc (abfd, 450 sizeof (tekhex_symbol_type)); 451 char type = (*src); 446 (tekhex_symbol_type *) bfd_alloc (abfd, amt); 447 char stype = (*src); 452 448 453 449 if (!new) … … 460 456 abfd->tdata.tekhex_data->symbols = new; 461 457 len = getsym (sym, &src); 462 new->symbol.name = bfd_alloc (abfd, len + 1);458 new->symbol.name = bfd_alloc (abfd, (bfd_size_type) len + 1); 463 459 if (!new->symbol.name) 464 460 abort (); /* FIXME */ 465 461 memcpy ((char *) (new->symbol.name), sym, len + 1); 466 462 new->symbol.section = section; 467 if ( type <= '4')463 if (stype <= '4') 468 464 new->symbol.flags = (BSF_GLOBAL | BSF_EXPORT); 469 465 else … … 476 472 } 477 473 478 /* Pass over a ntekhex, calling one of the above functions on each474 /* Pass over a tekhex, calling one of the above functions on each 479 475 record. */ 480 476 … … 485 481 { 486 482 unsigned int chars_on_line; 487 b oolean eof = false;483 bfd_boolean eof = FALSE; 488 484 489 485 /* To the front of the file */ 490 486 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) 491 487 abort (); 492 while ( eof == false)488 while (! eof) 493 489 { 494 490 char buffer[MAXCHUNK]; … … 497 493 498 494 /* Find first '%' */ 499 eof = (b oolean) (bfd_read (src, 1,1, abfd) != 1);495 eof = (bfd_boolean) (bfd_bread (src, (bfd_size_type) 1, abfd) != 1); 500 496 while (*src != '%' && !eof) 501 497 { 502 eof = (b oolean) (bfd_read (src, 1,1, abfd) != 1);498 eof = (bfd_boolean) (bfd_bread (src, (bfd_size_type) 1, abfd) != 1); 503 499 } 504 500 if (eof) … … 507 503 508 504 /* Fetch the type and the length and the checksum */ 509 if (bfd_ read (src, 1,5, abfd) != 5)505 if (bfd_bread (src, (bfd_size_type) 5, abfd) != 5) 510 506 abort (); /* FIXME */ 511 507 … … 517 513 chars_on_line = HEX (src) - 5; /* Already read five char */ 518 514 519 if (bfd_ read (src, 1,chars_on_line, abfd) != chars_on_line)515 if (bfd_bread (src, (bfd_size_type) chars_on_line, abfd) != chars_on_line) 520 516 abort (); /* FIXME */ 521 517 src[chars_on_line] = 0; /* put a null at the end */ … … 552 548 } 553 549 554 static b oolean550 static bfd_boolean 555 551 tekhex_mkobject (abfd) 556 552 bfd *abfd; 557 553 { 558 tdata_type *tdata = (tdata_type *) bfd_alloc (abfd, sizeof (tdata_type)); 559 554 tdata_type *tdata; 555 556 tdata = (tdata_type *) bfd_alloc (abfd, (bfd_size_type) sizeof (tdata_type)); 560 557 if (!tdata) 561 return false;558 return FALSE; 562 559 abfd->tdata.tekhex_data = tdata; 563 560 tdata->type = 1; … … 565 562 tdata->symbols = (struct tekhex_symbol_struct *) NULL; 566 563 tdata->data = (struct data_struct *) NULL; 567 return true;564 return TRUE; 568 565 } 569 566 570 567 /* 571 Return trueif the file looks like it's in TekHex format. Just look568 Return TRUE if the file looks like it's in TekHex format. Just look 572 569 for a percent sign and some hex digits */ 573 570 … … 581 578 582 579 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 583 || bfd_ read (b, 1,4, abfd) != 4)580 || bfd_bread (b, (bfd_size_type) 4, abfd) != 4) 584 581 return NULL; 585 582 … … 598 595 asection *section; 599 596 PTR locationp; 600 file_ptr offset ATTRIBUTE_UNUSED;597 file_ptr offset; 601 598 bfd_size_type count; 602 b oolean get;599 bfd_boolean get; 603 600 { 604 601 bfd_vma addr; … … 607 604 struct data_struct *d = (struct data_struct *) NULL; 608 605 606 BFD_ASSERT (offset == 0); 609 607 for (addr = section->vma; count != 0; count--, addr++) 610 608 { 611 612 bfd_vma chunk_number = addr & ~ CHUNK_MASK; /* Get high bits of address */609 /* Get high bits of address. */ 610 bfd_vma chunk_number = addr & ~(bfd_vma) CHUNK_MASK; 613 611 bfd_vma low_bits = addr & CHUNK_MASK; 614 612 … … 642 640 } 643 641 644 static b oolean642 static bfd_boolean 645 643 tekhex_get_section_contents (abfd, section, locationp, offset, count) 646 644 bfd *abfd; … … 652 650 if (section->flags & (SEC_LOAD | SEC_ALLOC)) 653 651 { 654 move_section_contents (abfd, section, locationp, offset, count, true);655 return true;652 move_section_contents (abfd, section, locationp, offset, count, TRUE); 653 return TRUE; 656 654 } 657 655 else 658 return false;659 } 660 661 static b oolean656 return FALSE; 657 } 658 659 static bfd_boolean 662 660 tekhex_set_arch_mach (abfd, arch, machine) 663 661 bfd *abfd; … … 671 669 */ 672 670 673 static b oolean671 static bfd_boolean 674 672 tekhex_set_section_contents (abfd, section, locationp, offset, bytes_to_do) 675 673 bfd *abfd; … … 680 678 { 681 679 682 if ( abfd->output_has_begun == false)680 if (! abfd->output_has_begun) 683 681 { 684 682 /* The first time around, allocate enough sections to hold all the chunks */ … … 690 688 if (s->flags & SEC_LOAD) 691 689 { 692 for (vma = s->vma & ~ CHUNK_MASK;690 for (vma = s->vma & ~(bfd_vma) CHUNK_MASK; 693 691 vma < s->vma + s->_raw_size; 694 692 vma += CHUNK_MASK) … … 700 698 if (section->flags & (SEC_LOAD | SEC_ALLOC)) 701 699 { 702 move_section_contents (abfd, section, locationp, offset, bytes_to_do, false); 703 return true; 700 move_section_contents (abfd, section, locationp, offset, bytes_to_do, 701 FALSE); 702 return TRUE; 704 703 } 705 704 else 706 return false;705 return FALSE; 707 706 708 707 } … … 741 740 writesym (dst, sym) 742 741 char **dst; 743 CONSTchar *sym;742 const char *sym; 744 743 { 745 744 char *p = *dst; … … 798 797 sum += sum_block[(unsigned char) front[3]]; /* type */ 799 798 TOHEX (front + 4, sum); 800 if (bfd_ write (front, 1,6, abfd) != 6)799 if (bfd_bwrite (front, (bfd_size_type) 6, abfd) != 6) 801 800 abort (); 802 801 end[0] = '\n'; 803 802 wrlen = end - start + 1; 804 if (bfd_ write (start, 1, wrlen, abfd) != wrlen)803 if (bfd_bwrite (start, wrlen, abfd) != wrlen) 805 804 abort (); 806 805 } 807 806 808 static b oolean807 static bfd_boolean 809 808 tekhex_write_object_contents (abfd) 810 809 bfd *abfd; … … 827 826 int low; 828 827 829 CONSTint span = 32;828 const int span = 32; 830 829 int addr; 831 830 … … 877 876 if (section_code != '?') 878 877 { /* do not include debug symbols */ 879 asymbol *s = *p;878 asymbol *sym = *p; 880 879 char *dst = buffer; 881 880 882 writesym (&dst, s ->section->name);881 writesym (&dst, sym->section->name); 883 882 884 883 switch (section_code) … … 909 908 case 'U': 910 909 bfd_set_error (bfd_error_wrong_format); 911 return false;910 return FALSE; 912 911 } 913 912 914 writesym (&dst, s ->name);915 writevalue (&dst, s ->value + s->section->vma);913 writesym (&dst, sym->name); 914 writevalue (&dst, sym->value + sym->section->vma); 916 915 out (abfd, '3', buffer, dst); 917 916 } … … 920 919 921 920 /* And the terminator */ 922 if (bfd_ write ("%0781010\n", 1,9, abfd) != 9)921 if (bfd_bwrite ("%0781010\n", (bfd_size_type) 9, abfd) != 9) 923 922 abort (); 924 return true;923 return TRUE; 925 924 } 926 925 … … 928 927 tekhex_sizeof_headers (abfd, exec) 929 928 bfd *abfd ATTRIBUTE_UNUSED; 930 b oolean exec ATTRIBUTE_UNUSED;929 bfd_boolean exec ATTRIBUTE_UNUSED; 931 930 932 931 { … … 938 937 bfd *abfd; 939 938 { 940 tekhex_symbol_type *new =941 (tekhex_symbol_type *) bfd_zalloc (abfd, sizeof (struct tekhex_symbol_struct));939 bfd_size_type amt = sizeof (struct tekhex_symbol_struct); 940 tekhex_symbol_type *new = (tekhex_symbol_type *) bfd_zalloc (abfd, amt); 942 941 943 942 if (!new) … … 958 957 959 958 static void 960 tekhex_print_symbol ( ignore_abfd, filep, symbol, how)961 bfd * ignore_abfd ATTRIBUTE_UNUSED;959 tekhex_print_symbol (abfd, filep, symbol, how) 960 bfd *abfd; 962 961 PTR filep; 963 962 asymbol *symbol; … … 976 975 case bfd_print_symbol_all: 977 976 { 978 CONSTchar *section_name = symbol->section->name;979 980 bfd_print_symbol_vandf ( (PTR) file, symbol);977 const char *section_name = symbol->section->name; 978 979 bfd_print_symbol_vandf (abfd, (PTR) file, symbol); 981 980 982 981 fprintf (file, " %-5s %s", … … 1002 1001 #define tekhex_bfd_relax_section bfd_generic_relax_section 1003 1002 #define tekhex_bfd_gc_sections bfd_generic_gc_sections 1003 #define tekhex_bfd_merge_sections bfd_generic_merge_sections 1004 #define tekhex_bfd_discard_group bfd_generic_discard_group 1004 1005 #define tekhex_bfd_link_hash_table_create _bfd_generic_link_hash_table_create 1006 #define tekhex_bfd_link_hash_table_free _bfd_generic_link_hash_table_free 1005 1007 #define tekhex_bfd_link_add_symbols _bfd_generic_link_add_symbols 1008 #define tekhex_bfd_link_just_syms _bfd_generic_link_just_syms 1006 1009 #define tekhex_bfd_final_link _bfd_generic_final_link 1007 1010 #define tekhex_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.