X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Felf64-sparc.c;h=8d352252b63aba8278f8764f5e4d746e1edf5b5e;hb=2d0a923cc653b76a531651c9f4b026a0ae366858;hp=8bf9623bd9fca6e240db79135353c19a2391fbb8;hpb=fd3619828e94a24a92cddec42cbc0ab33352eeb4;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/elf64-sparc.c b/bfd/elf64-sparc.c index 8bf9623bd9..8d352252b6 100644 --- a/bfd/elf64-sparc.c +++ b/bfd/elf64-sparc.c @@ -1,5 +1,5 @@ /* SPARC-specific support for 64-bit ELF - Copyright (C) 1993-2019 Free Software Foundation, Inc. + Copyright (C) 1993-2020 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -79,13 +79,11 @@ elf64_sparc_slurp_one_reloc_table (bfd *abfd, asection *asect, bfd_size_type count; arelent *relents; - allocated = bfd_malloc (rel_hdr->sh_size); + if (bfd_seek (abfd, rel_hdr->sh_offset, SEEK_SET) != 0) + return FALSE; + allocated = _bfd_malloc_and_read (abfd, rel_hdr->sh_size, rel_hdr->sh_size); if (allocated == NULL) - goto error_return; - - if (bfd_seek (abfd, rel_hdr->sh_offset, SEEK_SET) != 0 - || bfd_bread (allocated, rel_hdr->sh_size, abfd) != rel_hdr->sh_size) - goto error_return; + return FALSE; native_relocs = (bfd_byte *) allocated; @@ -163,14 +161,11 @@ elf64_sparc_slurp_one_reloc_table (bfd *abfd, asection *asect, canon_reloc_count (asect) += relent - relents; - if (allocated != NULL) - free (allocated); - + free (allocated); return TRUE; error_return: - if (allocated != NULL) - free (allocated); + free (allocated); return FALSE; }