Back to index

cell-binutils  2.17cvs20070401
Classes | Defines | Functions | Variables
aoutf1.h File Reference
#include "bfd.h"
#include "sysdep.h"
#include "libbfd.h"
#include "aout/sun4.h"
#include "libaout.h"
#include "aout/aout64.h"
#include "aout/stab_gnu.h"
#include "aout/ar.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  regs
struct  external_sparc_core
struct  external_solaris_bcp_core
struct  external_sun3_core
struct  internal_sunos_core
struct  sun_core_struct

Defines

#define MACHTYPE_OK(mtype)

Functions

static bfd_boolean sunos_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
static void sunos_set_arch_mach (bfd *abfd, enum machine_type machtype)
static void choose_reloc_size (bfd *abfd)
static bfd_boolean sunos_write_object_contents (bfd *abfd)
static void swapcore_sun3 (bfd *abfd, char *ext, struct internal_sunos_core *intcore)
static void swapcore_sparc (bfd *abfd, char *ext, struct internal_sunos_core *intcore)
static void swapcore_solaris_bcp (bfd *abfd, char *ext, struct internal_sunos_core *intcore)
static const bfd_targetsunos4_core_file_p (bfd *abfd)
static char * sunos4_core_file_failing_command (bfd *abfd)
static int sunos4_core_file_failing_signal (bfd *abfd)
static bfd_boolean sunos4_core_file_matches_executable_p (bfd *core_bfd, bfd *exec_bfd)
static bfd_boolean sunos4_set_sizes (bfd *abfd)

Variables

static struct aout_backend_data

Class Documentation

struct regs

Definition at line 255 of file aoutf1.h.

Class Members
int r_g1
int r_g2
int r_g3
int r_g4
int r_g5
int r_g6
int r_g7
int r_npc
int r_o0
int r_o1
int r_o2
int r_o3
int r_o4
int r_o5
int r_o6
int r_o7
int r_pc
int r_psr
int r_y
struct external_sparc_core

Definition at line 284 of file aoutf1.h.

Class Members
char c_cmdname
int c_dsize
int c_len
int c_magic
int c_signo
int c_ssize
int c_tsize
int c_ucode
double fp_stuff
struct external_solaris_bcp_core

Definition at line 307 of file aoutf1.h.

Class Members
char c_cmdname
int c_dsize
int c_exdata_bsize
int c_exdata_datorg
int c_exdata_doffset
int c_exdata_dsize
int c_exdata_entloc
int c_exdata_loffset
int c_exdata_lsize
short c_exdata_mach
short c_exdata_mag
int c_exdata_nshlibs
int c_exdata_toffset
int c_exdata_tsize
int c_exdata_txtorg
int c_exdata_vp
int c_len
int c_magic
int c_signo
int c_ssize
int c_tsize
int c_ucode
double fp_stuff
struct external_sun3_core

Definition at line 341 of file aoutf1.h.

Class Members
char c_cmdname
int c_dsize
int c_len
int c_magic
int c_regs
int c_signo
int c_ssize
int c_tsize
int c_ucode
double fp_stuff
struct internal_sunos_core

Definition at line 362 of file aoutf1.h.

Class Members
char c_cmdname
bfd_vma c_data_addr
int c_dsize
int c_len
int c_magic
long c_regs_pos
int c_regs_size
int c_signo
int c_ssize
bfd_vma c_stacktop
int c_tsize
int c_ucode
long fp_stuff_pos
int fp_stuff_size
struct sun_core_struct

Definition at line 546 of file aoutf1.h.

Collaboration diagram for sun_core_struct:
Class Members
asection * data_section
struct internal_sunos_core * hdr
asection * reg2_section
asection * reg_section
asection * stack_section

Define Documentation

#define MACHTYPE_OK (   mtype)
Value:
(((mtype) == M_SPARC && bfd_lookup_arch (bfd_arch_sparc, 0) != NULL) \
   || (((mtype) == M_UNKNOWN || (mtype) == M_68010 || (mtype) == M_68020) \
       && bfd_lookup_arch (bfd_arch_m68k, 0) != NULL))

Definition at line 39 of file aoutf1.h.


Function Documentation

static void choose_reloc_size ( bfd abfd) [static]

Definition at line 166 of file aoutf1.h.

{
  switch (bfd_get_arch (abfd))
    {
    case bfd_arch_sparc:
      obj_reloc_entry_size (abfd) = RELOC_EXT_SIZE;
      break;
    default:
      obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
      break;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static char* sunos4_core_file_failing_command ( bfd abfd) [static]

Definition at line 682 of file aoutf1.h.

{
  return core_hdr (abfd)->hdr->c_cmdname;
}
static int sunos4_core_file_failing_signal ( bfd abfd) [static]

Definition at line 688 of file aoutf1.h.

{
  return core_hdr (abfd)->hdr->c_signo;
}
static bfd_boolean sunos4_core_file_matches_executable_p ( bfd core_bfd,
bfd exec_bfd 
) [static]

Definition at line 694 of file aoutf1.h.

{
  if (core_bfd->xvec != exec_bfd->xvec)
    {
      bfd_set_error (bfd_error_system_call);
      return FALSE;
    }

  /* Solaris core files do not include an aouthdr.  */
  if ((core_hdr (core_bfd)->hdr)->c_len == SOLARIS_BCP_CORE_LEN)
    return TRUE;

  return memcmp ((char *) &((core_hdr (core_bfd)->hdr)->c_aouthdr),
               (char *) exec_hdr (exec_bfd),
               sizeof (struct internal_exec)) == 0;
}

Here is the call graph for this function:

static const bfd_target* sunos4_core_file_p ( bfd abfd) [static]

Definition at line 556 of file aoutf1.h.

{
  unsigned char longbuf[4]; /* Raw bytes of various header fields.  */
  bfd_size_type core_size, amt;
  unsigned long core_mag;
  struct internal_sunos_core *core;
  char *extcore;
  struct mergem
    {
      struct sun_core_struct suncoredata;
      struct internal_sunos_core internal_sunos_core;
      char external_core[1];
    } *mergem;
  flagword flags;

  if (bfd_bread ((void *) longbuf, (bfd_size_type) sizeof (longbuf), abfd)
      != sizeof (longbuf))
    return NULL;
  core_mag = H_GET_32 (abfd, longbuf);

  if (core_mag != CORE_MAGIC)
    return NULL;

  /* SunOS core headers can vary in length; second word is size; */
  if (bfd_bread ((void *) longbuf, (bfd_size_type) sizeof (longbuf), abfd)
      != sizeof (longbuf))
    return NULL;
  core_size = H_GET_32 (abfd, longbuf);
  /* Sanity check.  */
  if (core_size > 20000)
    return NULL;

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

  amt = core_size + sizeof (struct mergem);
  mergem = bfd_zalloc (abfd, amt);
  if (mergem == NULL)
    return NULL;

  extcore = mergem->external_core;

  if ((bfd_bread ((void *) extcore, core_size, abfd)) != core_size)
    {
    loser:
      bfd_release (abfd, (char *) mergem);
      abfd->tdata.any = NULL;
      bfd_section_list_clear (abfd);
      return NULL;
    }

  /* Validate that it's a core file we know how to handle, due to sun
     botching the positioning of registers and other fields in a machine
     dependent way.  */
  core = &mergem->internal_sunos_core;
  switch (core_size)
    {
    case SPARC_CORE_LEN:
      swapcore_sparc (abfd, extcore, core);
      break;
    case SUN3_CORE_LEN:
      swapcore_sun3 (abfd, extcore, core);
      break;
    case SOLARIS_BCP_CORE_LEN:
      swapcore_solaris_bcp (abfd, extcore, core);
      break;
    default:
      bfd_set_error (bfd_error_system_call);     /* FIXME.  */
      goto loser;
    }

  abfd->tdata.sun_core_data = &mergem->suncoredata;
  abfd->tdata.sun_core_data->hdr = core;

  /* Create the sections.  */
  flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
  core_stacksec (abfd) = bfd_make_section_anyway_with_flags (abfd, ".stack",
                                                      flags);
  if (core_stacksec (abfd) == NULL)
    /* bfd_release frees everything allocated after it's arg.  */
    goto loser;

  flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
  core_datasec (abfd) = bfd_make_section_anyway_with_flags (abfd, ".data",
                                                     flags);
  if (core_datasec (abfd) == NULL)
    goto loser;

  flags = SEC_HAS_CONTENTS;
  core_regsec (abfd) = bfd_make_section_anyway_with_flags (abfd, ".reg",
                                                    flags);
  if (core_regsec (abfd) == NULL)
    goto loser;

  flags = SEC_HAS_CONTENTS;
  core_reg2sec (abfd) = bfd_make_section_anyway_with_flags (abfd, ".reg2",
                                                     flags);
  if (core_reg2sec (abfd) == NULL)
    goto loser;

  core_stacksec (abfd)->size = core->c_ssize;
  core_datasec (abfd)->size = core->c_dsize;
  core_regsec (abfd)->size = core->c_regs_size;
  core_reg2sec (abfd)->size = core->fp_stuff_size;

  core_stacksec (abfd)->vma = (core->c_stacktop - core->c_ssize);
  core_datasec (abfd)->vma = core->c_data_addr;
  core_regsec (abfd)->vma = 0;
  core_reg2sec (abfd)->vma = 0;

  core_stacksec (abfd)->filepos = core->c_len + core->c_dsize;
  core_datasec (abfd)->filepos = core->c_len;
  /* We'll access the regs afresh in the core file, like any section:  */
  core_regsec (abfd)->filepos = (file_ptr) core->c_regs_pos;
  core_reg2sec (abfd)->filepos = (file_ptr) core->fp_stuff_pos;

  /* Align to word at least.  */
  core_stacksec (abfd)->alignment_power = 2;
  core_datasec (abfd)->alignment_power = 2;
  core_regsec (abfd)->alignment_power = 2;
  core_reg2sec (abfd)->alignment_power = 2;

  return abfd->xvec;
}

Here is the call graph for this function:

static bfd_boolean sunos4_set_sizes ( bfd abfd) [static]

Definition at line 714 of file aoutf1.h.

{
  switch (bfd_get_arch (abfd))
    {
    default:
      return FALSE;
    case bfd_arch_sparc:
      adata (abfd).page_size = 0x2000;
      adata (abfd).segment_size = 0x2000;
      adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE;
      return TRUE;
    case bfd_arch_m68k:
      adata (abfd).page_size = 0x2000;
      adata (abfd).segment_size = 0x20000;
      adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE;
      return TRUE;
    }
}

Here is the call graph for this function:

static bfd_boolean sunos_merge_private_bfd_data ( bfd ibfd,
bfd obfd 
) [static]

Definition at line 79 of file aoutf1.h.

{
  if (bfd_get_flavour (ibfd) != bfd_target_aout_flavour
      || bfd_get_flavour (obfd) != bfd_target_aout_flavour)
    return TRUE;

  if (bfd_get_arch (obfd) == bfd_arch_sparc)
    {
      if (bfd_get_mach (obfd) < bfd_get_mach (ibfd))
       bfd_set_arch_mach (obfd, bfd_arch_sparc, bfd_get_mach (ibfd));
    }

  return TRUE;
}

Here is the call graph for this function:

static void sunos_set_arch_mach ( bfd abfd,
enum machine_type  machtype 
) [static]

Definition at line 98 of file aoutf1.h.

{
  /* Determine the architecture and machine type of the object file.  */
  enum bfd_architecture arch;
  unsigned long machine;

  switch (machtype)
    {
    case M_UNKNOWN:
      /* Some Sun3s make magic numbers without cpu types in them, so
        we'll default to the 68000.  */
      arch = bfd_arch_m68k;
      machine = bfd_mach_m68000;
      break;

    case M_68010:
    case M_HP200:
      arch = bfd_arch_m68k;
      machine = bfd_mach_m68010;
      break;

    case M_68020:
    case M_HP300:
      arch = bfd_arch_m68k;
      machine = bfd_mach_m68020;
      break;

    case M_SPARC:
      arch = bfd_arch_sparc;
      machine = 0;
      break;

    case M_SPARCLET:
      arch = bfd_arch_sparc;
      machine = bfd_mach_sparc_sparclet;
      break;

    case M_SPARCLITE_LE:
      arch = bfd_arch_sparc;
      machine = bfd_mach_sparc_sparclite_le;
      break;

    case M_386:
    case M_386_DYNIX:
      arch = bfd_arch_i386;
      machine = 0;
      break;

    case M_HPUX:
      arch = bfd_arch_m68k;
      machine = 0;
      break;

    default:
      arch = bfd_arch_obscure;
      machine = 0;
      break;
    }
  bfd_set_arch_mach (abfd, arch, machine);
}
static bfd_boolean sunos_write_object_contents ( bfd abfd) [static]

Definition at line 186 of file aoutf1.h.

{
  struct external_exec exec_bytes;
  struct internal_exec *execp = exec_hdr (abfd);

  /* Magic number, maestro, please!  */
  switch (bfd_get_arch (abfd))
    {
    case bfd_arch_m68k:
      switch (bfd_get_mach (abfd))
       {
       case bfd_mach_m68000:
         N_SET_MACHTYPE (*execp, M_UNKNOWN);
         break;
       case bfd_mach_m68010:
         N_SET_MACHTYPE (*execp, M_68010);
         break;
       default:
       case bfd_mach_m68020:
         N_SET_MACHTYPE (*execp, M_68020);
         break;
       }
      break;
    case bfd_arch_sparc:
      switch (bfd_get_mach (abfd))
       {
       case bfd_mach_sparc_sparclet:
         N_SET_MACHTYPE (*execp, M_SPARCLET);
         break;
       case bfd_mach_sparc_sparclite_le:
         N_SET_MACHTYPE (*execp, M_SPARCLITE_LE);
         break;
       default:
         N_SET_MACHTYPE (*execp, M_SPARC);
         break;
       }
      break;
    case bfd_arch_i386:
      N_SET_MACHTYPE (*execp, M_386);
      break;
    default:
      N_SET_MACHTYPE (*execp, M_UNKNOWN);
    }

  choose_reloc_size (abfd);

  N_SET_FLAGS (*execp, aout_backend_info (abfd)->exec_hdr_flags);

  N_SET_DYNAMIC (*execp, (long)(bfd_get_file_flags (abfd) & DYNAMIC));

  WRITE_HEADERS (abfd, execp);

  return TRUE;
}

Here is the call graph for this function:

static void swapcore_solaris_bcp ( bfd abfd,
char *  ext,
struct internal_sunos_core intcore 
) [static]

Definition at line 476 of file aoutf1.h.

{
  struct external_solaris_bcp_core *extcore =
    (struct external_solaris_bcp_core *) ext;

  intcore->c_magic = H_GET_32 (abfd, &extcore->c_magic);
  intcore->c_len = H_GET_32 (abfd, &extcore->c_len);
  intcore->c_regs_pos = offsetof (struct external_solaris_bcp_core, c_regs);
  intcore->c_regs_size = sizeof (extcore->c_regs);

  /* The Solaris BCP exdata structure does not contain an a_syms field,
     so we are unable to synthesize an internal exec header.
     Luckily we are able to figure out the start address of the data section,
     which is the only thing needed from the internal exec header,
     from the exdata structure.

     As of Solaris 2.3, BCP core files for statically linked executables
     are buggy. The exdata structure is not properly filled in, and
     the data section is written from address zero instead of the data
     start address.  */
  memset ((void *) &intcore->c_aouthdr, 0, sizeof (struct internal_exec));
  intcore->c_data_addr = H_GET_32 (abfd, &extcore->c_exdata_datorg);
  intcore->c_signo = H_GET_32 (abfd, &extcore->c_signo);
  intcore->c_tsize = H_GET_32 (abfd, &extcore->c_tsize);
  intcore->c_dsize = H_GET_32 (abfd, &extcore->c_dsize);
  intcore->c_ssize = H_GET_32 (abfd, &extcore->c_ssize);
  memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
  intcore->fp_stuff_pos =
    offsetof (struct external_solaris_bcp_core, fp_stuff);
  /* FP stuff takes up whole rest of struct, except c_ucode.  */
  intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) -
    offsetof (struct external_solaris_bcp_core, fp_stuff);
  /* Ucode is the last thing in the struct -- just before the end */
  intcore->c_ucode = H_GET_32 (abfd,
                            (intcore->c_len
                            - sizeof (extcore->c_ucode)
                            + (unsigned char *) extcore));

  /* Supposedly the user stack grows downward from the bottom of kernel memory.
     Presuming that this remains true, this definition will work.  */
  /* Now sun has provided us with another challenge.  The value is different
     for sparc2 and sparc10 (both running SunOS 4.1.3).  We pick one or
     the other based on the current value of the stack pointer.  This
     loses (a) if the stack pointer has been clobbered, or (b) if the stack
     is larger than 128 megabytes.

     It's times like these you're glad they're switching to ELF.

     Note that using include files or nlist on /vmunix would be wrong,
     because we want the value for this core file, no matter what kind of
     machine we were compiled on or are running on.  */
#define SPARC_USRSTACK_SPARC2 ((bfd_vma)0xf8000000)
#define SPARC_USRSTACK_SPARC10 ((bfd_vma)0xf0000000)
  {
    bfd_vma sp = H_GET_32 (abfd, &extcore->c_regs.r_o6);
    if (sp < SPARC_USRSTACK_SPARC10)
      intcore->c_stacktop = SPARC_USRSTACK_SPARC10;
    else
      intcore->c_stacktop = SPARC_USRSTACK_SPARC2;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void swapcore_sparc ( bfd abfd,
char *  ext,
struct internal_sunos_core intcore 
) [static]

Definition at line 419 of file aoutf1.h.

{
  struct external_sparc_core *extcore = (struct external_sparc_core *) ext;

  intcore->c_magic = H_GET_32 (abfd, &extcore->c_magic);
  intcore->c_len = H_GET_32 (abfd, &extcore->c_len);
  intcore->c_regs_pos = offsetof (struct external_sparc_core, c_regs);
  intcore->c_regs_size = sizeof (extcore->c_regs);
#if ARCH_SIZE == 64
  aout_64_swap_exec_header_in
#else
  aout_32_swap_exec_header_in
#endif
    (abfd, &extcore->c_aouthdr, &intcore->c_aouthdr);
  intcore->c_signo = H_GET_32 (abfd, &extcore->c_signo);
  intcore->c_tsize = H_GET_32 (abfd, &extcore->c_tsize);
  intcore->c_dsize = H_GET_32 (abfd, &extcore->c_dsize);
  intcore->c_data_addr = N_DATADDR (intcore->c_aouthdr);
  intcore->c_ssize = H_GET_32 (abfd, &extcore->c_ssize);
  memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
  intcore->fp_stuff_pos = offsetof (struct external_sparc_core, fp_stuff);
  /* FP stuff takes up whole rest of struct, except c_ucode.  */
  intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) -
    offsetof (struct external_sparc_core, fp_stuff);
  /* Ucode is the last thing in the struct -- just before the end.  */
  intcore->c_ucode = H_GET_32 (abfd,
                            (intcore->c_len
                            - sizeof (extcore->c_ucode)
                            + (unsigned char *) extcore));

  /* Supposedly the user stack grows downward from the bottom of kernel memory.
     Presuming that this remains true, this definition will work.  */
  /* Now sun has provided us with another challenge.  The value is different
     for sparc2 and sparc10 (both running SunOS 4.1.3).  We pick one or
     the other based on the current value of the stack pointer.  This
     loses (a) if the stack pointer has been clobbered, or (b) if the stack
     is larger than 128 megabytes.

     It's times like these you're glad they're switching to ELF.

     Note that using include files or nlist on /vmunix would be wrong,
     because we want the value for this core file, no matter what kind of
     machine we were compiled on or are running on.  */
#define SPARC_USRSTACK_SPARC2 ((bfd_vma)0xf8000000)
#define SPARC_USRSTACK_SPARC10 ((bfd_vma)0xf0000000)
  {
    bfd_vma sp = H_GET_32 (abfd, &extcore->c_regs.r_o6);
    if (sp < SPARC_USRSTACK_SPARC10)
      intcore->c_stacktop = SPARC_USRSTACK_SPARC10;
    else
      intcore->c_stacktop = SPARC_USRSTACK_SPARC2;
  }
}

Here is the caller graph for this function:

static void swapcore_sun3 ( bfd abfd,
char *  ext,
struct internal_sunos_core intcore 
) [static]

Definition at line 384 of file aoutf1.h.

{
  struct external_sun3_core *extcore = (struct external_sun3_core *) ext;

  intcore->c_magic = H_GET_32 (abfd, &extcore->c_magic);
  intcore->c_len = H_GET_32 (abfd, &extcore->c_len);
  intcore->c_regs_pos = offsetof (struct external_sun3_core, c_regs);
  intcore->c_regs_size = sizeof (extcore->c_regs);
#if ARCH_SIZE == 64
  aout_64_swap_exec_header_in
#else
  aout_32_swap_exec_header_in
#endif
    (abfd, &extcore->c_aouthdr, &intcore->c_aouthdr);
  intcore->c_signo = H_GET_32 (abfd, &extcore->c_signo);
  intcore->c_tsize = H_GET_32 (abfd, &extcore->c_tsize);
  intcore->c_dsize = H_GET_32 (abfd, &extcore->c_dsize);
  intcore->c_data_addr = N_DATADDR (intcore->c_aouthdr);
  intcore->c_ssize = H_GET_32 (abfd, &extcore->c_ssize);
  memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
  intcore->fp_stuff_pos = offsetof (struct external_sun3_core, fp_stuff);
  /* FP stuff takes up whole rest of struct, except c_ucode.  */
  intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) -
    offsetof (struct external_sun3_core, fp_stuff);
  /* Ucode is the last thing in the struct -- just before the end.  */
  intcore->c_ucode = H_GET_32 (abfd,
                            (intcore->c_len
                            - sizeof (extcore->c_ucode)
                            + (unsigned char *) extcore));
  intcore->c_stacktop = 0x0E000000;       /* By experimentation.  */
}

Here is the caller graph for this function:


Variable Documentation