bfd/
[deliverable/binutils-gdb.git] / bfd / vms-gsd.c
index 2ee015fff064c6697dddd2e05717915dc6428a7c..5a107e18c7cb9aec6ff3c141613b27c7f0a1ad58 100644 (file)
@@ -1,6 +1,7 @@
 /* vms-gsd.c -- BFD back-end for VAX (openVMS/VAX) and
    EVAX (openVMS/Alpha) files.
-   Copyright 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004
+   Free Software Foundation, Inc.
 
    go and read the openVMS linker manual (esp. appendix B)
    if you don't know what's going on here :-)
@@ -21,8 +22,6 @@ 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.  */
 
-#include <ctype.h>
-
 #include "bfd.h"
 #include "sysdep.h"
 #include "bfdlink.h"
@@ -359,9 +358,9 @@ _bfd_vms_slurp_gsd (abfd, objtype)
                  return -1;
                }
              old_flags = bfd_getl16 (vms_rec + 2);
-             section->_raw_size = bfd_getl32 (vms_rec + 4);  /* allocation */
+             section->size = bfd_getl32 (vms_rec + 4);  /* allocation */
              new_flags = vms_secflag_by_name (abfd, vax_section_flags, name,
-                                              section->_raw_size > 0);
+                                              section->size > 0);
              if (old_flags & EGPS_S_V_REL)
                new_flags |= SEC_RELOC;
              if (old_flags & GPS_S_M_OVR)
@@ -378,7 +377,7 @@ _bfd_vms_slurp_gsd (abfd, objtype)
              if ((base_addr % align_addr) != 0)
                base_addr += (align_addr - (base_addr % align_addr));
              section->vma = (bfd_vma)base_addr;
-             base_addr += section->_raw_size;
+             base_addr += section->size;
 
              /* global section is common symbol  */
 
@@ -402,45 +401,43 @@ _bfd_vms_slurp_gsd (abfd, objtype)
              if (old_section != 0)
                {
                  section->contents = old_section->contents;
-                 if (section->_raw_size < old_section->_raw_size)
+                 if (section->size < old_section->size)
                    {
                      (*_bfd_error_handler)
                        (_("Size mismatch section %s=%lx, %s=%lx"),
                         old_section->name,
-                        (unsigned long) old_section->_raw_size,
+                        (unsigned long) old_section->size,
                         section->name,
-                        (unsigned long) section->_raw_size);
+                        (unsigned long) section->size);
                      return -1;
                    }
-                 else if (section->_raw_size > old_section->_raw_size)
+                 else if (section->size > old_section->size)
                    {
                      section->contents = ((unsigned char *)
                                           bfd_realloc (old_section->contents,
-                                                       section->_raw_size));
+                                                       section->size));
                      if (section->contents == NULL)
                        {
                          bfd_set_error (bfd_error_no_memory);
                          return -1;
-                       }
+                       }
                    }
                }
              else
                {
                  section->contents = ((unsigned char *)
-                                      bfd_malloc (section->_raw_size));
+                                      bfd_zmalloc (section->size));
                  if (section->contents == NULL)
                    {
                      bfd_set_error (bfd_error_no_memory);
                      return -1;
                    }
-                 memset (section->contents, 0, (size_t) section->_raw_size);
                }
-             section->_cooked_size = section->_raw_size;
 #if VMS_DEBUG
              vms_debug (4, "gsd psc %d (%s, flags %04x=%s) ",
                         section->index, name, old_flags, flag2str (gpsflagdesc, old_flags));
              vms_debug (4, "%d bytes at 0x%08lx (mem %p)\n",
-                        section->_raw_size, section->vma, section->contents);
+                        section->size, section->vma, section->contents);
 #endif
 
              gsd_size = vms_rec[8] + 9;
@@ -605,9 +602,9 @@ _bfd_vms_slurp_gsd (abfd, objtype)
            if (!section)
              return -1;
            old_flags = bfd_getl16 (vms_rec + 6);
-           section->_raw_size = bfd_getl32 (vms_rec + 8);      /* allocation */
+           section->size = bfd_getl32 (vms_rec + 8);   /* allocation */
            new_flags = vms_secflag_by_name (abfd, evax_section_flags, name,
-                                            section->_raw_size > 0);
+                                            section->size > 0);
            if (old_flags & EGPS_S_V_REL)
              new_flags |= SEC_RELOC;
            if (!bfd_set_section_flags (abfd, section, new_flags))
@@ -617,18 +614,16 @@ _bfd_vms_slurp_gsd (abfd, objtype)
            if ((base_addr % align_addr) != 0)
              base_addr += (align_addr - (base_addr % align_addr));
            section->vma = (bfd_vma)base_addr;
-           base_addr += section->_raw_size;
+           base_addr += section->size;
            section->contents = ((unsigned char *)
-                                bfd_malloc (section->_raw_size));
+                                bfd_zmalloc (section->size));
            if (section->contents == NULL)
              return -1;
-           memset (section->contents, 0, (size_t) section->_raw_size);
-           section->_cooked_size = section->_raw_size;
 #if VMS_DEBUG
            vms_debug(4, "egsd psc %d (%s, flags %04x=%s) ",
                       section->index, name, old_flags, flag2str(gpsflagdesc, old_flags));
            vms_debug(4, "%d bytes at 0x%08lx (mem %p)\n",
-                      section->_raw_size, section->vma, section->contents);
+                      section->size, section->vma, section->contents);
 #endif
          }
          break;
@@ -637,7 +632,7 @@ _bfd_vms_slurp_gsd (abfd, objtype)
          {
            /* symbol specification (definition or reference)  */
 
-           symbol = _bfd_vms_make_empty_symbol (abfd);
+           symbol = bfd_make_empty_symbol (abfd);
            if (symbol == 0)
              return -1;
 
@@ -664,20 +659,22 @@ _bfd_vms_slurp_gsd (abfd, objtype)
              }
            else        /* symbol reference */
              {
-               symbol->name =
+               symbol->name =
                  _bfd_vms_save_counted_string (vms_rec+8);
 #if VMS_DEBUG
                vms_debug(4, "egsd sym ref #%d (%s, %04x=%s)\n", abfd->symcount,
                           symbol->name, old_flags, flag2str(gsyflagdesc, old_flags));
 #endif
-               symbol->section = bfd_make_section (abfd, BFD_UND_SECTION_NAME);
+               symbol->section = bfd_make_section (abfd, BFD_UND_SECTION_NAME);
              }
 
            symbol->flags = new_flags;
 
            /* save symbol in vms_symbol_table  */
 
-           entry = (vms_symbol_entry *) bfd_hash_lookup (PRIV(vms_symbol_table), symbol->name, true, false);
+           entry = (vms_symbol_entry *) bfd_hash_lookup (PRIV(vms_symbol_table),
+                                                         symbol->name,
+                                                         TRUE, FALSE);
            if (entry == (vms_symbol_entry *)NULL)
              {
                bfd_set_error (bfd_error_no_memory);
@@ -759,7 +756,7 @@ _bfd_vms_write_gsd (abfd, objtype)
   while (section != 0)
     {
 #if VMS_DEBUG
-  vms_debug (3, "Section #%d %s, %d bytes\n", section->index, section->name, (int)section->_raw_size);
+  vms_debug (3, "Section #%d %s, %d bytes\n", section->index, section->name, (int)section->size);
 #endif
 
        /* 13 bytes egsd, max 31 chars name -> should be 44 bytes */
@@ -789,7 +786,7 @@ _bfd_vms_write_gsd (abfd, objtype)
          last_index++;
        }
 
-      /* Don't know if this is neccesary for the linker but for now it keeps
+      /* Don't know if this is necessary for the linker but for now it keeps
         vms_slurp_gsd happy  */
 
       sname = (char *)section->name;
@@ -825,10 +822,10 @@ _bfd_vms_write_gsd (abfd, objtype)
       else
        {
          new_flags = vms_esecflag_by_name (evax_section_flags, sname,
-                                           section->_raw_size > 0);
+                                           section->size > 0);
        }
       _bfd_vms_output_short (abfd, new_flags);
-      _bfd_vms_output_long (abfd, (unsigned long) section->_raw_size);
+      _bfd_vms_output_long (abfd, (unsigned long) section->size);
       _bfd_vms_output_counted (abfd, sname);
       _bfd_vms_output_flush (abfd);
 
@@ -904,7 +901,7 @@ _bfd_vms_write_gsd (abfd, objtype)
          unsigned long ca_psindx = 0;
          unsigned long psindx;
 
-         if (old_flags & BSF_FUNCTION)
+         if ((old_flags & BSF_FUNCTION) && symbol->udata.p != NULL)
            {
              code_address = ((asymbol *) (symbol->udata.p))->value;
              ca_psindx = ((asymbol *) (symbol->udata.p))->section->index;
This page took 0.028741 seconds and 4 git commands to generate.