Ignore:
Timestamp:
Aug 16, 2003, 6:59:22 PM (22 years ago)
Author:
bird
Message:

binutils v2.14 - offical sources.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/binutils/bfd/vms-misc.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* vms-misc.c -- Miscellaneous functions for VAX (openVMS/VAX) and
    22   EVAX (openVMS/Alpha) files.
    3    Copyright 1996, 1997, 1998, 1999, 2000, 2001
     3   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002
    44   Free Software Foundation, Inc.
    55
     
    3030
    3131#include "vms.h"
     32
     33static vms_section *add_new_contents PARAMS ((bfd *, sec_ptr));
     34static int hash_string PARAMS ((const char *));
     35static asymbol *new_symbol PARAMS ((bfd *, char *));
    3236
    3337/*-----------------------------------------------------------------------------*/
     
    291295  if (PRIV (buf_size) == 0)
    292296    {
     297      bfd_size_type amt;
     298
    293299      if (PRIV (is_vax))
    294300        {
    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;
    297302          PRIV (file_format) = FF_VAX;
    298303        }
    299304      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;
    301308    }
    302309
     
    304311
    305312  if (vms_buf == 0)
    306     {
    307       bfd_set_error (bfd_error_no_memory);
    308       return -1;
    309     }
     313    return -1;
    310314
    311315  switch (PRIV (file_format))
     
    333337  if (bfd_tell (abfd) & 1)
    334338    {
    335       if (bfd_read (PRIV (vms_buf), 1, 1, abfd) != 1)
     339      if (bfd_bread (PRIV (vms_buf), (bfd_size_type) 1, abfd) != 1)
    336340        {
    337341          bfd_set_error (bfd_error_file_truncated);
     
    343347
    344348  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)
    346350          != (bfd_size_type) test_len))
    347351    {
     
    354358  if (PRIV (file_format) == FF_UNKNOWN)
    355359    {                                           /* 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])
    358362        {
    359363          PRIV (file_format) = FF_FOREIGN;      /* Y: foreign environment */
     
    369373  if (PRIV (is_vax))
    370374    {
    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);
    372377      if (PRIV (rec_length) <= 0)
    373378        {
     
    381386      /* extract vms record length  */
    382387
    383       _bfd_vms_get_header_values (abfd, vms_buf+test_start, NULL,
     388      _bfd_vms_get_header_values (abfd, vms_buf + test_start, NULL,
    384389                                  &PRIV (rec_length));
    385390
     
    402407      if (PRIV (rec_length) > PRIV (buf_size))
    403408        {
    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)));
    405412          vms_buf = PRIV (vms_buf);
    406413          if (vms_buf == 0)
    407             {
    408               bfd_set_error (bfd_error_no_memory);
    409               return -1;
    410             }
     414            return -1;
    411415          PRIV (buf_size) = PRIV (rec_length);
    412416        }
     
    417421
    418422#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) !=
    422426          (bfd_size_type) remaining)
    423427        {
     
    429433
    430434#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));
    432436#endif
    433437
     
    491495     int size;
    492496{
    493   char *newstr = bfd_malloc (size + 1);
     497  char *newstr = bfd_malloc ((bfd_size_type) size + 1);
    494498
    495499  if (newstr == NULL)
    496500    return 0;
    497   strncpy (newstr, (char *)str, size);
     501  strncpy (newstr, (char *) str, (size_t) size);
    498502  newstr[size] = 0;
    499503
     
    593597    return sptr;
    594598
    595   newptr = (vms_section *) bfd_malloc (sizeof (vms_section));
     599  newptr = (vms_section *) bfd_alloc (abfd,
     600                                      (bfd_size_type) sizeof (vms_section));
    596601  if (newptr == (vms_section *) NULL)
    597602    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)
    600605    return NULL;
    601606  newptr->offset = 0;
     
    606611}
    607612
    608 /* Save section data & offset to an vms_section structure
    609    vms_section_table[] holds the vms_section chain  */
    610 
    611 boolean
     613/* Save section data & offset to a vms_section structure
     614   vms_section_table[] holds the vms_section chain.  */
     615
     616bfd_boolean
    612617_bfd_save_vms_section (abfd, section, data, offset, count)
    613618     bfd *abfd;
     
    622627    {
    623628      bfd_set_error (bfd_error_nonrepresentable_section);
    624       return false;
     629      return FALSE;
    625630    }
    626631  if (count == (bfd_size_type)0)
    627     return true;
     632    return TRUE;
    628633  sptr = add_new_contents (abfd, section);
    629634  if (sptr == NULL)
    630     return false;
     635    return FALSE;
    631636  memcpy (sptr->contents + offset, data, (size_t) count);
    632637
    633   return true;
     638  return TRUE;
    634639}
    635640
     
    668673#endif
    669674
    670   _bfd_vms_output_short (abfd,rectype);
     675  _bfd_vms_output_short (abfd, (unsigned int) rectype);
    671676
    672677  /* save current output position to fill in lenght later  */
     
    680685#endif
    681686
    682   _bfd_vms_output_short (abfd,0);               /* placeholder for length */
     687  _bfd_vms_output_short (abfd, 0);              /* placeholder for length */
    683688
    684689  if (rechead != -1)
    685     _bfd_vms_output_short (abfd,rechead);
     690    _bfd_vms_output_short (abfd, (unsigned int) rechead);
    686691
    687692  return;
     
    783788  /* put length to buffer  */
    784789  PRIV (output_size) = PRIV (length_pos);
    785   _bfd_vms_output_short (abfd, (unsigned int)length);
     790  _bfd_vms_output_short (abfd, (unsigned int) length);
    786791
    787792  if (PRIV (push_level) == 0)
     
    789794#ifndef VMS
    790795        /* 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);
    794800
    795801      PRIV (output_size) = 0;
     
    862868#endif
    863869
    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));
    865872  PRIV (output_size) += 2;
    866873  return;
     
    878885#endif
    879886
    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));
    881888  PRIV (output_size) += 4;
    882889  return;
     
    923930      return;
    924931    }
    925   _bfd_vms_output_byte (abfd, len & 0xff);
     932  _bfd_vms_output_byte (abfd, (unsigned int) len & 0xff);
    926933  _bfd_vms_output_dump (abfd, (unsigned char *)value, len);
    927934}
     
    942949    return;
    943950
    944   memcpy (PRIV (output_buf) + PRIV (output_size), data, length);
     951  memcpy (PRIV (output_buf) + PRIV (output_size), data, (size_t) length);
    945952  PRIV (output_size) += length;
    946953
     
    962969  if (count == 0)
    963970    return;
    964   memset (PRIV (output_buf) + PRIV (output_size), value, count);
     971  memset (PRIV (output_buf) + PRIV (output_size), value, (size_t) count);
    965972  PRIV (output_size) += count;
    966973
     
    10341041    }
    10351042
    1036   strncpy (out, in, i);
     1043  strncpy (out, in, (size_t) i);
    10371044  in += i;
    10381045  out += i;
     
    10691076#endif
    10701077
    1071   symbol = _bfd_vms_make_empty_symbol (abfd);
     1078  symbol = bfd_make_empty_symbol (abfd);
    10721079  if (symbol == 0)
    10731080    return symbol;
     
    10921099
    10931100  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);
    10951102  if (entry == 0)
    10961103    {
     
    10981105      _bfd_vms_debug (8,  "creating hash entry for %s\n", name);
    10991106#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);
    11011109      if (entry != 0)
    11021110        {
Note: See TracChangeset for help on using the changeset viewer.