diff options
author | Alan Modra <amodra@gmail.com> | 2002-01-05 13:11:33 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2002-01-05 13:11:33 +0000 |
commit | 9e7b37b31f29ad3b8321d15e589ed5de550c56d3 (patch) | |
tree | 45c0765ba86e10dfd9d2ad45edc64de1be7a3a31 /bfd/cisco-core.c | |
parent | * elf32-mips.c (_bfd_mips_elf_lo16_reloc): Simplify, and perform (diff) | |
download | binutils-gdb-9e7b37b31f29ad3b8321d15e589ed5de550c56d3.tar.gz binutils-gdb-9e7b37b31f29ad3b8321d15e589ed5de550c56d3.tar.bz2 binutils-gdb-9e7b37b31f29ad3b8321d15e589ed5de550c56d3.zip |
* section.c (bfd_section_init): Remove unnecessary initialisations.
(bfd_section_list_clear): New function.
(bfd_section_list_remove, bfd_section_list_insert): New macros.
(_bfd_strip_section_from_output): Use them.
* coffcode.h (coff_set_alignment_hook): Likewise.
* elf32-mips.c (_bfd_mips_elf_final_link): Likewise.
* elf64-mips.c (mips_elf64_final_link): Likewise.
* elf64-mmix.c (mmix_elf_final_link): Likewise.
* sunos.c (sunos_add_dynamic_symbols): Likewise.
* xcofflink.c (_bfd_xcoff_bfd_final_link): Likewise.
* bfd-in2.h: Regenerate.
* netbsd-core.c (netbsd_core_file_p): Use bfd_make_section_anyway
rather than doing our own section handling. Clean up after errors
with bfd_release and bfd_section_list_clear. Handle unexpected
flags.
* aoutf1.h (sunos4_core_file_p): Likewise.
* aix386-core.c (aix386_core_file_p): Likewise.
* cisco-core.c (cisco_core_file_validate): Likewise.
* ptrace-core.c (ptrace_unix_core_file_p): Likewise.
* trad-core.c (trad_unix_core_file_p): Likewise.
* hppabsd-core.c (hppabsd_core_core_file_p): Clean up after errors
with bfd_release and bfd_section_list_clear.
* hpux-core.c (hpux_core_core_file_p): Likewise.
* irix-core.c (irix_core_core_file_p): Likewise.
* lynx-core.c (lynx_core_file_p): Likewise.
* osf-core.c (osf_core_core_file_p): Likewise.
* rs6000-core.c (rs6000coff_core_p): Likewise.
* sco5-core.c (sco5_core_file_p): Likewise.
Diffstat (limited to 'bfd/cisco-core.c')
-rw-r--r-- | bfd/cisco-core.c | 73 |
1 files changed, 26 insertions, 47 deletions
diff --git a/bfd/cisco-core.c b/bfd/cisco-core.c index f9878a2cf0a..db87466ff31 100644 --- a/bfd/cisco-core.c +++ b/bfd/cisco-core.c @@ -1,5 +1,6 @@ /* BFD back-end for CISCO crash dumps. - Copyright 1994, 1997, 1999, 2000, 2001 Free Software Foundation, Inc. + Copyright 1994, 1997, 1999, 2000, 2001, 2002 + Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -237,58 +238,43 @@ cisco_core_file_validate (abfd, crash_info_loc) break; } - abfd->sections = NULL; - abfd->section_count = 0; - - /* Create a ".reg" section to allow access to the saved - registers. */ + /* Create a ".data" section that maps the entire file, which is + essentially a dump of the target system's RAM. */ - asect = (asection *) bfd_zmalloc ((bfd_size_type) sizeof (asection)); + asect = bfd_make_section_anyway (abfd, ".data"); if (asect == NULL) goto error_return; - asect->name = ".reg"; - asect->flags = SEC_HAS_CONTENTS; - asect->vma = 0; - asect->filepos = bfd_get_32 (abfd, crashinfo.registers) - rambase; - /* Since we don't know the exact size of the saved register info, - choose a register section size that is either the remaining part - of the file, or 1024, whichever is smaller. */ - nread = statbuf.st_size - asect->filepos; - asect->_raw_size = (nread < 1024) ? nread : 1024; - asect->next = abfd->sections; - abfd->sections = asect; - ++abfd->section_count; + asect->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS; + /* The size of memory is the size of the core file itself. */ + asect->_raw_size = statbuf.st_size; + asect->vma = rambase; + asect->filepos = 0; /* Create a ".crash" section to allow access to the saved crash information. */ - asect = (asection *) bfd_zmalloc ((bfd_size_type) sizeof (asection)); + asect = bfd_make_section_anyway (abfd, ".crash"); if (asect == NULL) goto error_return; - asect->name = ".crash"; asect->flags = SEC_HAS_CONTENTS; asect->vma = 0; asect->filepos = crashinfo_offset; asect->_raw_size = sizeof (crashinfo); - asect->next = abfd->sections; - abfd->sections = asect; - ++abfd->section_count; - /* Create a ".data" section that maps the entire file, which is - essentially a dump of the target system's RAM. */ + /* Create a ".reg" section to allow access to the saved + registers. */ - asect = (asection *) bfd_zmalloc ((bfd_size_type) sizeof (asection)); + asect = bfd_make_section_anyway (abfd, ".reg"); if (asect == NULL) goto error_return; - asect->name = ".data"; - asect->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS; - /* The size of memory is the size of the core file itself. */ - asect->_raw_size = statbuf.st_size; - asect->vma = rambase; - asect->filepos = 0; - asect->next = abfd->sections; - abfd->sections = asect; - ++abfd->section_count; + asect->flags = SEC_HAS_CONTENTS; + asect->vma = 0; + asect->filepos = bfd_get_32 (abfd, crashinfo.registers) - rambase; + /* Since we don't know the exact size of the saved register info, + choose a register section size that is either the remaining part + of the file, or 1024, whichever is smaller. */ + nread = statbuf.st_size - asect->filepos; + asect->_raw_size = (nread < 1024) ? nread : 1024; return abfd->xvec; @@ -296,17 +282,10 @@ cisco_core_file_validate (abfd, crash_info_loc) and there is an error of some kind. */ error_return: - { - sec_ptr nextsect; - for (asect = abfd->sections; asect != NULL;) - { - nextsect = asect->next; - free (asect); - asect = nextsect; - } - free (abfd->tdata.cisco_core_data); - return NULL; - } + bfd_release (abfd, abfd->tdata.any); + abfd->tdata.any = NULL; + bfd_section_list_clear (abfd); + return NULL; } static const bfd_target * |