diff options
author | Alan Modra <amodra@gmail.com> | 2002-11-12 23:25:42 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2002-11-12 23:25:42 +0000 |
commit | a7f84125428c5d831d73cf256259155aef45121e (patch) | |
tree | 527ddb44aa17859c0acf9c0d1135346869d1d6a1 /bfd | |
parent | 0b74bc77842321bf862a0b00897ad819b8a2ba8f (diff) | |
download | gdb-a7f84125428c5d831d73cf256259155aef45121e.zip gdb-a7f84125428c5d831d73cf256259155aef45121e.tar.gz gdb-a7f84125428c5d831d73cf256259155aef45121e.tar.bz2 |
Missed commit in last change.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 2 | ||||
-rw-r--r-- | bfd/elfcore.h | 46 |
2 files changed, 14 insertions, 34 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index e8b786b..d7d10b5 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -26,7 +26,7 @@ (bfd_sym_scan): New function split out from bfd_sym_object_p. * xsym.h (bfd_sym_scan): Declare. * elfcode.h (elf_object_p): Use bfd_preserve_save/restore/finish. - (elf_core_file_p): Likewise. + * elfcore.h (elf_core_file_p): Likewise. * targets.c (_bfd_target_vector): Revert 2002-11-08 change. 2002-11-12 Nick Clifton <nickc@redhat.com> diff --git a/bfd/elfcore.h b/bfd/elfcore.h index 7db5f72..264ff55 100644 --- a/bfd/elfcore.h +++ b/bfd/elfcore.h @@ -85,18 +85,18 @@ elf_core_file_p (abfd) unsigned int phindex; struct elf_backend_data *ebd; struct bfd_preserve preserve; - struct elf_obj_tdata *new_tdata = NULL; bfd_size_type amt; - preserve.arch_info = abfd->arch_info; + preserve.marker = NULL; /* Read in the ELF header in external format. */ if (bfd_bread ((PTR) &x_ehdr, (bfd_size_type) sizeof (x_ehdr), abfd) != sizeof (x_ehdr)) { if (bfd_get_error () != bfd_error_system_call) - bfd_set_error (bfd_error_wrong_format); - return NULL; + goto wrong; + else + goto fail; } /* Check the magic number. */ @@ -126,24 +126,14 @@ elf_core_file_p (abfd) /* Give abfd an elf_obj_tdata. */ amt = sizeof (struct elf_obj_tdata); - new_tdata = (struct elf_obj_tdata *) bfd_zalloc (abfd, amt); - if (new_tdata == NULL) - return NULL; - preserve.tdata = elf_tdata (abfd); - elf_tdata (abfd) = new_tdata; - - /* Clear section information, since there might be a recognized bfd that - we now check if we can replace, and we don't want to append to it. */ - preserve.sections = abfd->sections; - preserve.section_tail = abfd->section_tail; - preserve.section_count = abfd->section_count; - preserve.section_htab = abfd->section_htab; - abfd->sections = NULL; - abfd->section_tail = &abfd->sections; - abfd->section_count = 0; - if (!bfd_hash_table_init (&abfd->section_htab, bfd_section_hash_newfunc)) + preserve.marker = bfd_zalloc (abfd, amt); + if (preserve.marker == NULL) + goto fail; + if (!bfd_preserve_save (abfd, &preserve)) goto fail; + elf_tdata (abfd) = preserve.marker; + /* Swap in the rest of the header, now that we have the byte order. */ i_ehdrp = elf_elfheader (abfd); elf_swap_ehdr_in (abfd, &x_ehdr, i_ehdrp); @@ -248,7 +238,7 @@ elf_core_file_p (abfd) goto wrong; } - bfd_hash_table_free (&preserve.section_htab); + bfd_preserve_finish (abfd, &preserve); return abfd->xvec; wrong: @@ -264,17 +254,7 @@ wrong: bfd_set_error (bfd_error_wrong_format); fail: - abfd->arch_info = preserve.arch_info; - if (new_tdata != NULL) - { - /* bfd_release frees all memory more recently bfd_alloc'd than - its arg, as well as its arg. */ - bfd_release (abfd, new_tdata); - elf_tdata (abfd) = preserve.tdata; - abfd->section_htab = preserve.section_htab; - abfd->sections = preserve.sections; - abfd->section_tail = preserve.section_tail; - abfd->section_count = preserve.section_count; - } + if (preserve.marker != NULL) + bfd_preserve_restore (abfd, &preserve); return NULL; } |