]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
ECOFF slurp_relocs thinko
authorAlan Modra <amodra@gmail.com>
Mon, 18 May 2020 11:14:30 +0000 (20:44 +0930)
committerAlan Modra <amodra@gmail.com>
Mon, 18 May 2020 11:26:39 +0000 (20:56 +0930)
In git commit 806470a219 I swapped the order of internal vs. external
relocs memory allocation in ecoff_slurp_reloc_table, the idea being
that the external reloc size can be sanity checked against file size.
However, that fails badly with bfd_alloc memory where releasing any
block also releases all more recently allocated blocks.

* ecoff.c (ecoff_slurp_reloc_table): Malloc external_relocs so
they can be freed without also freeing internal_relocs.

bfd/ChangeLog
bfd/ecoff.c

index b3cefd94881421b5bd256c88faedd68ecf81f973..0e5dec08d6afce8a878c5ffe2720a1fa7d9f08f4 100644 (file)
@@ -1,3 +1,8 @@
+2020-05-18  Alan Modra  <amodra@gmail.com>
+
+       * ecoff.c (ecoff_slurp_reloc_table): Malloc external_relocs so
+       they can be freed without also freeing internal_relocs.
+
 2020-05-18  Jaydeep Chauhan  <jaydeepchauhan1494@gmail.com>
 
        PR 25713
index 50a133b7bac30d0ecdfa48e3390cff61c62b8bde..82267a889df6ee880cbf0231e90609074abaeab3 100644 (file)
@@ -1626,7 +1626,7 @@ ecoff_slurp_reloc_table (bfd *abfd,
   amt = external_reloc_size * section->reloc_count;
   if (bfd_seek (abfd, section->rel_filepos, SEEK_SET) != 0)
     return FALSE;
-  external_relocs = _bfd_alloc_and_read (abfd, amt, amt);
+  external_relocs = _bfd_malloc_and_read (abfd, amt, amt);
   if (external_relocs == NULL)
     return FALSE;
 
@@ -1635,7 +1635,7 @@ ecoff_slurp_reloc_table (bfd *abfd,
   internal_relocs = (arelent *) bfd_alloc (abfd, amt);
   if (internal_relocs == NULL)
     {
-      bfd_release (abfd, external_relocs);
+      free (external_relocs);
       return FALSE;
     }
 
@@ -1703,7 +1703,7 @@ ecoff_slurp_reloc_table (bfd *abfd,
       (*backend->adjust_reloc_in) (abfd, &intern, rptr);
     }
 
-  bfd_release (abfd, external_relocs);
+  free (external_relocs);
 
   section->relocation = internal_relocs;