Automatic date update in version.in
[deliverable/binutils-gdb.git] / bfd / xcofflink.c
index 7078f253efc069e8acb2058c88ec0346df36e35e..2560d2ca427ae5051868fb554b3b64502dd5c575 100644 (file)
@@ -214,7 +214,7 @@ xcoff_get_section_contents (bfd *abfd, asection *sec)
 {
   if (coff_section_data (abfd, sec) == NULL)
     {
-      bfd_size_type amt = sizeof (struct coff_section_tdata);
+      size_t amt = sizeof (struct coff_section_tdata);
 
       sec->used_by_bfd = bfd_zalloc (abfd, amt);
       if (sec->used_by_bfd == NULL)
@@ -593,7 +593,7 @@ struct bfd_link_hash_table *
 _bfd_xcoff_bfd_link_hash_table_create (bfd *abfd)
 {
   struct xcoff_link_hash_table *ret;
-  bfd_size_type amt = sizeof (* ret);
+  size_t amt = sizeof (* ret);
 
   ret = bfd_zmalloc (amt);
   if (ret == NULL)
@@ -764,7 +764,7 @@ xcoff_set_import_path (struct bfd_link_info *info,
       if (*pp == NULL)
        {
          struct xcoff_import_file *n;
-         bfd_size_type amt = sizeof (* n);
+         size_t amt = sizeof (*n);
 
          n = bfd_alloc (info->output_bfd, amt);
          if (n == NULL)
@@ -1317,14 +1317,17 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
        {
          bfd_byte *linenos;
 
-         amt = linesz * o->lineno_count;
-         linenos = bfd_malloc (amt);
+         if (bfd_seek (abfd, o->line_filepos, SEEK_SET) != 0)
+           goto error_return;
+         if (_bfd_mul_overflow (linesz, o->lineno_count, &amt))
+           {
+             bfd_set_error (bfd_error_file_too_big);
+             goto error_return;
+           }
+         linenos = _bfd_malloc_and_read (abfd, amt, amt);
          if (linenos == NULL)
            goto error_return;
          reloc_info[o->target_index].linenos = linenos;
-         if (bfd_seek (abfd, o->line_filepos, SEEK_SET) != 0
-             || bfd_bread (linenos, amt, abfd) != amt)
-           goto error_return;
        }
     }
 
@@ -2520,7 +2523,7 @@ xcoff_find_function (struct bfd_link_info *info,
     {
       char *fnname;
       struct xcoff_link_hash_entry *hfn;
-      bfd_size_type amt;
+      size_t amt;
 
       amt = strlen (h->root.root.string) + 2;
       fnname = bfd_malloc (amt);
@@ -3044,7 +3047,7 @@ bfd_xcoff_link_record_set (bfd *output_bfd,
 {
   struct xcoff_link_hash_entry *h = (struct xcoff_link_hash_entry *) harg;
   struct xcoff_link_size_list *n;
-  bfd_size_type amt;
+  size_t amt;
 
   if (bfd_get_flavour (output_bfd) != bfd_target_xcoff_flavour)
     return TRUE;
@@ -3292,7 +3295,7 @@ static bfd_boolean
 xcoff_build_ldsym (struct xcoff_loader_info *ldinfo,
                   struct xcoff_link_hash_entry *h)
 {
-  bfd_size_type amt;
+  size_t amt;
 
   /* Warn if this symbol is exported but not defined.  */
   if ((h->flags & XCOFF_EXPORT) != 0
@@ -3640,7 +3643,7 @@ bfd_xcoff_size_dynamic_sections (bfd *output_bfd,
   bfd *sub;
   struct bfd_strtab_hash *debug_strtab;
   bfd_byte *debug_contents = NULL;
-  bfd_size_type amt;
+  size_t amt;
 
   if (bfd_get_flavour (output_bfd) != bfd_target_xcoff_flavour)
     {
@@ -4782,7 +4785,7 @@ xcoff_link_input_bfd (struct xcoff_final_link_info *flinfo,
        {
          bfd_size_type sz = o->rawsize ? o->rawsize : o->size;
          if (!bfd_get_section_contents (input_bfd, o, flinfo->contents, 0, sz))
-           return FALSE;
+           goto err_out;
          contents = flinfo->contents;
        }
 
@@ -4804,7 +4807,7 @@ xcoff_link_input_bfd (struct xcoff_final_link_info *flinfo,
                              (flinfo->section_info[target_index].relocs
                               + o->output_section->reloc_count)));
          if (internal_relocs == NULL)
-           return FALSE;
+           goto err_out;
 
          /* Call processor specific code to relocate the section
             contents.  */
@@ -4814,7 +4817,7 @@ xcoff_link_input_bfd (struct xcoff_final_link_info *flinfo,
                                           internal_relocs,
                                           flinfo->internal_syms,
                                           xcoff_data (input_bfd)->csects))
-           return FALSE;
+           goto err_out;
 
          offset = o->output_section->vma + o->output_offset - o->vma;
          irel = internal_relocs;
@@ -4861,12 +4864,12 @@ xcoff_link_input_bfd (struct xcoff_final_link_info *flinfo,
                        {
                          struct xcoff_toc_rel_hash *n;
                          struct xcoff_link_section_info *si;
-                         bfd_size_type amt;
+                         size_t amt;
 
                          amt = sizeof (* n);
                          n = bfd_alloc (flinfo->output_bfd, amt);
                          if (n == NULL)
-                           return FALSE;
+                           goto err_out;
                          si = flinfo->section_info + target_index;
                          n->next = si->toc_rel_hashes;
                          n->h = h;
@@ -4948,7 +4951,7 @@ xcoff_link_input_bfd (struct xcoff_final_link_info *flinfo,
                                      (input_bfd, is, buf));
 
                              if (name == NULL)
-                               return FALSE;
+                               goto err_out;
 
                              (*flinfo->info->callbacks->unattached_reloc)
                                (flinfo->info, name,
@@ -4972,7 +4975,7 @@ xcoff_link_input_bfd (struct xcoff_final_link_info *flinfo,
                  if (!xcoff_create_ldrel (output_bfd, flinfo,
                                           o->output_section, input_bfd,
                                           irel, sec, h))
-                   return FALSE;
+                   goto err_out;
                }
            }
 
@@ -4983,7 +4986,7 @@ xcoff_link_input_bfd (struct xcoff_final_link_info *flinfo,
       if (! bfd_set_section_contents (output_bfd, o->output_section,
                                      contents, (file_ptr) o->output_offset,
                                      o->size))
-       return FALSE;
+       goto err_out;
     }
 
   obj_coff_keep_syms (input_bfd) = keep_syms;
@@ -4995,6 +4998,10 @@ xcoff_link_input_bfd (struct xcoff_final_link_info *flinfo,
     }
 
   return TRUE;
+
+ err_out:
+  obj_coff_keep_syms (input_bfd) = keep_syms;
+  return FALSE;
 }
 
 #undef N_TMASK
This page took 0.028418 seconds and 4 git commands to generate.