Fixed exported names, removed a bad define
[deliverable/binutils-gdb.git] / bfd / coffgen.c
index cb9b2ba630cc636c2b6439b2be041f50adf7af6e..3797ec8c23abe5dfc5b12320f47a92c1fca5ec9b 100644 (file)
@@ -73,10 +73,7 @@ make_a_section_from_file (abfd, hdr, target_index)
   /* Assorted wastage to null-terminate the name, thanks AT&T! */
   name = bfd_alloc (abfd, sizeof (hdr->s_name) + 1);
   if (name == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   strncpy (name, (char *) &hdr->s_name[0], sizeof (hdr->s_name));
   name[sizeof (hdr->s_name)] = 0;
 
@@ -84,10 +81,8 @@ make_a_section_from_file (abfd, hdr, target_index)
   if (return_section == NULL)
     return false;
 
-  /* s_paddr is presumed to be = to s_vaddr */
-
   return_section->vma = hdr->s_vaddr;
-  return_section->lma = return_section->vma;
+  return_section->lma = hdr->s_paddr;
   return_section->_raw_size = hdr->s_size;
   return_section->filepos = hdr->s_scnptr;
   return_section->rel_filepos = hdr->s_relptr;
@@ -166,10 +161,7 @@ coff_real_object_p (abfd, nscns, internal_f, internal_a)
   readsize = nscns * scnhsz;
   external_sections = (char *) bfd_alloc (abfd, readsize);
   if (!external_sections)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      goto fail;
-    }
+    goto fail;
 
   if (bfd_read ((PTR) external_sections, 1, readsize, abfd) != readsize)
     goto fail;
@@ -403,12 +395,9 @@ _bfd_coff_read_internal_relocs (abfd, sec, cache, external_relocs,
 
   if (external_relocs == NULL)
     {
-      free_external = (bfd_byte *) malloc (sec->reloc_count * relsz);
+      free_external = (bfd_byte *) bfd_malloc (sec->reloc_count * relsz);
       if (free_external == NULL && sec->reloc_count > 0)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         goto error_return;
-       }
+       goto error_return;
       external_relocs = free_external;
     }
 
@@ -420,13 +409,10 @@ _bfd_coff_read_internal_relocs (abfd, sec, cache, external_relocs,
   if (internal_relocs == NULL)
     {
       free_internal = ((struct internal_reloc *)
-                      malloc (sec->reloc_count
-                              * sizeof (struct internal_reloc)));
+                      bfd_malloc (sec->reloc_count
+                                  * sizeof (struct internal_reloc)));
       if (free_internal == NULL && sec->reloc_count > 0)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         goto error_return;
-       }
+       goto error_return;
       internal_relocs = free_internal;
     }
 
@@ -451,10 +437,7 @@ _bfd_coff_read_internal_relocs (abfd, sec, cache, external_relocs,
            (PTR) bfd_zalloc (abfd,
                              sizeof (struct coff_section_tdata));
          if (sec->used_by_bfd == NULL)
-           {
-             bfd_set_error (bfd_error_no_memory);
-             goto error_return;
-           }
+           goto error_return;
          coff_section_data (abfd, sec)->contents = NULL;
        }
       coff_section_data (abfd, sec)->relocs = free_internal;
@@ -626,10 +609,7 @@ coff_renumber_symbols (bfd_ptr, first_undef)
                                                sizeof (asymbol *)
                                                * (symbol_count + 1));
     if (!newsyms)
-      {
-       bfd_set_error (bfd_error_no_memory);
-       return false;
-      }
+      return false;
     bfd_ptr->outsymbols = newsyms;
     for (i = 0; i < symbol_count; i++)
       if ((symbol_ptr_ptr[i]->flags & BSF_NOT_AT_END) != 0
@@ -913,10 +893,7 @@ coff_write_symbol (abfd, symbol, native, written, string_size_p,
   symesz = bfd_coff_symesz (abfd);
   buf = bfd_alloc (abfd, symesz);
   if (!buf)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   bfd_coff_swap_sym_out (abfd, &native->u.syment, buf);
   if (bfd_write (buf, 1, symesz, abfd) != symesz)
     return false;
@@ -930,10 +907,7 @@ coff_write_symbol (abfd, symbol, native, written, string_size_p,
       auxesz = bfd_coff_auxesz (abfd);
       buf = bfd_alloc (abfd, auxesz);
       if (!buf)
-       {
-         bfd_set_error (bfd_error_no_memory);
-         return false;
-       }
+       return false;
       for (j = 0; j < native->u.syment.n_numaux; j++)
        {
          bfd_coff_swap_aux_out (abfd,
@@ -1242,10 +1216,7 @@ coff_write_linenumbers (abfd)
   linesz = bfd_coff_linesz (abfd);
   buff = bfd_alloc (abfd, linesz);
   if (!buff)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
   for (s = abfd->sections; s != (asection *) NULL; s = s->next)
     {
       if (s->lineno_count)
@@ -1416,10 +1387,7 @@ build_debug_section (abfd)
   debug_section = (PTR) bfd_alloc (abfd,
                                   bfd_get_section_size_before_reloc (sect));
   if (debug_section == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
 
   /* Seek to the beginning of the `.debug' section and read it. 
      Save the current position first; it is needed by our caller.
@@ -1457,10 +1425,7 @@ copy_name (abfd, name, maxlen)
     }
 
   if ((newname = (PTR) bfd_alloc (abfd, len + 1)) == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return (NULL);
-    }
+    return (NULL);
   strncpy (newname, name, len);
   newname[len] = '\0';
   return newname;
@@ -1483,12 +1448,9 @@ _bfd_coff_get_external_symbols (abfd)
 
   size = obj_raw_syment_count (abfd) * symesz;
 
-  syms = (PTR) malloc (size);
+  syms = (PTR) bfd_malloc (size);
   if (syms == NULL && size != 0)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return false;
-    }
+    return false;
 
   if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0
       || bfd_read (syms, size, 1, abfd) != size)
@@ -1550,12 +1512,9 @@ _bfd_coff_read_string_table (abfd)
       return NULL;
     }
 
-  strings = (char *) malloc (strsize);
+  strings = (char *) bfd_malloc (strsize);
   if (strings == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
 
   if (bfd_read (strings + STRING_SIZE_SIZE,
                strsize - STRING_SIZE_SIZE, 1, abfd)
@@ -1617,10 +1576,7 @@ coff_get_normalized_symtab (abfd)
   size = obj_raw_syment_count (abfd) * sizeof (combined_entry_type);
   internal = (combined_entry_type *) bfd_alloc (abfd, size);
   if (internal == NULL && size != 0)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return NULL;
-    }
+    return NULL;
   internal_end = internal + obj_raw_syment_count (abfd);
 
   if (! _bfd_coff_get_external_symbols (abfd))
@@ -1726,10 +1682,7 @@ coff_get_normalized_symtab (abfd)
                }               /* possible lengths of this string. */
 
              if ((newstring = (PTR) bfd_alloc (abfd, ++i)) == NULL)
-               {
-                 bfd_set_error (bfd_error_no_memory);
-                 return (NULL);
-               }               /* on error */
+               return (NULL);
              memset (newstring, 0, i);
              strncpy (newstring, internal_ptr->u.syment._n._n_name, i - 1);
              internal_ptr->u.syment._n._n_n._n_offset = (long int) newstring;
@@ -1790,10 +1743,7 @@ coff_make_empty_symbol (abfd)
 {
   coff_symbol_type *new = (coff_symbol_type *) bfd_alloc (abfd, sizeof (coff_symbol_type));
   if (new == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return (NULL);
-    }                          /* on error */
+    return (NULL);
   memset (new, 0, sizeof *new);
   new->symbol.section = 0;
   new->native = 0;
@@ -1813,17 +1763,11 @@ coff_bfd_make_debug_symbol (abfd, ptr, sz)
 {
   coff_symbol_type *new = (coff_symbol_type *) bfd_alloc (abfd, sizeof (coff_symbol_type));
   if (new == NULL)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return (NULL);
-    }                          /* on error */
+    return (NULL);
   /* @@ This shouldn't be using a constant multiplier.  */
   new->native = (combined_entry_type *) bfd_zalloc (abfd, sizeof (combined_entry_type) * 10);
   if (!new->native)
-    {
-      bfd_set_error (bfd_error_no_memory);
-      return (NULL);
-    }                          /* on error */
+    return (NULL);
   new->symbol.section = bfd_abs_section_ptr;
   new->symbol.flags = BSF_DEBUGGING;
   new->lineno = (alent *) NULL;
@@ -2130,7 +2074,7 @@ coff_find_nearest_line (abfd, section, ignore_symbols, offset, filename_ptr,
     }
 
   /* Cache the results for the next call.  */
-  if (sec_data == NULL)
+  if (sec_data == NULL && section->owner == abfd)
     {
       section->used_by_bfd =
        ((PTR) bfd_zalloc (abfd,
This page took 0.026082 seconds and 4 git commands to generate.