Back to index

cell-binutils  2.17cvs20070401
Classes | Defines | Functions | Variables
aix386-core.c File Reference
#include "bfd.h"
#include "sysdep.h"
#include "libbfd.h"
#include "coff/i386.h"
#include "coff/internal.h"
#include "libcoff.h"
#include <signal.h>

Go to the source code of this file.

Classes

struct  trad_core_struct

Defines

#define COR_MAGIC   "core"
#define core_hdr(bfd)   (((bfd->tdata.trad_core_data))->hdr)
#define core_section(bfd, n)   (((bfd)->tdata.trad_core_data)->sections[n])
#define core_regsec(bfd)   (((bfd)->tdata.trad_core_data)->reg_section)
#define core_reg2sec(bfd)   (((bfd)->tdata.trad_core_data)->reg2_section)
#define aix386_core_file_matches_executable_p   generic_core_file_matches_executable_p
#define NO_GET   ((bfd_vma (*) (const void *)) swap_abort)
#define NO_PUT   ((void (*) (bfd_vma, void *)) swap_abort)
#define NO_GETS   ((bfd_signed_vma (*) (const void *)) swap_abort)
#define NO_GET64   ((bfd_uint64_t (*) (const void *)) swap_abort)
#define NO_PUT64   ((void (*) (bfd_uint64_t, void *)) swap_abort)
#define NO_GETS64   ((bfd_int64_t (*) (const void *)) swap_abort)

Functions

static void swap_abort PARAMS ((void))
static const bfd_targetaix386_core_file_p (bfd *abfd)
static char * aix386_core_file_failing_command (bfd *abfd)
static int aix386_core_file_failing_signal (bfd *abfd)
static void swap_abort ()

Variables

const bfd_target aix386_core_vec

Class Documentation

struct trad_core_struct

Definition at line 61 of file aix386-core.c.

Collaboration diagram for trad_core_struct:
Class Members
asection * data_section
struct corehdr * hdr
asection * reg2_section
asection * reg_section
asection * sections
asection * stack_section

Define Documentation

Definition at line 211 of file aix386-core.c.

#define COR_MAGIC   "core"

Definition at line 47 of file aix386-core.c.

#define core_hdr (   bfd)    (((bfd->tdata.trad_core_data))->hdr)

Definition at line 51 of file aix386-core.c.

#define core_reg2sec (   bfd)    (((bfd)->tdata.trad_core_data)->reg2_section)

Definition at line 543 of file aoutf1.h.

#define core_regsec (   bfd)    (((bfd)->tdata.trad_core_data)->reg_section)

Definition at line 55 of file aix386-core.c.

#define core_section (   bfd,
  n 
)    (((bfd)->tdata.trad_core_data)->sections[n])

Definition at line 53 of file aix386-core.c.

#define NO_GET   ((bfd_vma (*) (const void *)) swap_abort)

Definition at line 222 of file aix386-core.c.

#define NO_GET64   ((bfd_uint64_t (*) (const void *)) swap_abort)

Definition at line 225 of file aix386-core.c.

#define NO_GETS   ((bfd_signed_vma (*) (const void *)) swap_abort)

Definition at line 224 of file aix386-core.c.

#define NO_GETS64   ((bfd_int64_t (*) (const void *)) swap_abort)

Definition at line 227 of file aix386-core.c.

#define NO_PUT   ((void (*) (bfd_vma, void *)) swap_abort)

Definition at line 223 of file aix386-core.c.

#define NO_PUT64   ((void (*) (bfd_uint64_t, void *)) swap_abort)

Definition at line 226 of file aix386-core.c.


Function Documentation

static char* aix386_core_file_failing_command ( bfd abfd) [static]

Definition at line 198 of file aix386-core.c.

{
  return core_hdr (abfd)->cd_comm;
}
static int aix386_core_file_failing_signal ( bfd abfd) [static]

Definition at line 205 of file aix386-core.c.

{
  return core_hdr (abfd)->cd_cursig;
}
static const bfd_target* aix386_core_file_p ( bfd abfd) [static]

Definition at line 71 of file aix386-core.c.

{
  int i, n;
  unsigned char longbuf[4]; /* Raw bytes of various header fields */
  bfd_size_type core_size = sizeof (struct corehdr);
  bfd_size_type amt;
  struct corehdr *core;
  struct mergem {
    struct trad_core_struct coredata;
    struct corehdr internal_core;
  } *mergem;
  flagword flags;

  amt = sizeof (longbuf);
  if (bfd_bread ((PTR) longbuf, amt, abfd) != amt)
    {
      if (bfd_get_error () != bfd_error_system_call)
       bfd_set_error (bfd_error_wrong_format);
      return 0;
    }

  if (strncmp (longbuf, COR_MAGIC, 4))
    return 0;

  if (bfd_seek (abfd, (file_ptr) 0, 0) != 0)
    return 0;

  amt = sizeof (struct mergem);
  mergem = (struct mergem *) bfd_zalloc (abfd, amt);
  if (mergem == NULL)
    return 0;

  core = &mergem->internal_core;

  if ((bfd_bread ((PTR) core, core_size, abfd)) != core_size)
    {
      if (bfd_get_error () != bfd_error_system_call)
       bfd_set_error (bfd_error_wrong_format);
    loser:
      bfd_release (abfd, (char *) mergem);
      abfd->tdata.any = NULL;
      bfd_section_list_clear (abfd);
      return 0;
    }

  set_tdata (abfd, &mergem->coredata);
  core_hdr (abfd) = core;

  /* Create the sections.  */
  flags = SEC_HAS_CONTENTS;
  core_regsec (abfd) = bfd_make_section_anyway_with_flags (abfd, ".reg",
                                                    flags);
  if (core_regsec (abfd) == NULL)
    goto loser;

  core_regsec (abfd)->size = sizeof (core->cd_regs);
  core_regsec (abfd)->vma = (bfd_vma) -1;

  /* We'll access the regs afresh in the core file, like any section.  */
  core_regsec (abfd)->filepos =
    (file_ptr) offsetof (struct corehdr, cd_regs[0]);

  flags = SEC_HAS_CONTENTS;
  core_reg2sec (abfd) = bfd_make_section_anyway_with_flags (abfd, ".reg2",
                                                     flags);
  if (core_reg2sec (abfd) == NULL)
    /* bfd_release frees everything allocated after it's arg.  */
    goto loser;

  core_reg2sec (abfd)->size = sizeof (core->cd_fpregs);
  core_reg2sec (abfd)->vma = (bfd_vma) -1;
  core_reg2sec (abfd)->filepos =
    (file_ptr) offsetof (struct corehdr, cd_fpregs);

  for (i = 0, n = 0; (i < MAX_CORE_SEGS) && (core->cd_segs[i].cs_type); i++)
    {
      const char *sname;
      flagword flags;

      if (core->cd_segs[i].cs_offset == 0)
       continue;

      switch (core->cd_segs[i].cs_type)
       {
       case COR_TYPE_DATA:
         sname = ".data";
         flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
         break;
       case COR_TYPE_STACK:
         sname = ".stack";
         flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
         break;
       case COR_TYPE_LIBDATA:
         sname = ".libdata";
         flags = SEC_ALLOC + SEC_HAS_CONTENTS;
         break;
       case COR_TYPE_WRITE:
         sname = ".writeable";
         flags = SEC_ALLOC + SEC_HAS_CONTENTS;
         break;
       case COR_TYPE_MSC:
         sname = ".misc";
         flags = SEC_ALLOC + SEC_HAS_CONTENTS;
         break;
       default:
         sname = ".unknown";
         flags = SEC_ALLOC + SEC_HAS_CONTENTS;
         break;
       }
      core_section (abfd, n) = bfd_make_section_anyway_with_flags (abfd,
                                                           sname,
                                                           flags);
      if (core_section (abfd, n) == NULL)
       goto loser;

      core_section (abfd, n)->size = core->cd_segs[i].cs_len;
      core_section (abfd, n)->vma       = core->cd_segs[i].cs_address;
      core_section (abfd, n)->filepos   = core->cd_segs[i].cs_offset;
      core_section (abfd, n)->alignment_power = 2;
      n++;
    }

  return abfd->xvec;
}

Here is the call graph for this function:

static void swap_abort PARAMS ( (void)  ) [static]
static void swap_abort ( void  ) [static]

Definition at line 216 of file aix386-core.c.

{
  /* This way doesn't require any declaration for ANSI to fuck up.  */
  abort ();
}

Variable Documentation

Definition at line 229 of file aix386-core.c.