*** empty log message ***
[deliverable/binutils-gdb.git] / bfd / vms-hdr.c
index b8c8ee699ae787524ae04130c93e89d8292cb4c2..67c22b300d13ee4f56c2df92b367ad8fff97d733 100644 (file)
@@ -1,6 +1,6 @@
 /* vms-hdr.c -- BFD back-end for VMS/VAX (openVMS/VAX) and
    EVAX (openVMS/Alpha) files.
 /* vms-hdr.c -- BFD back-end for VMS/VAX (openVMS/VAX) and
    EVAX (openVMS/Alpha) files.
-   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005
+   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006
    Free Software Foundation, Inc.
 
    HDR record handling functions
    Free Software Foundation, Inc.
 
    HDR record handling functions
 
    Written by Klaus K"ampf (kkaempf@rmi.de)
 
 
    Written by Klaus K"ampf (kkaempf@rmi.de)
 
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
 
 
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
 
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 #include "bfd.h"
 #include "bfdver.h"
 
 #include "bfd.h"
 #include "bfdver.h"
@@ -38,18 +38,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #include <alloca.h>
 #endif
 
 #include <alloca.h>
 #endif
 
-static unsigned char *get_vms_time_string PARAMS ((void));
-
-
-/*---------------------------------------------------------------------------*/
-
 /* Read & process emh record
 /* Read & process emh record
-   return 0 on success, -1 on error  */
+   return 0 on success, -1 on error.  */
 
 int
 
 int
-_bfd_vms_slurp_hdr (abfd, objtype)
-     bfd *abfd;
-     int objtype;
+_bfd_vms_slurp_hdr (bfd *abfd, int objtype)
 {
   unsigned char *ptr;
   unsigned char *vms_rec;
 {
   unsigned char *ptr;
   unsigned char *vms_rec;
@@ -63,14 +56,14 @@ _bfd_vms_slurp_hdr (abfd, objtype)
 
   switch (objtype)
     {
 
   switch (objtype)
     {
-      case OBJ_S_C_HDR:
-       subtype = vms_rec[1];
-       break;
-      case EOBJ_S_C_EMH:
-       subtype = bfd_getl16 (vms_rec + 4) + EVAX_OFFSET;
-       break;
-      default:
-       subtype = -1;
+    case OBJ_S_C_HDR:
+      subtype = vms_rec[1];
+      break;
+    case EOBJ_S_C_EMH:
+      subtype = bfd_getl16 (vms_rec + 4) + EVAX_OFFSET;
+      break;
+    default:
+      subtype = -1;
     }
 
 #if VMS_DEBUG
     }
 
 #if VMS_DEBUG
@@ -79,138 +72,77 @@ _bfd_vms_slurp_hdr (abfd, objtype)
 
   switch (subtype)
     {
 
   switch (subtype)
     {
-
-      case MHD_S_C_MHD:
-       /*
-        * module header
-        */
-       PRIV(hdr_data).hdr_b_strlvl = vms_rec[2];
-       PRIV(hdr_data).hdr_l_recsiz = bfd_getl16 (vms_rec + 3);
-       PRIV(hdr_data).hdr_t_name = _bfd_vms_save_counted_string (vms_rec + 5);
-       ptr = vms_rec + 5 + vms_rec[5] + 1;
-       PRIV(hdr_data).hdr_t_version = _bfd_vms_save_counted_string (ptr);
-       ptr += *ptr + 1;
-       PRIV(hdr_data).hdr_t_date = _bfd_vms_save_sized_string (ptr, 17);
-
-      break;
-
-      case MHD_S_C_LNM:
-       /*
-        *
-        */
-       PRIV(hdr_data).hdr_c_lnm = _bfd_vms_save_sized_string (vms_rec, PRIV(rec_length-2));
-      break;
-
-      case MHD_S_C_SRC:
-       /*
-        *
-        */
-       PRIV(hdr_data).hdr_c_src = _bfd_vms_save_sized_string (vms_rec, PRIV(rec_length-2));
-      break;
-
-      case MHD_S_C_TTL:
-       /*
-        *
-        */
-       PRIV(hdr_data).hdr_c_ttl = _bfd_vms_save_sized_string (vms_rec, PRIV(rec_length-2));
-      break;
-
-      case MHD_S_C_CPR:
-       /*
-        *
-        */
-      break;
-
-      case MHD_S_C_MTC:
-       /*
-        *
-        */
+    case MHD_S_C_MHD:
+      /* Module header.  */
+      PRIV (hdr_data).hdr_b_strlvl = vms_rec[2];
+      PRIV (hdr_data).hdr_l_recsiz = bfd_getl16 (vms_rec + 3);
+      PRIV (hdr_data).hdr_t_name = _bfd_vms_save_counted_string (vms_rec + 5);
+      ptr = vms_rec + 5 + vms_rec[5] + 1;
+      PRIV (hdr_data).hdr_t_version = _bfd_vms_save_counted_string (ptr);
+      ptr += *ptr + 1;
+      PRIV (hdr_data).hdr_t_date = _bfd_vms_save_sized_string (ptr, 17);
       break;
 
       break;
 
-      case MHD_S_C_GTX:
-       /*
-        *
-        */
+    case MHD_S_C_LNM:
+      PRIV (hdr_data).hdr_c_lnm = _bfd_vms_save_sized_string (vms_rec, PRIV (rec_length - 2));
       break;
 
       break;
 
-      case EMH_S_C_MHD + EVAX_OFFSET:
-       /*
-        * module header
-        */
-       PRIV(hdr_data).hdr_b_strlvl = vms_rec[6];
-       PRIV(hdr_data).hdr_l_arch1 = bfd_getl32 (vms_rec + 8);
-       PRIV(hdr_data).hdr_l_arch2 = bfd_getl32 (vms_rec + 12);
-       PRIV(hdr_data).hdr_l_recsiz = bfd_getl32 (vms_rec + 16);
-       PRIV(hdr_data).hdr_t_name =
-         _bfd_vms_save_counted_string (vms_rec + 20);
-       ptr = vms_rec + 20 + vms_rec[20] + 1;
-       PRIV(hdr_data).hdr_t_version =
-         _bfd_vms_save_counted_string (ptr);
-       ptr += *ptr + 1;
-       PRIV(hdr_data).hdr_t_date =
-         _bfd_vms_save_sized_string (ptr, 17);
-
+    case MHD_S_C_SRC:
+      PRIV (hdr_data).hdr_c_src = _bfd_vms_save_sized_string (vms_rec, PRIV (rec_length - 2));
       break;
 
       break;
 
-      case EMH_S_C_LNM + EVAX_OFFSET:
-       /*
-        *
-        */
-       PRIV(hdr_data).hdr_c_lnm =
-         _bfd_vms_save_sized_string (vms_rec, PRIV(rec_length-6));
+    case MHD_S_C_TTL:
+      PRIV (hdr_data).hdr_c_ttl = _bfd_vms_save_sized_string (vms_rec, PRIV (rec_length - 2));
       break;
 
       break;
 
-      case EMH_S_C_SRC + EVAX_OFFSET:
-       /*
-        *
-        */
-       PRIV(hdr_data).hdr_c_src =
-         _bfd_vms_save_sized_string (vms_rec, PRIV(rec_length-6));
+    case EMH_S_C_MHD + EVAX_OFFSET:
+      /* Module header.  */
+      PRIV (hdr_data).hdr_b_strlvl = vms_rec[6];
+      PRIV (hdr_data).hdr_l_arch1  = bfd_getl32 (vms_rec + 8);
+      PRIV (hdr_data).hdr_l_arch2  = bfd_getl32 (vms_rec + 12);
+      PRIV (hdr_data).hdr_l_recsiz = bfd_getl32 (vms_rec + 16);
+      PRIV (hdr_data).hdr_t_name   = _bfd_vms_save_counted_string (vms_rec + 20);
+      ptr = vms_rec + 20 + vms_rec[20] + 1;
+      PRIV (hdr_data).hdr_t_version =_bfd_vms_save_counted_string (ptr);
+      ptr += *ptr + 1;
+      PRIV (hdr_data).hdr_t_date = _bfd_vms_save_sized_string (ptr, 17);
       break;
 
       break;
 
-      case EMH_S_C_TTL + EVAX_OFFSET:
-       /*
-        *
-        */
-       PRIV(hdr_data).hdr_c_ttl =
-         _bfd_vms_save_sized_string (vms_rec, PRIV(rec_length-6));
+    case EMH_S_C_LNM + EVAX_OFFSET:
+      PRIV (hdr_data).hdr_c_lnm = _bfd_vms_save_sized_string (vms_rec, PRIV (rec_length - 6));
       break;
 
       break;
 
-      case EMH_S_C_CPR + EVAX_OFFSET:
-       /*
-        *
-        */
+    case EMH_S_C_SRC + EVAX_OFFSET:
+      PRIV (hdr_data).hdr_c_src = _bfd_vms_save_sized_string (vms_rec, PRIV (rec_length - 6));
       break;
 
       break;
 
-      case EMH_S_C_MTC + EVAX_OFFSET:
-       /*
-        *
-        */
+    case EMH_S_C_TTL + EVAX_OFFSET:
+      PRIV (hdr_data).hdr_c_ttl = _bfd_vms_save_sized_string (vms_rec, PRIV (rec_length - 6));
       break;
 
       break;
 
-      case EMH_S_C_GTX + EVAX_OFFSET:
-       /*
-        *
-        */
+    case MHD_S_C_CPR:
+    case MHD_S_C_MTC:
+    case MHD_S_C_GTX:
+    case EMH_S_C_CPR + EVAX_OFFSET:
+    case EMH_S_C_MTC + EVAX_OFFSET:
+    case EMH_S_C_GTX + EVAX_OFFSET:
       break;
 
       break;
 
-      default:
-       bfd_set_error (bfd_error_wrong_format);
+    default:
+      bfd_set_error (bfd_error_wrong_format);
       return -1;
       return -1;
-
-    } /* switch */
+    }
 
   return 0;
 }
 
 
   return 0;
 }
 
-/*-----------------------------------------------------------------------------*/
 /* Output routines.  */
 
 /* Manufacture a VMS like time on a unix based system.
 /* Output routines.  */
 
 /* Manufacture a VMS like time on a unix based system.
-   stolen from obj-vms.c  */
+   stolen from obj-vms.c.  */
 
 static unsigned char *
 
 static unsigned char *
-get_vms_time_string ()
+get_vms_time_string (void)
 {
   static unsigned char tbuf[18];
 #ifndef VMS
 {
   static unsigned char tbuf[18];
 #ifndef VMS
@@ -218,7 +150,8 @@ get_vms_time_string ()
 
   char *pnt;
   time_t timeb;
 
   char *pnt;
   time_t timeb;
-  time (&timeb);
+
+  time (& timeb);
   pnt = ctime (&timeb);
   pnt[3] = 0;
   pnt[7] = 0;
   pnt = ctime (&timeb);
   pnt[3] = 0;
   pnt[7] = 0;
@@ -246,12 +179,10 @@ get_vms_time_string ()
   return tbuf;
 }
 
   return tbuf;
 }
 
-/* write object header for bfd abfd  */
+/* Write object header for bfd abfd.  */
 
 int
 
 int
-_bfd_vms_write_hdr (abfd, objtype)
-     bfd *abfd;
-     int objtype;
+_bfd_vms_write_hdr (bfd *abfd, int objtype)
 {
   asymbol *symbol;
   unsigned int symnum;
 {
   asymbol *symbol;
   unsigned int symnum;
@@ -264,12 +195,8 @@ _bfd_vms_write_hdr (abfd, objtype)
 
   _bfd_vms_output_alignment (abfd, 2);
 
 
   _bfd_vms_output_alignment (abfd, 2);
 
-  /* MHD */
-
-  if (objtype == OBJ_S_C_HDR)
-    {
-    }
-  else
+  /* MHD.  */
+  if (objtype != OBJ_S_C_HDR)
     {
       _bfd_vms_output_begin (abfd, EOBJ_S_C_EMH, EMH_S_C_MHD);
       _bfd_vms_output_short (abfd, EOBJ_S_C_STRLVL);
     {
       _bfd_vms_output_begin (abfd, EOBJ_S_C_EMH, EMH_S_C_MHD);
       _bfd_vms_output_short (abfd, EOBJ_S_C_STRLVL);
@@ -280,12 +207,11 @@ _bfd_vms_write_hdr (abfd, objtype)
 
   if (bfd_get_filename (abfd) != 0)
     {
 
   if (bfd_get_filename (abfd) != 0)
     {
-      /* strip path and suffix information */
-
+      /* Strip path and suffix information.  */
       char *fname, *fout, *fptr;
 
       fptr = bfd_get_filename (abfd);
       char *fname, *fout, *fptr;
 
       fptr = bfd_get_filename (abfd);
-      fname = (char *) alloca (strlen (fptr) + 1);
+      fname = alloca (strlen (fptr) + 1);
       strcpy (fname, fptr);
       fout = strrchr (fname, ']');
       if (fout == 0)
       strcpy (fname, fptr);
       fout = strrchr (fname, ']');
       if (fout == 0)
@@ -295,8 +221,7 @@ _bfd_vms_write_hdr (abfd, objtype)
       else
        fout = fname;
 
       else
        fout = fname;
 
-      /* strip .obj suffix  */
-
+      /* Strip .obj suffix.  */
       fptr = strrchr (fname, '.');
       if ((fptr != 0)
          && (strcasecmp (fptr, ".OBJ") == 0))
       fptr = strrchr (fname, '.');
       if ((fptr != 0)
          && (strcasecmp (fptr, ".OBJ") == 0))
@@ -321,14 +246,12 @@ _bfd_vms_write_hdr (abfd, objtype)
   _bfd_vms_output_fill (abfd, 0, 17);
   _bfd_vms_output_flush (abfd);
 
   _bfd_vms_output_fill (abfd, 0, 17);
   _bfd_vms_output_flush (abfd);
 
-  /* LMN */
-
+  /* LMN.  */
   _bfd_vms_output_begin (abfd, EOBJ_S_C_EMH, EMH_S_C_LNM);
   _bfd_vms_output_begin (abfd, EOBJ_S_C_EMH, EMH_S_C_LNM);
-  _bfd_vms_output_dump (abfd, (unsigned char *)"GAS proGIS", 10);
+  _bfd_vms_output_dump (abfd, (unsigned char *) STRING_COMMA_LEN ("GAS proGIS"));
   _bfd_vms_output_flush (abfd);
 
   _bfd_vms_output_flush (abfd);
 
-  /* SRC */
-
+  /* SRC.  */
   _bfd_vms_output_begin (abfd, EOBJ_S_C_EMH, EMH_S_C_SRC);
 
   for (symnum = 0; symnum < abfd->symcount; symnum++)
   _bfd_vms_output_begin (abfd, EOBJ_S_C_EMH, EMH_S_C_SRC);
 
   for (symnum = 0; symnum < abfd->symcount; symnum++)
@@ -337,10 +260,10 @@ _bfd_vms_write_hdr (abfd, objtype)
 
       if (symbol->flags & BSF_FILE)
        {
 
       if (symbol->flags & BSF_FILE)
        {
-         if (strncmp ((char *)symbol->name, "<CASE:", 6) == 0)
+         if (CONST_STRNEQ ((char *)symbol->name, "<CASE:"))
            {
            {
-             PRIV(flag_hash_long_names) = symbol->name[6] - '0';
-             PRIV(flag_show_after_trunc) = symbol->name[7] - '0';
+             PRIV (flag_hash_long_names) = symbol->name[6] - '0';
+             PRIV (flag_show_after_trunc) = symbol->name[7] - '0';
 
              if (had_file)
                break;
 
              if (had_file)
                break;
@@ -357,18 +280,16 @@ _bfd_vms_write_hdr (abfd, objtype)
     }
 
   if (symnum == abfd->symcount)
     }
 
   if (symnum == abfd->symcount)
-    _bfd_vms_output_dump (abfd, (unsigned char *)"noname", 6);
+    _bfd_vms_output_dump (abfd, (unsigned char *) STRING_COMMA_LEN ("noname"));
 
   _bfd_vms_output_flush (abfd);
 
 
   _bfd_vms_output_flush (abfd);
 
-  /* TTL */
-
+  /* TTL.  */
   _bfd_vms_output_begin (abfd, EOBJ_S_C_EMH, EMH_S_C_TTL);
   _bfd_vms_output_begin (abfd, EOBJ_S_C_EMH, EMH_S_C_TTL);
-  _bfd_vms_output_dump (abfd, (unsigned char *)"TTL", 3);
+  _bfd_vms_output_dump (abfd, (unsigned char *) STRING_COMMA_LEN ("TTL"));
   _bfd_vms_output_flush (abfd);
 
   _bfd_vms_output_flush (abfd);
 
-  /* CPR */
-
+  /* CPR.  */
   _bfd_vms_output_begin (abfd, EOBJ_S_C_EMH, EMH_S_C_CPR);
   _bfd_vms_output_dump (abfd,
                         (unsigned char *)"GNU BFD ported by Klaus Kämpf 1994-1996",
   _bfd_vms_output_begin (abfd, EOBJ_S_C_EMH, EMH_S_C_CPR);
   _bfd_vms_output_dump (abfd,
                         (unsigned char *)"GNU BFD ported by Klaus Kämpf 1994-1996",
@@ -378,15 +299,11 @@ _bfd_vms_write_hdr (abfd, objtype)
   return 0;
 }
 
   return 0;
 }
 
-/*-----------------------------------------------------------------------------*/
-
 /* Process EOM/EEOM record
 /* Process EOM/EEOM record
-   return 0 on success, -1 on error  */
+   return 0 on success, -1 on error.  */
 
 int
 
 int
-_bfd_vms_slurp_eom (abfd, objtype)
-     bfd *abfd;
-     int objtype;
+_bfd_vms_slurp_eom (bfd *abfd, int objtype)
 {
   unsigned char *vms_rec;
 
 {
   unsigned char *vms_rec;
 
@@ -394,7 +311,7 @@ _bfd_vms_slurp_eom (abfd, objtype)
   vms_debug(2, "EOM/EEOM\n");
 #endif
 
   vms_debug(2, "EOM/EEOM\n");
 #endif
 
-  vms_rec = PRIV(vms_rec);
+  vms_rec = PRIV (vms_rec);
 
   if ((objtype == OBJ_S_C_EOM)
      || (objtype == OBJ_S_C_EOMW))
 
   if ((objtype == OBJ_S_C_EOM)
      || (objtype == OBJ_S_C_EOMW))
@@ -402,43 +319,42 @@ _bfd_vms_slurp_eom (abfd, objtype)
     }
   else
     {
     }
   else
     {
-      PRIV(eom_data).eom_l_total_lps = bfd_getl32 (vms_rec + 4);
-      PRIV(eom_data).eom_b_comcod = *(vms_rec + 8);
-      if (PRIV(eom_data).eom_b_comcod > 1)
+      PRIV (eom_data).eom_l_total_lps = bfd_getl32 (vms_rec + 4);
+      PRIV (eom_data).eom_b_comcod = *(vms_rec + 8);
+
+      if (PRIV (eom_data).eom_b_comcod > 1)
        {
          (*_bfd_error_handler) (_("Object module NOT error-free !\n"));
          bfd_set_error (bfd_error_bad_value);
          return -1;
        }
        {
          (*_bfd_error_handler) (_("Object module NOT error-free !\n"));
          bfd_set_error (bfd_error_bad_value);
          return -1;
        }
-      PRIV(eom_data).eom_has_transfer = FALSE;
-      if (PRIV(rec_size) > 10)
+      PRIV (eom_data).eom_has_transfer = FALSE;
+      if (PRIV (rec_size) > 10)
        {
        {
-          PRIV(eom_data).eom_has_transfer = TRUE;
-          PRIV(eom_data).eom_b_tfrflg = *(vms_rec + 9);
-          PRIV(eom_data).eom_l_psindx = bfd_getl32 (vms_rec + 12);
-          PRIV(eom_data).eom_l_tfradr = bfd_getl32 (vms_rec + 16);
+          PRIV (eom_data).eom_has_transfer = TRUE;
+          PRIV (eom_data).eom_b_tfrflg = *(vms_rec + 9);
+          PRIV (eom_data).eom_l_psindx = bfd_getl32 (vms_rec + 12);
+          PRIV (eom_data).eom_l_tfradr = bfd_getl32 (vms_rec + 16);
 
 
-          abfd->start_address = PRIV(eom_data).eom_l_tfradr;
+          abfd->start_address = PRIV (eom_data).eom_l_tfradr;
        }
     }
   return 0;
 }
 
        }
     }
   return 0;
 }
 
-/* Write eom record for bfd abfd  */
+/* Write eom record for bfd abfd.  */
 
 int
 
 int
-_bfd_vms_write_eom (abfd, objtype)
-     bfd *abfd;
-     int objtype;
+_bfd_vms_write_eom (bfd *abfd, int objtype)
 {
 #if VMS_DEBUG
   vms_debug (2, "vms_write_eom (%p, %d)\n", abfd, objtype);
 #endif
 
   _bfd_vms_output_begin (abfd, objtype, -1);
 {
 #if VMS_DEBUG
   vms_debug (2, "vms_write_eom (%p, %d)\n", abfd, objtype);
 #endif
 
   _bfd_vms_output_begin (abfd, objtype, -1);
-  _bfd_vms_output_long (abfd, (unsigned long) (PRIV(vms_linkage_index) >> 1));
-  _bfd_vms_output_byte (abfd, 0);      /* completion code */
-  _bfd_vms_output_byte (abfd, 0);      /* fill byte */
+  _bfd_vms_output_long (abfd, (unsigned long) (PRIV (vms_linkage_index) >> 1));
+  _bfd_vms_output_byte (abfd, 0);      /* Completion code.  */
+  _bfd_vms_output_byte (abfd, 0);      /* Fill byte.  */
 
   if (bfd_get_start_address (abfd) != (bfd_vma)-1)
     {
 
   if (bfd_get_start_address (abfd) != (bfd_vma)-1)
     {
This page took 0.030256 seconds and 4 git commands to generate.