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-gsd.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* vms-gsd.c -- BFD back-end for VAX (openVMS/VAX) and
    22   EVAX (openVMS/Alpha) files.
    3    Copyright 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
     3   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002
     4   Free Software Foundation, Inc.
    45
    56   go and read the openVMS linker manual (esp. appendix B)
     
    2122along with this program; if not, write to the Free Software
    2223Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
    23 
    24 #include <ctype.h>
    2524
    2625#include "bfd.h"
     
    140139};
    141140
     141static flagword vms_secflag_by_name PARAMS ((bfd *, struct sec_flags_struct *, char *, int));
     142static flagword vms_esecflag_by_name PARAMS ((struct sec_flags_struct *, char *, int));
     143
    142144/* Retrieve bfd section flags by name and size  */
    143145
    144146static flagword
    145 vms_secflag_by_name (abfd, section_flags, name, size)
     147vms_secflag_by_name (abfd, section_flags, name, hassize)
    146148     bfd *abfd;
    147149     struct sec_flags_struct *section_flags;
    148150     char *name;
    149      int size;
     151     int hassize;
    150152{
    151153  int i = 0;
     
    157159            strcmp (name, section_flags[i].name)) == 0)
    158160        {
    159           if (size > 0)
     161          if (hassize)
    160162            return section_flags[i].flags_hassize;
    161163          else
     
    164166      i++;
    165167    }
    166   if (size > 0)
     168  if (hassize)
    167169    return section_flags[i].flags_hassize;
    168170  return section_flags[i].flags_always;
     
    172174
    173175static flagword
    174 vms_esecflag_by_name (section_flags, name, size)
     176vms_esecflag_by_name (section_flags, name, hassize)
    175177     struct sec_flags_struct *section_flags;
    176178     char *name;
    177      int size;
     179     int hassize;
    178180{
    179181  int i = 0;
     
    183185      if (strcmp (name, section_flags[i].name) == 0)
    184186        {
    185           if (size > 0)
     187          if (hassize)
    186188            return section_flags[i].vflags_hassize;
    187189          else
     
    190192      i++;
    191193    }
    192   if (size > 0)
     194  if (hassize)
    193195    return section_flags[i].vflags_hassize;
    194196  return section_flags[i].vflags_always;
     
    288290  switch (objtype)
    289291    {
    290       case EOBJ_S_C_EGSD:
    291         PRIV(vms_rec) += 8;     /* skip type, size, l_temp */
    292         PRIV(rec_size) -= 8;
    293         break;
    294       case OBJ_S_C_GSD:
    295         PRIV(vms_rec) += 1;
    296         PRIV(rec_size) -= 1;
    297         break;
    298       default:
    299         return -1;
     292    case EOBJ_S_C_EGSD:
     293      PRIV(vms_rec) += 8;       /* skip type, size, l_temp */
     294      PRIV(rec_size) -= 8;
     295      break;
     296    case OBJ_S_C_GSD:
     297      PRIV(vms_rec) += 1;
     298      PRIV(rec_size) -= 1;
     299      break;
     300    default:
     301      return -1;
    300302    }
    301303
     
    357359                }
    358360              old_flags = bfd_getl16 (vms_rec + 2);
    359               section->_raw_size = bfd_getl32(vms_rec + 4);     /* allocation */
    360               new_flags = vms_secflag_by_name (abfd, vax_section_flags, name, section->_raw_size);
     361              section->_raw_size = bfd_getl32 (vms_rec + 4);  /* allocation */
     362              new_flags = vms_secflag_by_name (abfd, vax_section_flags, name,
     363                                               section->_raw_size > 0);
    361364              if (old_flags & EGPS_S_V_REL)
    362365                new_flags |= SEC_RELOC;
     
    412415                    {
    413416                      section->contents = ((unsigned char *)
    414                                     bfd_realloc (old_section->contents, section->_raw_size));
     417                                           bfd_realloc (old_section->contents,
     418                                                        section->_raw_size));
    415419                      if (section->contents == NULL)
    416420                        {
    417421                          bfd_set_error (bfd_error_no_memory);
    418422                          return -1;
    419                         }
     423                        }
    420424                    }
    421425                }
     
    423427                {
    424428                  section->contents = ((unsigned char *)
    425                                         bfd_malloc (section->_raw_size));
     429                                       bfd_zmalloc (section->_raw_size));
    426430                  if (section->contents == NULL)
    427431                    {
     
    429433                      return -1;
    430434                    }
    431                   memset (section->contents, 0, (size_t)section->_raw_size);
    432435                }
    433436              section->_cooked_size = section->_raw_size;
     
    454457          case GSD_S_C_SYMW:
    455458            {
    456               int name_offset, value_offset;
     459              int name_offset = 0, value_offset = 0;
    457460
    458461              /*
     
    471474              switch (gsd_type)
    472475                {
    473                   case GSD_S_C_EPM:
    474                     name_offset = 11;
    475                     value_offset = 5;
    476                     new_flags |= BSF_FUNCTION;
    477                     break;
    478                   case GSD_S_C_EPMW:
    479                     name_offset = 12;
    480                     value_offset = 6;
    481                     new_flags |= BSF_FUNCTION;
    482                     break;
    483                   case GSD_S_C_SYM:
    484                     if (old_flags & GSY_S_M_DEF)        /* symbol definition */
    485                       name_offset = 9;
    486                     else
    487                       name_offset = 4;
    488                     value_offset = 5;
    489                     break;
    490                   case GSD_S_C_SYMW:
    491                     if (old_flags & GSY_S_M_DEF)        /* symbol definition */
    492                       name_offset = 10;
    493                     else
    494                       name_offset = 5;
    495                     value_offset = 6;
    496                     break;
     476                case GSD_S_C_EPM:
     477                  name_offset = 11;
     478                  value_offset = 5;
     479                  new_flags |= BSF_FUNCTION;
     480                  break;
     481                case GSD_S_C_EPMW:
     482                  name_offset = 12;
     483                  value_offset = 6;
     484                  new_flags |= BSF_FUNCTION;
     485                  break;
     486                case GSD_S_C_SYM:
     487                  if (old_flags & GSY_S_M_DEF)  /* symbol definition */
     488                    name_offset = 9;
     489                  else
     490                    name_offset = 4;
     491                  value_offset = 5;
     492                  break;
     493                case GSD_S_C_SYMW:
     494                  if (old_flags & GSY_S_M_DEF)  /* symbol definition */
     495                    name_offset = 10;
     496                  else
     497                    name_offset = 5;
     498                  value_offset = 6;
     499                  break;
    497500                }
    498501
     
    602605            old_flags = bfd_getl16 (vms_rec + 6);
    603606            section->_raw_size = bfd_getl32 (vms_rec + 8);      /* allocation */
    604             new_flags = vms_secflag_by_name (abfd, evax_section_flags, name, (int) section->_raw_size);
     607            new_flags = vms_secflag_by_name (abfd, evax_section_flags, name,
     608                                             section->_raw_size > 0);
    605609            if (old_flags & EGPS_S_V_REL)
    606610              new_flags |= SEC_RELOC;
     
    614618            base_addr += section->_raw_size;
    615619            section->contents = ((unsigned char *)
    616                                  bfd_malloc (section->_raw_size));
     620                                 bfd_zmalloc (section->_raw_size));
    617621            if (section->contents == NULL)
    618622              return -1;
    619             memset (section->contents, 0, (size_t) section->_raw_size);
    620623            section->_cooked_size = section->_raw_size;
    621624#if VMS_DEBUG
     
    632635            /* symbol specification (definition or reference)  */
    633636
    634             symbol = _bfd_vms_make_empty_symbol (abfd);
     637            symbol = bfd_make_empty_symbol (abfd);
    635638            if (symbol == 0)
    636639              return -1;
     
    659662            else        /* symbol reference */
    660663              {
    661                 symbol->name =
     664                symbol->name =
    662665                  _bfd_vms_save_counted_string (vms_rec+8);
    663666#if VMS_DEBUG
     
    665668                           symbol->name, old_flags, flag2str(gsyflagdesc, old_flags));
    666669#endif
    667                 symbol->section = bfd_make_section (abfd, BFD_UND_SECTION_NAME);
     670                symbol->section = bfd_make_section (abfd, BFD_UND_SECTION_NAME);
    668671              }
    669672
     
    672675            /* save symbol in vms_symbol_table  */
    673676
    674             entry = (vms_symbol_entry *) bfd_hash_lookup (PRIV(vms_symbol_table), symbol->name, true, false);
     677            entry = (vms_symbol_entry *) bfd_hash_lookup (PRIV(vms_symbol_table),
     678                                                          symbol->name,
     679                                                          TRUE, FALSE);
    675680            if (entry == (vms_symbol_entry *)NULL)
    676681              {
     
    819824      else
    820825        {
    821           new_flags = vms_esecflag_by_name (evax_section_flags, sname, section->_raw_size);
     826          new_flags = vms_esecflag_by_name (evax_section_flags, sname,
     827                                            section->_raw_size > 0);
    822828        }
    823829      _bfd_vms_output_short (abfd, new_flags);
    824       _bfd_vms_output_long (abfd, section->_raw_size);
     830      _bfd_vms_output_long (abfd, (unsigned long) section->_raw_size);
    825831      _bfd_vms_output_counted (abfd, sname);
    826832      _bfd_vms_output_flush (abfd);
     
    840846  for (symnum = 0; symnum < abfd->symcount; symnum++)
    841847    {
     848      char *hash;
    842849
    843850      symbol = abfd->outsymbols[symnum];
     
    891898      _bfd_vms_output_short (abfd, new_flags);
    892899
    893       if (old_flags & (BSF_GLOBAL|BSF_WEAK))            /* symbol definition */
    894         {
    895           if (old_flags & BSF_FUNCTION)
     900      if (old_flags & (BSF_GLOBAL | BSF_WEAK))          /* symbol definition */
     901        {
     902          uquad code_address = 0;
     903          unsigned long ca_psindx = 0;
     904          unsigned long psindx;
     905
     906          if ((old_flags & BSF_FUNCTION) && symbol->udata.p != NULL)
    896907            {
    897               _bfd_vms_output_quad (abfd, symbol->value);
    898               _bfd_vms_output_quad (abfd,
    899                                      ((asymbol *) (symbol->udata.p))->value);
    900               _bfd_vms_output_long (abfd,
    901                                      (((asymbol *) (symbol->udata.p))
    902                                       ->section->index));
    903               _bfd_vms_output_long (abfd, symbol->section->index);
     908              code_address = ((asymbol *) (symbol->udata.p))->value;
     909              ca_psindx = ((asymbol *) (symbol->udata.p))->section->index;
    904910            }
    905           else
    906             {
    907               _bfd_vms_output_quad (abfd, symbol->value);       /* L_VALUE */
    908               _bfd_vms_output_quad (abfd, 0);                   /* L_CODE_ADDRESS */
    909               _bfd_vms_output_long (abfd, 0);                   /* L_CA_PSINDX */
    910               _bfd_vms_output_long (abfd, symbol->section->index);/* L_PSINDX */
    911             }
    912         }
    913       _bfd_vms_output_counted (abfd, _bfd_vms_length_hash_symbol (abfd, symbol->name, EOBJ_S_C_SYMSIZ));
     911          psindx = symbol->section->index;
     912
     913          _bfd_vms_output_quad (abfd, symbol->value);
     914          _bfd_vms_output_quad (abfd, code_address);
     915          _bfd_vms_output_long (abfd, ca_psindx);
     916          _bfd_vms_output_long (abfd, psindx);
     917        }
     918      hash = _bfd_vms_length_hash_symbol (abfd, symbol->name, EOBJ_S_C_SYMSIZ);
     919      _bfd_vms_output_counted (abfd, hash);
    914920
    915921      _bfd_vms_output_flush (abfd);
Note: See TracChangeset for help on using the changeset viewer.