Changeset 609 for branches/GNU/src/binutils/bfd/vms-misc.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/bfd/vms-misc.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* vms-misc.c -- Miscellaneous functions for VAX (openVMS/VAX) and 2 2 EVAX (openVMS/Alpha) files. 3 Copyright 1996, 1997, 1998, 1999, 2000, 2001 3 Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 4 4 Free Software Foundation, Inc. 5 5 … … 30 30 31 31 #include "vms.h" 32 33 static vms_section *add_new_contents PARAMS ((bfd *, sec_ptr)); 34 static int hash_string PARAMS ((const char *)); 35 static asymbol *new_symbol PARAMS ((bfd *, char *)); 32 36 33 37 /*-----------------------------------------------------------------------------*/ … … 291 295 if (PRIV (buf_size) == 0) 292 296 { 297 bfd_size_type amt; 298 293 299 if (PRIV (is_vax)) 294 300 { 295 PRIV (vms_buf) = (unsigned char *) malloc (OBJ_S_C_MAXRECSIZ); 296 PRIV (buf_size) = OBJ_S_C_MAXRECSIZ; 301 amt = OBJ_S_C_MAXRECSIZ; 297 302 PRIV (file_format) = FF_VAX; 298 303 } 299 304 else 300 PRIV (vms_buf) = (unsigned char *) malloc (6); 305 amt = 6; 306 PRIV (vms_buf) = (unsigned char *) bfd_malloc (amt); 307 PRIV (buf_size) = amt; 301 308 } 302 309 … … 304 311 305 312 if (vms_buf == 0) 306 { 307 bfd_set_error (bfd_error_no_memory); 308 return -1; 309 } 313 return -1; 310 314 311 315 switch (PRIV (file_format)) … … 333 337 if (bfd_tell (abfd) & 1) 334 338 { 335 if (bfd_ read (PRIV (vms_buf), 1,1, abfd) != 1)339 if (bfd_bread (PRIV (vms_buf), (bfd_size_type) 1, abfd) != 1) 336 340 { 337 341 bfd_set_error (bfd_error_file_truncated); … … 343 347 344 348 if ((test_len != 0) 345 && (bfd_ read (PRIV (vms_buf), 1,test_len, abfd)349 && (bfd_bread (PRIV (vms_buf), (bfd_size_type) test_len, abfd) 346 350 != (bfd_size_type) test_len)) 347 351 { … … 354 358 if (PRIV (file_format) == FF_UNKNOWN) 355 359 { /* record length repeats ? */ 356 if ( (vms_buf[0] == vms_buf[4])357 && (vms_buf[1] == vms_buf[5]))360 if (vms_buf[0] == vms_buf[4] 361 && vms_buf[1] == vms_buf[5]) 358 362 { 359 363 PRIV (file_format) = FF_FOREIGN; /* Y: foreign environment */ … … 369 373 if (PRIV (is_vax)) 370 374 { 371 PRIV (rec_length) = bfd_read (vms_buf, 1, PRIV (buf_size), abfd); 375 PRIV (rec_length) = bfd_bread (vms_buf, (bfd_size_type) PRIV (buf_size), 376 abfd); 372 377 if (PRIV (rec_length) <= 0) 373 378 { … … 381 386 /* extract vms record length */ 382 387 383 _bfd_vms_get_header_values (abfd, vms_buf +test_start, NULL,388 _bfd_vms_get_header_values (abfd, vms_buf + test_start, NULL, 384 389 &PRIV (rec_length)); 385 390 … … 402 407 if (PRIV (rec_length) > PRIV (buf_size)) 403 408 { 404 PRIV (vms_buf) = (unsigned char *) realloc (vms_buf, PRIV (rec_length)); 409 PRIV (vms_buf) = ((unsigned char *) 410 bfd_realloc (vms_buf, 411 (bfd_size_type) PRIV (rec_length))); 405 412 vms_buf = PRIV (vms_buf); 406 413 if (vms_buf == 0) 407 { 408 bfd_set_error (bfd_error_no_memory); 409 return -1; 410 } 414 return -1; 411 415 PRIV (buf_size) = PRIV (rec_length); 412 416 } … … 417 421 418 422 #if VMS_DEBUG 419 vms_debug (10, "bfd_ read remaining %d\n", remaining);420 #endif 421 if (bfd_ read (vms_buf + test_len, 1,remaining, abfd) !=423 vms_debug (10, "bfd_bread remaining %d\n", remaining); 424 #endif 425 if (bfd_bread (vms_buf + test_len, (bfd_size_type) remaining, abfd) != 422 426 (bfd_size_type) remaining) 423 427 { … … 429 433 430 434 #if VMS_DEBUG 431 vms_debug (11, "bfd_ read rec_length %d\n", PRIV (rec_length));435 vms_debug (11, "bfd_bread rec_length %d\n", PRIV (rec_length)); 432 436 #endif 433 437 … … 491 495 int size; 492 496 { 493 char *newstr = bfd_malloc ( size + 1);497 char *newstr = bfd_malloc ((bfd_size_type) size + 1); 494 498 495 499 if (newstr == NULL) 496 500 return 0; 497 strncpy (newstr, (char *) str,size);501 strncpy (newstr, (char *) str, (size_t) size); 498 502 newstr[size] = 0; 499 503 … … 593 597 return sptr; 594 598 595 newptr = (vms_section *) bfd_malloc (sizeof (vms_section)); 599 newptr = (vms_section *) bfd_alloc (abfd, 600 (bfd_size_type) sizeof (vms_section)); 596 601 if (newptr == (vms_section *) NULL) 597 602 return NULL; 598 newptr->contents = (unsigned char *) bfd_alloc (abfd, (int)section->_raw_size);599 if (newptr->contents == (unsigned char *) NULL)603 newptr->contents = (unsigned char *) bfd_alloc (abfd, section->_raw_size); 604 if (newptr->contents == (unsigned char *) NULL) 600 605 return NULL; 601 606 newptr->offset = 0; … … 606 611 } 607 612 608 /* Save section data & offset to a nvms_section structure609 vms_section_table[] holds the vms_section chain */610 611 b oolean613 /* Save section data & offset to a vms_section structure 614 vms_section_table[] holds the vms_section chain. */ 615 616 bfd_boolean 612 617 _bfd_save_vms_section (abfd, section, data, offset, count) 613 618 bfd *abfd; … … 622 627 { 623 628 bfd_set_error (bfd_error_nonrepresentable_section); 624 return false;629 return FALSE; 625 630 } 626 631 if (count == (bfd_size_type)0) 627 return true;632 return TRUE; 628 633 sptr = add_new_contents (abfd, section); 629 634 if (sptr == NULL) 630 return false;635 return FALSE; 631 636 memcpy (sptr->contents + offset, data, (size_t) count); 632 637 633 return true;638 return TRUE; 634 639 } 635 640 … … 668 673 #endif 669 674 670 _bfd_vms_output_short (abfd, rectype);675 _bfd_vms_output_short (abfd, (unsigned int) rectype); 671 676 672 677 /* save current output position to fill in lenght later */ … … 680 685 #endif 681 686 682 _bfd_vms_output_short (abfd, 0); /* placeholder for length */687 _bfd_vms_output_short (abfd, 0); /* placeholder for length */ 683 688 684 689 if (rechead != -1) 685 _bfd_vms_output_short (abfd, rechead);690 _bfd_vms_output_short (abfd, (unsigned int) rechead); 686 691 687 692 return; … … 783 788 /* put length to buffer */ 784 789 PRIV (output_size) = PRIV (length_pos); 785 _bfd_vms_output_short (abfd, (unsigned int) length);790 _bfd_vms_output_short (abfd, (unsigned int) length); 786 791 787 792 if (PRIV (push_level) == 0) … … 789 794 #ifndef VMS 790 795 /* write length first, see FF_FOREIGN in the input routines */ 791 fwrite (PRIV (output_buf)+2, 2, 1, (FILE *)abfd->iostream); 792 #endif 793 fwrite (PRIV (output_buf), real_size, 1, (FILE *)abfd->iostream); 796 fwrite (PRIV (output_buf) + 2, 2, 1, (FILE *) abfd->iostream); 797 #endif 798 fwrite (PRIV (output_buf), (size_t) real_size, 1, 799 (FILE *) abfd->iostream); 794 800 795 801 PRIV (output_size) = 0; … … 862 868 #endif 863 869 864 bfd_put_16 (abfd, value & 0xffff, PRIV (output_buf) + PRIV (output_size)); 870 bfd_put_16 (abfd, (bfd_vma) value & 0xffff, 871 PRIV (output_buf) + PRIV (output_size)); 865 872 PRIV (output_size) += 2; 866 873 return; … … 878 885 #endif 879 886 880 bfd_put_32 (abfd, value, PRIV (output_buf) + PRIV (output_size));887 bfd_put_32 (abfd, (bfd_vma) value, PRIV (output_buf) + PRIV (output_size)); 881 888 PRIV (output_size) += 4; 882 889 return; … … 923 930 return; 924 931 } 925 _bfd_vms_output_byte (abfd, len & 0xff);932 _bfd_vms_output_byte (abfd, (unsigned int) len & 0xff); 926 933 _bfd_vms_output_dump (abfd, (unsigned char *)value, len); 927 934 } … … 942 949 return; 943 950 944 memcpy (PRIV (output_buf) + PRIV (output_size), data, length);951 memcpy (PRIV (output_buf) + PRIV (output_size), data, (size_t) length); 945 952 PRIV (output_size) += length; 946 953 … … 962 969 if (count == 0) 963 970 return; 964 memset (PRIV (output_buf) + PRIV (output_size), value, count);971 memset (PRIV (output_buf) + PRIV (output_size), value, (size_t) count); 965 972 PRIV (output_size) += count; 966 973 … … 1034 1041 } 1035 1042 1036 strncpy (out, in, i);1043 strncpy (out, in, (size_t) i); 1037 1044 in += i; 1038 1045 out += i; … … 1069 1076 #endif 1070 1077 1071 symbol = _bfd_vms_make_empty_symbol (abfd);1078 symbol = bfd_make_empty_symbol (abfd); 1072 1079 if (symbol == 0) 1073 1080 return symbol; … … 1092 1099 1093 1100 entry = (vms_symbol_entry *) 1094 bfd_hash_lookup (PRIV (vms_symbol_table), name, false, false);1101 bfd_hash_lookup (PRIV (vms_symbol_table), name, FALSE, FALSE); 1095 1102 if (entry == 0) 1096 1103 { … … 1098 1105 _bfd_vms_debug (8, "creating hash entry for %s\n", name); 1099 1106 #endif 1100 entry = (vms_symbol_entry *)bfd_hash_lookup (PRIV (vms_symbol_table), name, true, false); 1107 entry = (vms_symbol_entry *) bfd_hash_lookup (PRIV (vms_symbol_table), 1108 name, TRUE, FALSE); 1101 1109 if (entry != 0) 1102 1110 { -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.