X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=bfd%2Felf64-sparc.c;h=8d352252b63aba8278f8764f5e4d746e1edf5b5e;hb=d4d8aee345704f7c39ebe9910cc08386708637b1;hp=55a1db911e9aa4072b2a8421e72621ce02738722;hpb=242a115951fe55e62036bac555017eb817ca1aa6;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/elf64-sparc.c b/bfd/elf64-sparc.c index 55a1db911e..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; @@ -116,17 +114,17 @@ elf64_sparc_slurp_one_reloc_table (bfd *abfd, asection *asect, if (ELF64_R_SYM (rela.r_info) == STN_UNDEF) relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; else if (/* PR 17512: file: 996185f8. */ - (!dynamic && ELF64_R_SYM(rela.r_info) > bfd_get_symcount(abfd)) - || (dynamic - && ELF64_R_SYM(rela.r_info) > bfd_get_dynamic_symcount(abfd))) - { - _bfd_error_handler + ELF64_R_SYM (rela.r_info) > (dynamic + ? bfd_get_dynamic_symcount (abfd) + : bfd_get_symcount (abfd))) + { + _bfd_error_handler /* xgettext:c-format */ (_("%pB(%pA): relocation %d has invalid symbol index %ld"), abfd, asect, i, (long) ELF64_R_SYM (rela.r_info)); bfd_set_error (bfd_error_bad_value); relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; - } + } else { asymbol **ps, *s; @@ -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; } @@ -748,7 +743,7 @@ elf64_sparc_fake_sections (bfd *abfd ATTRIBUTE_UNUSED, { const char *name; - name = bfd_get_section_name (abfd, sec); + name = bfd_section_name (sec); if (strcmp (name, ".stab") == 0) {