Changeset 609 for branches/GNU/src/binutils/bfd/srec.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/bfd/srec.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* BFD back-end for s-record objects. 2 2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 3 2000 3 2000, 2001, 2002 4 4 Free Software Foundation, Inc. 5 5 Written by Steve Chamberlain of Cygnus Support <sac@cygnus.com>. … … 109 109 #include "libbfd.h" 110 110 #include "libiberty.h" 111 #include <ctype.h>111 #include "safe-ctype.h" 112 112 113 113 static void srec_get_symbol_info PARAMS ((bfd *, asymbol *, symbol_info *)); … … 115 115 PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type)); 116 116 static void srec_init PARAMS ((void)); 117 static b oolean srec_mkobject PARAMS ((bfd *));118 static int srec_get_byte PARAMS ((bfd *, b oolean *));119 static void srec_bad_byte PARAMS ((bfd *, unsigned int, int, b oolean));120 static b oolean srec_scan PARAMS ((bfd *));117 static bfd_boolean srec_mkobject PARAMS ((bfd *)); 118 static int srec_get_byte PARAMS ((bfd *, bfd_boolean *)); 119 static void srec_bad_byte PARAMS ((bfd *, unsigned int, int, bfd_boolean)); 120 static bfd_boolean srec_scan PARAMS ((bfd *)); 121 121 static const bfd_target *srec_object_p PARAMS ((bfd *)); 122 122 static const bfd_target *symbolsrec_object_p PARAMS ((bfd *)); 123 static boolean srec_read_section PARAMS ((bfd *, asection *, bfd_byte *)); 124 125 static boolean srec_write_record PARAMS ((bfd *, int, bfd_vma, 126 const bfd_byte *, 127 const bfd_byte *)); 128 static boolean srec_write_header PARAMS ((bfd *)); 129 static boolean srec_write_symbols PARAMS ((bfd *)); 130 static boolean srec_new_symbol PARAMS ((bfd *, const char *, bfd_vma)); 131 static boolean srec_get_section_contents 123 static bfd_boolean srec_read_section PARAMS ((bfd *, asection *, bfd_byte *)); 124 125 static bfd_boolean srec_write_record 126 PARAMS ((bfd *, unsigned int, bfd_vma, const bfd_byte *, const bfd_byte *)); 127 static bfd_boolean srec_write_header PARAMS ((bfd *)); 128 static bfd_boolean srec_write_symbols PARAMS ((bfd *)); 129 static bfd_boolean srec_new_symbol PARAMS ((bfd *, const char *, bfd_vma)); 130 static bfd_boolean srec_get_section_contents 132 131 PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type)); 133 static b oolean srec_set_arch_mach132 static bfd_boolean srec_set_arch_mach 134 133 PARAMS ((bfd *, enum bfd_architecture, unsigned long)); 135 static b oolean srec_set_section_contents134 static bfd_boolean srec_set_section_contents 136 135 PARAMS ((bfd *, sec_ptr, PTR, file_ptr, bfd_size_type)); 137 static boolean internal_srec_write_object_contents PARAMS ((bfd *, int)); 138 static boolean srec_write_object_contents PARAMS ((bfd *)); 139 static boolean symbolsrec_write_object_contents PARAMS ((bfd *)); 140 static int srec_sizeof_headers PARAMS ((bfd *, boolean)); 141 static asymbol *srec_make_empty_symbol PARAMS ((bfd *)); 136 static bfd_boolean internal_srec_write_object_contents PARAMS ((bfd *, int)); 137 static bfd_boolean srec_write_object_contents PARAMS ((bfd *)); 138 static bfd_boolean symbolsrec_write_object_contents PARAMS ((bfd *)); 139 static int srec_sizeof_headers PARAMS ((bfd *, bfd_boolean)); 142 140 static long srec_get_symtab_upper_bound PARAMS ((bfd *)); 143 141 static long srec_get_symtab PARAMS ((bfd *, asymbol **)); … … 145 143 /* Macros for converting between hex and binary. */ 146 144 147 static CONSTchar digs[] = "0123456789ABCDEF";145 static const char digs[] = "0123456789ABCDEF"; 148 146 149 147 #define NIBBLE(x) hex_value(x) … … 160 158 srec_init () 161 159 { 162 static b oolean inited = false;163 164 if ( inited == false)165 { 166 inited = true;160 static bfd_boolean inited = FALSE; 161 162 if (! inited) 163 { 164 inited = TRUE; 167 165 hex_init (); 168 166 } 169 167 } 170 168 171 /* The maximum number of bytes on a line is FF. */169 /* The maximum number of address+data+crc bytes on a line is FF. */ 172 170 #define MAXCHUNK 0xff 173 171 … … 175 173 #define DEFAULT_CHUNK 16 176 174 177 /* The number of bytes we actually fit onto a line on output.175 /* The number of data bytes we actually fit onto a line on output. 178 176 This variable can be modified by objcopy's --srec-len parameter. 179 177 For a 0x75 byte record you should set --srec-len=0x70. */ … … 183 181 This variable can be modified by objcopy's --srec-forceS3 184 182 parameter. */ 185 b oolean S3Forced = 0;183 bfd_boolean S3Forced = FALSE; 186 184 187 185 /* When writing an S-record file, the S-records can not be output as … … 222 220 tdata_type; 223 221 224 static boolean srec_write_section PARAMS ((bfd *, tdata_type *, 225 srec_data_list_type *)); 226 static boolean srec_write_terminator PARAMS ((bfd *, tdata_type *)); 222 static bfd_boolean srec_write_section 223 PARAMS ((bfd *, tdata_type *, srec_data_list_type *)); 224 static bfd_boolean srec_write_terminator 225 PARAMS ((bfd *, tdata_type *)); 227 226 228 227 /* Set up the S-record tdata information. */ 229 228 230 static b oolean229 static bfd_boolean 231 230 srec_mkobject (abfd) 232 231 bfd *abfd; 233 232 { 233 bfd_size_type amt; 234 tdata_type *tdata; 235 234 236 srec_init (); 235 237 236 if (abfd->tdata.srec_data == NULL) 237 { 238 tdata_type *tdata = (tdata_type *) bfd_alloc (abfd, sizeof (tdata_type)); 239 if (tdata == NULL) 240 return false; 241 abfd->tdata.srec_data = tdata; 242 tdata->type = 1; 243 tdata->head = NULL; 244 tdata->tail = NULL; 245 tdata->symbols = NULL; 246 tdata->symtail = NULL; 247 tdata->csymbols = NULL; 248 } 249 250 return true; 238 amt = sizeof (tdata_type); 239 tdata = (tdata_type *) bfd_alloc (abfd, amt); 240 if (tdata == NULL) 241 return FALSE; 242 243 abfd->tdata.srec_data = tdata; 244 tdata->type = 1; 245 tdata->head = NULL; 246 tdata->tail = NULL; 247 tdata->symbols = NULL; 248 tdata->symtail = NULL; 249 tdata->csymbols = NULL; 250 251 return TRUE; 251 252 } 252 253 … … 257 258 srec_get_byte (abfd, errorptr) 258 259 bfd *abfd; 259 b oolean *errorptr;260 bfd_boolean *errorptr; 260 261 { 261 262 bfd_byte c; 262 263 263 if (bfd_ read (&c, 1,1, abfd) != 1)264 if (bfd_bread (&c, (bfd_size_type) 1, abfd) != 1) 264 265 { 265 266 if (bfd_get_error () != bfd_error_file_truncated) 266 *errorptr = true;267 *errorptr = TRUE; 267 268 return EOF; 268 269 } … … 280 281 unsigned int lineno; 281 282 int c; 282 b oolean error;283 bfd_boolean error; 283 284 { 284 285 if (c == EOF) … … 291 292 char buf[10]; 292 293 293 if (! isprint(c))294 if (! ISPRINT (c)) 294 295 sprintf (buf, "\\%03o", (unsigned int) c); 295 296 else … … 300 301 (*_bfd_error_handler) 301 302 (_("%s:%d: Unexpected character `%s' in S-record file\n"), 302 bfd_ get_filename (abfd), lineno, buf);303 bfd_archive_filename (abfd), lineno, buf); 303 304 bfd_set_error (bfd_error_bad_value); 304 305 } … … 307 308 /* Add a new symbol found in an S-record file. */ 308 309 309 static b oolean310 static bfd_boolean 310 311 srec_new_symbol (abfd, name, val) 311 312 bfd *abfd; … … 314 315 { 315 316 struct srec_symbol *n; 316 317 n = (struct srec_symbol *) bfd_alloc (abfd, sizeof (struct srec_symbol)); 317 bfd_size_type amt = sizeof (struct srec_symbol); 318 319 n = (struct srec_symbol *) bfd_alloc (abfd, amt); 318 320 if (n == NULL) 319 return false;321 return FALSE; 320 322 321 323 n->name = name; … … 331 333 ++abfd->symcount; 332 334 333 return true;335 return TRUE; 334 336 } 335 337 … … 337 339 section for each contiguous set of bytes. */ 338 340 339 static b oolean341 static bfd_boolean 340 342 srec_scan (abfd) 341 343 bfd *abfd; … … 343 345 int c; 344 346 unsigned int lineno = 1; 345 b oolean error = false;347 bfd_boolean error = FALSE; 346 348 bfd_byte *buf = NULL; 347 349 size_t bufsize = 0; … … 355 357 { 356 358 /* We only build sections from contiguous S-records, so if this 357 359 is not an S-record, then stop building a section. */ 358 360 if (c != 'S' && c != '\r' && c != '\n') 359 361 sec = NULL; … … 390 392 do 391 393 { 392 unsigned intalc;394 bfd_size_type alc; 393 395 char *p, *symname; 394 396 bfd_vma symval; … … 417 419 *p++ = c; 418 420 while ((c = srec_get_byte (abfd, &error)) != EOF 419 && ! isspace(c))421 && ! ISSPACE (c)) 420 422 { 421 if (( unsigned int) (p - symbuf) >= alc)423 if ((bfd_size_type) (p - symbuf) >= alc) 422 424 { 423 425 char *n; … … 441 443 442 444 *p++ = '\0'; 443 symname = bfd_alloc (abfd, p - symbuf);445 symname = bfd_alloc (abfd, (bfd_size_type) (p - symbuf)); 444 446 if (symname == NULL) 445 447 goto error_return; … … 504 506 pos = bfd_tell (abfd) - 1; 505 507 506 if (bfd_ read (hdr, 1,3, abfd) != 3)508 if (bfd_bread (hdr, (bfd_size_type) 3, abfd) != 3) 507 509 goto error_return; 508 510 … … 522 524 if (buf != NULL) 523 525 free (buf); 524 buf = (bfd_byte *) bfd_malloc ( bytes * 2);526 buf = (bfd_byte *) bfd_malloc ((bfd_size_type) bytes * 2); 525 527 if (buf == NULL) 526 528 goto error_return; … … 528 530 } 529 531 530 if (bfd_ read (buf, 1,bytes * 2, abfd) != bytes * 2)532 if (bfd_bread (buf, (bfd_size_type) bytes * 2, abfd) != bytes * 2) 531 533 goto error_return; 532 534 … … 541 543 case '5': 542 544 /* Prologue--ignore the file name, but stop building a 543 545 section at this point. */ 544 546 sec = NULL; 545 547 break; … … 566 568 { 567 569 /* This data goes at the end of the section we are 568 570 currently building. */ 569 571 sec->_raw_size += bytes; 570 572 } … … 573 575 char secbuf[20]; 574 576 char *secname; 577 bfd_size_type amt; 575 578 576 579 sprintf (secbuf, ".sec%d", bfd_count_sections (abfd) + 1); 577 secname = (char *) bfd_alloc (abfd, strlen (secbuf) + 1); 580 amt = strlen (secbuf) + 1; 581 secname = (char *) bfd_alloc (abfd, amt); 578 582 strcpy (secname, secbuf); 579 583 sec = bfd_make_section (abfd, secname); … … 609 613 free (buf); 610 614 611 return true;615 return TRUE; 612 616 } 613 617 } … … 622 626 free (buf); 623 627 624 return true;628 return TRUE; 625 629 626 630 error_return: … … 629 633 if (buf != NULL) 630 634 free (buf); 631 return false;635 return FALSE; 632 636 } 633 637 … … 638 642 bfd *abfd; 639 643 { 644 PTR tdata_save; 640 645 bfd_byte b[4]; 641 646 … … 643 648 644 649 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 645 || bfd_ read (b, 1,4, abfd) != 4)650 || bfd_bread (b, (bfd_size_type) 4, abfd) != 4) 646 651 return NULL; 647 652 … … 652 657 } 653 658 654 if (! srec_mkobject (abfd) 655 || ! srec_scan (abfd)) 656 return NULL; 659 tdata_save = abfd->tdata.any; 660 if (! srec_mkobject (abfd) || ! srec_scan (abfd)) 661 { 662 if (abfd->tdata.any != tdata_save && abfd->tdata.any != NULL) 663 bfd_release (abfd, abfd->tdata.any); 664 abfd->tdata.any = tdata_save; 665 return NULL; 666 } 657 667 658 668 if (abfd->symcount > 0) … … 668 678 bfd *abfd; 669 679 { 680 PTR tdata_save; 670 681 char b[2]; 671 682 … … 673 684 674 685 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 675 || bfd_ read (b, 1,2, abfd) != 2)686 || bfd_bread (b, (bfd_size_type) 2, abfd) != 2) 676 687 return NULL; 677 688 … … 682 693 } 683 694 684 if (! srec_mkobject (abfd) 685 || ! srec_scan (abfd)) 686 return NULL; 695 tdata_save = abfd->tdata.any; 696 if (! srec_mkobject (abfd) || ! srec_scan (abfd)) 697 { 698 if (abfd->tdata.any != tdata_save && abfd->tdata.any != NULL) 699 bfd_release (abfd, abfd->tdata.any); 700 abfd->tdata.any = tdata_save; 701 return NULL; 702 } 687 703 688 704 if (abfd->symcount > 0) … … 694 710 /* Read in the contents of a section in an S-record file. */ 695 711 696 static b oolean712 static bfd_boolean 697 713 srec_read_section (abfd, section, contents) 698 714 bfd *abfd; … … 702 718 int c; 703 719 bfd_size_type sofar = 0; 704 b oolean error = false;720 bfd_boolean error = FALSE; 705 721 bfd_byte *buf = NULL; 706 722 size_t bufsize = 0; … … 720 736 721 737 /* This is called after srec_scan has already been called, so we 722 738 ought to know the exact format. */ 723 739 BFD_ASSERT (c == 'S'); 724 740 725 if (bfd_ read (hdr, 1,3, abfd) != 3)741 if (bfd_bread (hdr, (bfd_size_type) 3, abfd) != 3) 726 742 goto error_return; 727 743 … … 734 750 if (buf != NULL) 735 751 free (buf); 736 buf = (bfd_byte *) bfd_malloc ( bytes * 2);752 buf = (bfd_byte *) bfd_malloc ((bfd_size_type) bytes * 2); 737 753 if (buf == NULL) 738 754 goto error_return; … … 740 756 } 741 757 742 if (bfd_ read (buf, 1,bytes * 2, abfd) != bytes * 2)758 if (bfd_bread (buf, (bfd_size_type) bytes * 2, abfd) != bytes * 2) 743 759 goto error_return; 744 760 … … 751 767 if (buf != NULL) 752 768 free (buf); 753 return true;769 return TRUE; 754 770 755 771 case '3': … … 776 792 if (buf != NULL) 777 793 free (buf); 778 return true;794 return TRUE; 779 795 } 780 796 … … 801 817 free (buf); 802 818 803 return true;819 return TRUE; 804 820 805 821 error_return: 806 822 if (buf != NULL) 807 823 free (buf); 808 return false;824 return FALSE; 809 825 } 810 826 811 827 /* Get the contents of a section in an S-record file. */ 812 828 813 static b oolean829 static bfd_boolean 814 830 srec_get_section_contents (abfd, section, location, offset, count) 815 831 bfd *abfd; … … 822 838 { 823 839 section->used_by_bfd = bfd_alloc (abfd, section->_raw_size); 824 if (section->used_by_bfd == NULL 825 && section->_raw_size != 0) 826 return false; 840 if (section->used_by_bfd == NULL && section->_raw_size != 0) 841 return FALSE; 827 842 828 843 if (! srec_read_section (abfd, section, section->used_by_bfd)) 829 return false;844 return FALSE; 830 845 } 831 846 … … 833 848 (size_t) count); 834 849 835 return true;850 return TRUE; 836 851 } 837 852 838 853 /* Set the architecture. We accept an unknown architecture here. */ 839 854 840 static b oolean855 static bfd_boolean 841 856 srec_set_arch_mach (abfd, arch, mach) 842 857 bfd *abfd; … … 847 862 { 848 863 abfd->arch_info = &bfd_default_arch_struct; 849 return true;864 return TRUE; 850 865 } 851 866 return bfd_default_set_arch_mach (abfd, arch, mach); … … 854 869 /* We have to save up all the Srecords for a splurge before output. */ 855 870 856 static b oolean871 static bfd_boolean 857 872 srec_set_section_contents (abfd, section, location, offset, bytes_to_do) 858 873 bfd *abfd; … … 866 881 867 882 entry = ((srec_data_list_type *) 868 bfd_alloc (abfd, sizeof (srec_data_list_type)));883 bfd_alloc (abfd, (bfd_size_type) sizeof (srec_data_list_type))); 869 884 if (entry == NULL) 870 return false;885 return FALSE; 871 886 872 887 if (bytes_to_do … … 874 889 && (section->flags & SEC_LOAD)) 875 890 { 876 bfd_byte *data = (bfd_byte *) bfd_alloc (abfd, bytes_to_do); 891 bfd_byte *data; 892 893 data = (bfd_byte *) bfd_alloc (abfd, bytes_to_do); 877 894 if (data == NULL) 878 return false;895 return FALSE; 879 896 memcpy ((PTR) data, location, (size_t) bytes_to_do); 880 897 881 /* Ff S3Forced is truethen always select S3 records,898 /* Ff S3Forced is TRUE then always select S3 records, 882 899 regardless of the siez of the addresses. */ 883 900 if (S3Forced) … … 896 913 897 914 /* Sort the records by address. Optimize for the common case of 898 915 adding a record to the end of the list. */ 899 916 if (tdata->tail != NULL 900 917 && entry->where >= tdata->tail->where) … … 918 935 } 919 936 } 920 return true;937 return TRUE; 921 938 } 922 939 … … 925 942 here. */ 926 943 927 static b oolean944 static bfd_boolean 928 945 srec_write_record (abfd, type, address, data, end) 929 946 bfd *abfd; 930 int type;947 unsigned int type; 931 948 bfd_vma address; 932 949 const bfd_byte *data; 933 950 const bfd_byte *end; 934 951 { 935 char buffer[ MAXCHUNK];952 char buffer[2 * MAXCHUNK + 6]; 936 953 unsigned int check_sum = 0; 937 CONSTbfd_byte *src = data;954 const bfd_byte *src = data; 938 955 char *dst = buffer; 939 956 char *length; … … 982 999 *dst++ = '\n'; 983 1000 wrlen = dst - buffer; 984 if (bfd_ write ((PTR) buffer, 1, wrlen, abfd) != wrlen)985 return false;986 return true;987 } 988 989 static b oolean1001 if (bfd_bwrite ((PTR) buffer, wrlen, abfd) != wrlen) 1002 return FALSE; 1003 return TRUE; 1004 } 1005 1006 static bfd_boolean 990 1007 srec_write_header (abfd) 991 1008 bfd *abfd; 992 1009 { 993 bfd_byte buffer[MAXCHUNK]; 994 bfd_byte *dst = buffer; 995 unsigned int i; 1010 unsigned int len = strlen (abfd->filename); 996 1011 997 1012 /* I'll put an arbitary 40 char limit on header size. */ 998 for (i = 0; i < 40 && abfd->filename[i]; i++) 999 *dst++ = abfd->filename[i]; 1000 1001 return srec_write_record (abfd, 0, 0, buffer, dst); 1002 } 1003 1004 static boolean 1013 if (len > 40) 1014 len = 40; 1015 1016 return srec_write_record (abfd, 0, (bfd_vma) 0, 1017 abfd->filename, abfd->filename + len); 1018 } 1019 1020 static bfd_boolean 1005 1021 srec_write_section (abfd, tdata, list) 1006 1022 bfd *abfd; … … 1010 1026 unsigned int octets_written = 0; 1011 1027 bfd_byte *location = list->data; 1028 1029 /* Validate number of data bytes to write. The srec length byte 1030 counts the address, data and crc bytes. S1 (tdata->type == 1) 1031 records have two address bytes, S2 (tdata->type == 2) records 1032 have three, and S3 (tdata->type == 3) records have four. 1033 The total length can't exceed 255, and a zero data length will 1034 spin for a long time. */ 1035 if (Chunk == 0) 1036 Chunk = 1; 1037 else if (Chunk > MAXCHUNK - tdata->type - 2) 1038 Chunk = MAXCHUNK - tdata->type - 2; 1012 1039 1013 1040 while (octets_written < list->size) … … 1026 1053 location, 1027 1054 location + octets_this_chunk)) 1028 return false;1055 return FALSE; 1029 1056 1030 1057 octets_written += octets_this_chunk; … … 1032 1059 } 1033 1060 1034 return true;1035 } 1036 1037 static b oolean1061 return TRUE; 1062 } 1063 1064 static bfd_boolean 1038 1065 srec_write_terminator (abfd, tdata) 1039 1066 bfd *abfd; 1040 1067 tdata_type *tdata; 1041 1068 { 1042 bfd_byte buffer[2];1043 1044 1069 return srec_write_record (abfd, 10 - tdata->type, 1045 abfd->start_address, buffer, buffer);1046 } 1047 1048 static b oolean1070 abfd->start_address, NULL, NULL); 1071 } 1072 1073 static bfd_boolean 1049 1074 srec_write_symbols (abfd) 1050 1075 bfd *abfd; 1051 1076 { 1052 char buffer[MAXCHUNK];1053 1077 /* Dump out the symbols of a bfd. */ 1054 1078 int i; … … 1057 1081 if (count) 1058 1082 { 1059 size_tlen;1083 bfd_size_type len; 1060 1084 asymbol **table = bfd_get_outsymbols (abfd); 1061 sprintf (buffer, "$$ %s\r\n",abfd->filename);1062 1063 len = strlen (buffer); 1064 if (bfd_write (buffer, len, 1, abfd) != len)1065 return false;1085 len = strlen (abfd->filename); 1086 if (bfd_bwrite ("$$ ", (bfd_size_type) 3, abfd) != 3 1087 || bfd_bwrite (abfd->filename, len, abfd) != len 1088 || bfd_bwrite ("\r\n", (bfd_size_type) 2, abfd) != 2) 1089 return FALSE; 1066 1090 1067 1091 for (i = 0; i < count; i++) … … 1072 1096 { 1073 1097 /* Just dump out non debug symbols. */ 1074 bfd_size_type l; 1075 char buf2[40], *p; 1076 1077 sprintf_vma (buf2, 1078 s->value + s->section->output_section->lma 1079 + s->section->output_offset); 1080 p = buf2; 1098 char buf[43], *p; 1099 1100 len = strlen (s->name); 1101 if (bfd_bwrite (" ", (bfd_size_type) 2, abfd) != 2 1102 || bfd_bwrite (s->name, len, abfd) != len) 1103 return FALSE; 1104 1105 sprintf_vma (buf + 2, (s->value 1106 + s->section->output_section->lma 1107 + s->section->output_offset)); 1108 p = buf + 2; 1081 1109 while (p[0] == '0' && p[1] != 0) 1082 1110 p++; 1083 sprintf (buffer, " %s $%s\r\n", s->name, p); 1084 l = strlen (buffer); 1085 if (bfd_write (buffer, l, 1, abfd) != l) 1086 return false; 1111 len = strlen (p); 1112 p[len] = '\r'; 1113 p[len + 1] = '\n'; 1114 *--p = '$'; 1115 *--p = ' '; 1116 len += 4; 1117 if (bfd_bwrite (p, len, abfd) != len) 1118 return FALSE; 1087 1119 } 1088 1120 } 1089 sprintf (buffer, "$$ \r\n"); 1090 len = strlen (buffer); 1091 if (bfd_write (buffer, len, 1, abfd) != len) 1092 return false; 1093 } 1094 1095 return true; 1096 } 1097 1098 static boolean 1121 if (bfd_bwrite ("$$ \r\n", (bfd_size_type) 5, abfd) != 5) 1122 return FALSE; 1123 } 1124 1125 return TRUE; 1126 } 1127 1128 static bfd_boolean 1099 1129 internal_srec_write_object_contents (abfd, symbols) 1100 1130 bfd *abfd; … … 1107 1137 { 1108 1138 if (! srec_write_symbols (abfd)) 1109 return false;1139 return FALSE; 1110 1140 } 1111 1141 1112 1142 if (! srec_write_header (abfd)) 1113 return false;1143 return FALSE; 1114 1144 1115 1145 /* Now wander though all the sections provided and output them. */ … … 1119 1149 { 1120 1150 if (! srec_write_section (abfd, tdata, list)) 1121 return false;1151 return FALSE; 1122 1152 list = list->next; 1123 1153 } … … 1125 1155 } 1126 1156 1127 static b oolean1157 static bfd_boolean 1128 1158 srec_write_object_contents (abfd) 1129 1159 bfd *abfd; … … 1132 1162 } 1133 1163 1134 static b oolean1164 static bfd_boolean 1135 1165 symbolsrec_write_object_contents (abfd) 1136 1166 bfd *abfd; … … 1142 1172 srec_sizeof_headers (abfd, exec) 1143 1173 bfd *abfd ATTRIBUTE_UNUSED; 1144 b oolean exec ATTRIBUTE_UNUSED;1174 bfd_boolean exec ATTRIBUTE_UNUSED; 1145 1175 { 1146 1176 return 0; 1147 }1148 1149 static asymbol *1150 srec_make_empty_symbol (abfd)1151 bfd *abfd;1152 {1153 asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));1154 if (new)1155 new->the_bfd = abfd;1156 return new;1157 1177 } 1158 1178 … … 1173 1193 asymbol **alocation; 1174 1194 { 1175 unsigned intsymcount = bfd_get_symcount (abfd);1195 bfd_size_type symcount = bfd_get_symcount (abfd); 1176 1196 asymbol *csymbols; 1177 1197 unsigned int i; … … 1185 1205 csymbols = (asymbol *) bfd_alloc (abfd, symcount * sizeof (asymbol)); 1186 1206 if (csymbols == NULL && symcount != 0) 1187 return false;1207 return 0; 1188 1208 abfd->tdata.srec_data->csymbols = csymbols; 1189 1209 … … 1218 1238 1219 1239 static void 1220 srec_print_symbol ( ignore_abfd, afile, symbol, how)1221 bfd * ignore_abfd ATTRIBUTE_UNUSED;1240 srec_print_symbol (abfd, afile, symbol, how) 1241 bfd *abfd; 1222 1242 PTR afile; 1223 1243 asymbol *symbol; … … 1231 1251 break; 1232 1252 default: 1233 bfd_print_symbol_vandf ( (PTR) file, symbol);1253 bfd_print_symbol_vandf (abfd, (PTR) file, symbol); 1234 1254 fprintf (file, " %-5s %s", 1235 1255 symbol->section->name, … … 1246 1266 #define srec_get_lineno _bfd_nosymbols_get_lineno 1247 1267 #define srec_find_nearest_line _bfd_nosymbols_find_nearest_line 1268 #define srec_make_empty_symbol _bfd_generic_make_empty_symbol 1248 1269 #define srec_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol 1249 1270 #define srec_read_minisymbols _bfd_generic_read_minisymbols … … 1263 1284 #define srec_bfd_relax_section bfd_generic_relax_section 1264 1285 #define srec_bfd_gc_sections bfd_generic_gc_sections 1286 #define srec_bfd_merge_sections bfd_generic_merge_sections 1287 #define srec_bfd_discard_group bfd_generic_discard_group 1265 1288 #define srec_bfd_link_hash_table_create _bfd_generic_link_hash_table_create 1289 #define srec_bfd_link_hash_table_free _bfd_generic_link_hash_table_free 1266 1290 #define srec_bfd_link_add_symbols _bfd_generic_link_add_symbols 1291 #define srec_bfd_link_just_syms _bfd_generic_link_just_syms 1267 1292 #define srec_bfd_final_link _bfd_generic_final_link 1268 1293 #define srec_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.