Back to index

cell-binutils  2.17cvs20070401
Defines | Functions | Variables
peicode.h File Reference
#include "libpei.h"

Go to the source code of this file.


#define coff_bfd_print_private_bfd_data   pe_print_private_bfd_data
#define coff_bfd_copy_private_bfd_data   pe_bfd_copy_private_bfd_data
#define coff_mkobject   pe_mkobject
#define coff_mkobject_hook   pe_mkobject_hook
#define coff_swap_filehdr_out   _bfd_pe_only_swap_filehdr_out
#define coff_bfd_copy_private_section_data   _bfd_XX_bfd_copy_private_section_data
#define coff_get_symbol_info   _bfd_XX_get_symbol_info


static bfd_boolean pe_print_private_bfd_data (bfd *, void *)
static bfd_boolean pe_bfd_copy_private_bfd_data (bfd *, bfd *)
static void coff_swap_reloc_in (bfd *abfd, void *src, void *dst)
static unsigned int coff_swap_reloc_out (bfd *abfd, void *src, void *dst)
static void coff_swap_filehdr_in (bfd *abfd, void *src, void *dst)
static void coff_swap_scnhdr_in (bfd *abfd, void *ext, void *in)
static bfd_boolean pe_mkobject (bfd *abfd)
static void * pe_mkobject_hook (bfd *abfd, void *filehdr, void *aouthdr ATTRIBUTE_UNUSED)


static bfd_boolean(* pe_saved_coff_bfd_print_private_bfd_data )(bfd *, void *)
static bfd_boolean(* pe_saved_coff_bfd_copy_private_bfd_data )(bfd *, bfd *)

Define Documentation

Definition at line 78 of file peicode.h.

Definition at line 367 of file peicode.h.

Definition at line 67 of file peicode.h.

Definition at line 370 of file peicode.h.

#define coff_mkobject   pe_mkobject

Definition at line 80 of file peicode.h.

Definition at line 81 of file peicode.h.

#define coff_swap_filehdr_out   _bfd_pe_only_swap_filehdr_out

Definition at line 190 of file peicode.h.

Function Documentation

static void coff_swap_filehdr_in ( bfd abfd,
void *  src,
void *  dst 
) [static]

Definition at line 160 of file peicode.h.

  FILHDR *filehdr_src = (FILHDR *) src;
  struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst;

  filehdr_dst->f_magic  = H_GET_16 (abfd, filehdr_src->f_magic);
  filehdr_dst->f_nscns  = H_GET_16 (abfd, filehdr_src->f_nscns);
  filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat);
  filehdr_dst->f_nsyms  = H_GET_32 (abfd, filehdr_src->f_nsyms);
  filehdr_dst->f_flags  = H_GET_16 (abfd, filehdr_src->f_flags);
  filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr);

  /* Other people's tools sometimes generate headers with an nsyms but
     a zero symptr.  */
  if (filehdr_dst->f_nsyms != 0 && filehdr_dst->f_symptr == 0)
      filehdr_dst->f_nsyms = 0;
      filehdr_dst->f_flags |= F_LSYMS;

  filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr);
static void coff_swap_reloc_in ( bfd abfd,
void *  src,
void *  dst 
) [static]

Definition at line 126 of file peicode.h.

  RELOC *reloc_src = (RELOC *) src;
  struct internal_reloc *reloc_dst = (struct internal_reloc *) dst;

  reloc_dst->r_vaddr  = H_GET_32 (abfd, reloc_src->r_vaddr);
  reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx);
  reloc_dst->r_type   = H_GET_16 (abfd, reloc_src->r_type);
  reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset);
static unsigned int coff_swap_reloc_out ( bfd abfd,
void *  src,
void *  dst 
) [static]

Definition at line 140 of file peicode.h.

  struct internal_reloc *reloc_src = (struct internal_reloc *) src;
  struct external_reloc *reloc_dst = (struct external_reloc *) dst;

  H_PUT_32 (abfd, reloc_src->r_vaddr, reloc_dst->r_vaddr);
  H_PUT_32 (abfd, reloc_src->r_symndx, reloc_dst->r_symndx);
  H_PUT_16 (abfd, reloc_src->r_type, reloc_dst->r_type);

  SWAP_OUT_RELOC_OFFSET (abfd, reloc_src->r_offset, reloc_dst->r_offset);
  SWAP_OUT_RELOC_EXTRA (abfd, reloc_src, reloc_dst);
  return RELSZ;
static void coff_swap_scnhdr_in ( bfd abfd,
void *  ext,
void *  in 
) [static]

Definition at line 194 of file peicode.h.

  SCNHDR *scnhdr_ext = (SCNHDR *) ext;
  struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;

  memcpy (scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name));

  scnhdr_int->s_vaddr   = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr);
  scnhdr_int->s_paddr   = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr);
  scnhdr_int->s_size    = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size);
  scnhdr_int->s_scnptr  = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr);
  scnhdr_int->s_relptr  = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr);
  scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr);
  scnhdr_int->s_flags   = H_GET_32 (abfd, scnhdr_ext->s_flags);

  /* MS handles overflow of line numbers by carrying into the reloc
     field (it appears).  Since it's supposed to be zero for PE
     *IMAGE* format, that's safe.  This is still a bit iffy.  */
  scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno)
                      + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16));
  scnhdr_int->s_nreloc = 0;
  scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc);
  scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno);

  if (scnhdr_int->s_vaddr != 0)
      scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase;
      /* Do not cut upper 32-bits for 64-bit vma.  */
#ifndef COFF_WITH_pex64
      scnhdr_int->s_vaddr &= 0xffffffff;

  /* If this section holds uninitialized data and is from an object file
     or from an executable image that has not initialized the field,
     or if the image is an executable file and the physical size is padded,
     use the virtual size (stored in s_paddr) instead.  */
  if (scnhdr_int->s_paddr > 0
      && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0
          && (! bfd_pe_executable_p (abfd) || scnhdr_int->s_size == 0))
          || (bfd_pe_executable_p (abfd) && scnhdr_int->s_size > scnhdr_int->s_paddr)))
  /* This code used to set scnhdr_int->s_paddr to 0.  However,
     coff_set_alignment_hook stores s_paddr in virt_size, which
     only works if it correctly holds the virtual size of the
     section.  */
    scnhdr_int->s_size = scnhdr_int->s_paddr;
static bfd_boolean pe_bfd_copy_private_bfd_data ( bfd ibfd,
bfd obfd 
) [static]

Definition at line 348 of file peicode.h.

  /* PR binutils/716: Copy the large address aware flag.
     XXX: Should we be copying other flags or other fields in the pe_data()
     structure ?  */
  if (pe_data (obfd) != NULL
      && pe_data (ibfd) != NULL
      && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE)
    pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE;
  if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd))
    return FALSE;

  if (pe_saved_coff_bfd_copy_private_bfd_data)
    return pe_saved_coff_bfd_copy_private_bfd_data (ibfd, obfd);

  return TRUE;
static bfd_boolean pe_mkobject ( bfd abfd) [static]

Definition at line 248 of file peicode.h.

  pe_data_type *pe;
  bfd_size_type amt = sizeof (pe_data_type);

  abfd->tdata.pe_obj_data = (struct pe_tdata *) bfd_zalloc (abfd, amt);

  if (abfd->tdata.pe_obj_data == 0)
    return FALSE;

  pe = pe_data (abfd);

  pe-> = 1;

  /* in_reloc_p is architecture dependent.  */
  pe->in_reloc_p = in_reloc_p;

  pe->force_minimum_alignment = 1;
  pe->target_subsystem = PEI_TARGET_SUBSYSTEM;

  return TRUE;

Here is the call graph for this function:

Here is the caller graph for this function:

static void* pe_mkobject_hook ( bfd abfd,
void *  filehdr,
void *aouthdr  ATTRIBUTE_UNUSED 
) [static]

Definition at line 278 of file peicode.h.

  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
  pe_data_type *pe;

  if (! pe_mkobject (abfd))
    return NULL;

  pe = pe_data (abfd);
  pe->coff.sym_filepos = internal_f->f_symptr;
  /* These members communicate important constants about the symbol
     table to GDB's symbol-reading code.  These `constants'
     unfortunately vary among coff implementations...  */
  pe->coff.local_n_btmask = N_BTMASK;
  pe->coff.local_n_btshft = N_BTSHFT;
  pe->coff.local_n_tmask = N_TMASK;
  pe->coff.local_n_tshift = N_TSHIFT;
  pe->coff.local_symesz = SYMESZ;
  pe->coff.local_auxesz = AUXESZ;
  pe->coff.local_linesz = LINESZ;

  pe->coff.timestamp = internal_f->f_timdat;

  obj_raw_syment_count (abfd) =
    obj_conv_table_size (abfd) =

  pe->real_flags = internal_f->f_flags;

  if ((internal_f->f_flags & F_DLL) != 0)
    pe->dll = 1;

  if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0)
    abfd->flags |= HAS_DEBUG;

  if (aouthdr)
    pe->pe_opthdr = ((struct internal_aouthdr *) aouthdr)->pe;

#ifdef ARM
  if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags))
    coff_data (abfd) ->flags = 0;

  return (void *) pe;

Here is the call graph for this function:

static bfd_boolean pe_print_private_bfd_data ( bfd abfd,
void *  vfile 
) [static]

Definition at line 329 of file peicode.h.

  FILE *file = (FILE *) vfile;

  if (!_bfd_XX_print_private_bfd_data_common (abfd, vfile))
    return FALSE;

  if (pe_saved_coff_bfd_print_private_bfd_data == NULL)
    return TRUE;

  fputc ('\n', file);

  return pe_saved_coff_bfd_print_private_bfd_data (abfd, vfile);

Variable Documentation

Initial value:

Definition at line 69 of file peicode.h.

Initial value:

Definition at line 58 of file peicode.h.