trad_unix_core_file_p: Return bfd_cleanup
[deliverable/binutils-gdb.git] / bfd / wasm-module.c
index e62f842e12c07f7f6f6cfa96f884b02d746a6cc5..ac78692816e9c9a1c05f3d14ea511437e0b78a79 100644 (file)
@@ -245,6 +245,7 @@ wasm_scan_name_function_section (bfd *abfd, sec_ptr asect)
   tdata_type *tdata = abfd->tdata.any;
   asymbol *symbols = NULL;
   sec_ptr space_function_index;
+  size_t amt;
 
   p = asect->contents;
   end = asect->contents + asect->size;
@@ -301,7 +302,12 @@ wasm_scan_name_function_section (bfd *abfd, sec_ptr asect)
   if (!space_function_index)
     return FALSE;
 
-  symbols = bfd_alloc2 (abfd, tdata->symcount, sizeof (asymbol));
+  if (_bfd_mul_overflow (tdata->symcount, sizeof (asymbol), &amt))
+    {
+      bfd_set_error (bfd_error_file_too_big);
+      return FALSE;
+    }
+  symbols = bfd_alloc (abfd, amt);
   if (!symbols)
     return FALSE;
 
@@ -446,12 +452,10 @@ wasm_scan (bfd *abfd)
 
       if (bfdsec->size != 0)
        {
-         bfdsec->contents = bfd_alloc (abfd, bfdsec->size);
+         bfdsec->contents = _bfd_alloc_and_read (abfd, bfdsec->size,
+                                                 bfdsec->size);
          if (!bfdsec->contents)
            goto error_return;
-
-         if (bfd_bread (bfdsec->contents, bfdsec->size, abfd) != bfdsec->size)
-           goto error_return;
        }
 
       vma += bfdsec->size;
@@ -688,7 +692,7 @@ wasm_canonicalize_symtab (bfd *abfd, asymbol **alocation)
 static asymbol *
 wasm_make_empty_symbol (bfd *abfd)
 {
-  bfd_size_type amt = sizeof (asymbol);
+  size_t amt = sizeof (asymbol);
   asymbol *new_symbol = (asymbol *) bfd_zalloc (abfd, amt);
 
   if (! new_symbol)
@@ -727,7 +731,7 @@ wasm_get_symbol_info (bfd *abfd ATTRIBUTE_UNUSED,
 
 /* Check whether ABFD is a WebAssembly module; if so, scan it.  */
 
-static const bfd_target *
+static bfd_cleanup
 wasm_object_p (bfd *abfd)
 {
   bfd_boolean error;
@@ -757,7 +761,7 @@ wasm_object_p (bfd *abfd)
   if (s != NULL && wasm_scan_name_function_section (abfd, s))
     abfd->flags |= HAS_SYMS;
 
-  return abfd->xvec;
+  return _bfd_no_cleanup;
 }
 
 /* BFD_JUMP_TABLE_WRITE */
This page took 0.023324 seconds and 4 git commands to generate.