Ignore:
Timestamp:
Aug 16, 2003, 6:59:22 PM (22 years ago)
Author:
bird
Message:

binutils v2.14 - offical sources.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/binutils/bfd/cisco-core.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* BFD back-end for CISCO crash dumps.
    2 
    3 Copyright 1994, 1997, 1999, 2000 Free Software Foundation, Inc.
     2   Copyright 1994, 1997, 1999, 2000, 2001, 2002
     3 Free Software Foundation, Inc.
    44
    55This file is part of BFD, the Binary File Descriptor library.
     
    6868} crashinfo_external;
    6969
    70 
    7170struct cisco_core_struct
    7271{
    7372  int sig;
    7473};
     74
     75
     76
     77
     78
     79
    7580
    7681
     
    9297  sec_ptr asect;
    9398  struct stat statbuf;
    94 
    95   if (bfd_seek (abfd, crash_info_loc, SEEK_SET) != 0)
     99  bfd_size_type amt;
     100
     101  if (bfd_seek (abfd, (file_ptr) crash_info_loc, SEEK_SET) != 0)
    96102    return NULL;
    97103
    98   nread = bfd_read (buf, 1, 4, abfd);
     104  nread = bfd_ 4, abfd);
    99105  if (nread != 4)
    100106    {
     
    105111  crashinfo_offset = MASK_ADDR (bfd_get_32 (abfd, buf));
    106112
    107   if (bfd_seek (abfd, crashinfo_offset, SEEK_SET) != 0)
     113  if (bfd_seek (abfd, crashinfo_offset, SEEK_SET) != 0)
    108114    {
    109115      /* Most likely we failed because of a bogus (huge) offset */
     
    112118    }
    113119
    114   nread = bfd_read (&crashinfo, 1, sizeof (crashinfo), abfd);
     120  nread = bfd_ sizeof (crashinfo), abfd);
    115121  if (nread != sizeof (crashinfo))
    116122    {
     
    151157  /* OK, we believe you.  You're a core file.  */
    152158
    153   abfd->tdata.cisco_core_data =
    154     ((struct cisco_core_struct *)
    155      bfd_zmalloc (sizeof (struct cisco_core_struct)));
     159  amt = sizeof (struct cisco_core_struct);
     160  abfd->tdata.cisco_core_data = (struct cisco_core_struct *) bfd_zmalloc (amt);
    156161  if (abfd->tdata.cisco_core_data == NULL)
    157162    return NULL;
     
    236241    }
    237242
    238   abfd->sections = NULL;
    239   abfd->section_count = 0;
     243  /* Create a ".data" section that maps the entire file, which is
     244     essentially a dump of the target system's RAM.  */
     245
     246  asect = bfd_make_section_anyway (abfd, ".data");
     247  if (asect == NULL)
     248    goto error_return;
     249  asect->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
     250  /* The size of memory is the size of the core file itself.  */
     251  asect->_raw_size = statbuf.st_size;
     252  asect->vma = rambase;
     253  asect->filepos = 0;
     254
     255  /* Create a ".crash" section to allow access to the saved
     256     crash information.  */
     257
     258  asect = bfd_make_section_anyway (abfd, ".crash");
     259  if (asect == NULL)
     260    goto error_return;
     261  asect->flags = SEC_HAS_CONTENTS;
     262  asect->vma = 0;
     263  asect->filepos = crashinfo_offset;
     264  asect->_raw_size = sizeof (crashinfo);
    240265
    241266  /* Create a ".reg" section to allow access to the saved
    242267     registers.  */
    243268
    244   asect = (asection *) bfd_zmalloc (sizeof (asection));
     269  asect = );
    245270  if (asect == NULL)
    246271    goto error_return;
    247   asect->name = ".reg";
    248272  asect->flags = SEC_HAS_CONTENTS;
    249273  asect->vma = 0;
     
    254278  nread = statbuf.st_size - asect->filepos;
    255279  asect->_raw_size = (nread < 1024) ? nread : 1024;
    256   asect->next = abfd->sections;
    257   abfd->sections = asect;
    258   ++abfd->section_count;
    259 
    260   /* Create a ".crash" section to allow access to the saved
    261      crash information.  */
    262 
    263   asect = (asection *) bfd_zmalloc (sizeof (asection));
    264   if (asect == NULL)
    265     goto error_return;
    266   asect->name = ".crash";
    267   asect->flags = SEC_HAS_CONTENTS;
    268   asect->vma = 0;
    269   asect->filepos = crashinfo_offset;
    270   asect->_raw_size = sizeof (crashinfo);
    271   asect->next = abfd->sections;
    272   abfd->sections = asect;
    273   ++abfd->section_count;
    274 
    275   /* Create a ".data" section that maps the entire file, which is
    276      essentially a dump of the target system's RAM.  */
    277 
    278   asect = (asection *) bfd_zmalloc (sizeof (asection));
    279   if (asect == NULL)
    280     goto error_return;
    281   asect->name = ".data";
    282   asect->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
    283   /* The size of memory is the size of the core file itself.  */
    284   asect->_raw_size = statbuf.st_size;
    285   asect->vma = rambase;
    286   asect->filepos = 0;
    287   asect->next = abfd->sections;
    288   abfd->sections = asect;
    289   ++abfd->section_count;
    290280
    291281  return abfd->xvec;
     
    295285
    296286 error_return:
    297   {
    298     sec_ptr nextsect;
    299     for (asect = abfd->sections; asect != NULL;)
    300       {
    301         nextsect = asect->next;
    302         free (asect);
    303         asect = nextsect;
    304       }
    305     free (abfd->tdata.cisco_core_data);
    306     return NULL;
    307   }
     287  bfd_release (abfd, abfd->tdata.any);
     288  abfd->tdata.any = NULL;
     289  bfd_section_list_clear (abfd);
     290  return NULL;
    308291}
    309292
     
    326309char *
    327310cisco_core_file_failing_command (abfd)
    328      bfd *abfd;
     311     bfd *abfd;
    329312{
    330313  return NULL;
     
    333316int
    334317cisco_core_file_failing_signal (abfd)
    335      bfd *abfd;
     318     bfd *abfd;
    336319{
    337320  return abfd->tdata.cisco_core_data->sig;
    338321}
    339322
    340 boolean
     323boolean
    341324cisco_core_file_matches_executable_p (core_bfd, exec_bfd)
    342      bfd *core_bfd;
    343      bfd *exec_bfd;
    344 {
    345   return true;
     325     bfd *core_bfd;
     326     bfd *exec_bfd;
     327{
     328  return ;
    346329}
    347330
Note: See TracChangeset for help on using the changeset viewer.