Back to index

cell-binutils  2.17cvs20070401
Classes | Defines | Typedefs | Enumerations | Functions
pef.h File Reference
#include "bfd.h"
#include <stdio.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  bfd_pef_header
struct  bfd_pef_loader_header
struct  bfd_pef_imported_library
struct  bfd_pef_imported_symbol
struct  bfd_pef_section
struct  bfd_pef_data_struct
struct  bfd_pef_xlib_header
struct  bfd_pef_xlib_data_struct

Defines

#define BFD_PEF_TAG1   0x4A6F7921 /* 'Joy!' */
#define BFD_PEF_TAG2   0x70656666 /* 'peff' */
#define BFD_PEF_VERSION   0x00000001
#define BFD_PEF_SECTION_CODE   0
#define BFD_PEF_SECTION_UNPACKED_DATA   1
#define BFD_PEF_SECTION_PACKED_DATA   2
#define BFD_PEF_SECTION_CONSTANT   3
#define BFD_PEF_SECTION_LOADER   4
#define BFD_PEF_SECTION_DEBUG   5
#define BFD_PEF_SECTION_EXEC_DATA   6
#define BFD_PEF_SECTION_EXCEPTION   7
#define BFD_PEF_SECTION_TRACEBACK   8
#define BFD_PEF_SHARE_PROCESS   1
#define BFD_PEF_SHARE_GLOBAL   4
#define BFD_PEF_SHARE_PROTECTED   5
#define BFD_PEF_XLIB_TAG1   0xF04D6163 /* '?Mac' */
#define BFD_PEF_VLIB_TAG2   0x564C6962 /* 'VLib' */
#define BFD_PEF_BLIB_TAG2   0x424C6962 /* 'BLib' */
#define BFD_PEF_XLIB_VERSION   0x00000001

Typedefs

typedef struct bfd_pef_header
typedef struct bfd_pef_loader_header
typedef struct bfd_pef_imported_library
typedef struct bfd_pef_imported_symbol
typedef struct bfd_pef_section
typedef struct bfd_pef_data_struct
typedef struct bfd_pef_xlib_header
typedef struct bfd_pef_xlib_data_struct

Enumerations

enum  bfd_pef_imported_library_options { BFD_PEF_WEAK_IMPORT_LIB = 0x40, BFD_PEF_INIT_LIB_BEFORE = 0x80 }
enum  bfd_pef_imported_symbol_class {
  BFD_PEF_CODE_SYMBOL = 0x00, BFD_PEF_DATA_SYMBOL = 0x01, BFD_PEF_TVECTOR_SYMBOL = 0x02, BFD_PEF_TOC_SYMBOL = 0x03,
  BFD_PEF_GLUE_SYMBOL = 0x04, BFD_PEF_UNDEFINED_SYMBOL = 0x0F, BFD_PEF_WEAK_IMPORT_SYMBOL_MASK = 0x80
}

Functions

int bfd_pef_parse_loader_header (bfd *, unsigned char *, size_t, bfd_pef_loader_header *)
int bfd_pef_print_loader_section (bfd *, FILE *)
void bfd_pef_print_loader_header (bfd *, bfd_pef_loader_header *, FILE *)
int bfd_pef_parse_imported_library (bfd *, unsigned char *, size_t, bfd_pef_imported_library *)
int bfd_pef_parse_imported_symbol (bfd *, unsigned char *, size_t, bfd_pef_imported_symbol *)
int bfd_pef_scan_section (bfd *, bfd_pef_section *)
int bfd_pef_scan_start_address (bfd *)
int bfd_pef_scan (bfd *, bfd_pef_header *, bfd_pef_data_struct *)

Class Documentation

struct bfd_pef_header

Definition at line 25 of file pef.h.

Class Members
unsigned long architecture
unsigned long current_version
unsigned long format_version
unsigned short instantiated_section_count
unsigned long old_definition_version
unsigned long old_implementation_version
unsigned long reserved
unsigned short section_count
unsigned long tag1
unsigned long tag2
unsigned long timestamp
struct bfd_pef_loader_header

Definition at line 41 of file pef.h.

Class Members
unsigned long export_hash_offset
unsigned long export_hash_table_power
unsigned long exported_symbol_count
unsigned long imported_library_count
unsigned long init_offset
long init_section
unsigned long loader_strings_offset
unsigned long main_offset
long main_section
unsigned long reloc_instr_offset
unsigned long reloc_section_count
unsigned long term_offset
long term_section
unsigned long total_imported_symbol_count
struct bfd_pef_imported_library

Definition at line 60 of file pef.h.

Class Members
unsigned long current_version
unsigned long first_imported_symbol
unsigned long imported_symbol_count
unsigned long name_offset
unsigned long old_implementation_version
unsigned char options
unsigned char reserved_a
unsigned short reserved_b
struct bfd_pef_imported_symbol

Definition at line 79 of file pef.h.

Class Members
unsigned char class
unsigned long name
struct bfd_pef_section

Definition at line 102 of file pef.h.

Collaboration diagram for bfd_pef_section:
Class Members
unsigned char alignment
asection * bfd_section
unsigned long container_length
unsigned long container_offset
unsigned long default_address
unsigned long header_offset
long name_offset
unsigned char reserved
unsigned char section_kind
unsigned char share_kind
unsigned long total_length
unsigned long unpacked_length
struct bfd_pef_data_struct

Definition at line 133 of file pef.h.

Collaboration diagram for bfd_pef_data_struct:
Class Members
bfd_pef_header header
bfd * ibfd
bfd_pef_section * sections
struct bfd_pef_xlib_header

Definition at line 147 of file pef.h.

Class Members
unsigned long container_strings_offset
unsigned long cpu_family
unsigned long cpu_model
unsigned long current_format
unsigned long current_version
unsigned long date_time_stamp
unsigned long dylib_path_length
unsigned long dylib_path_offset
unsigned long export_hash_offset
unsigned long export_hash_table_power
unsigned long export_key_offset
unsigned long export_names_offset
unsigned long export_symbol_offset
unsigned long exported_symbol_count
unsigned long frag_name_length
unsigned long frag_name_offset
unsigned long old_definition_version
unsigned long old_implementation_version
unsigned long tag1
unsigned long tag2
struct bfd_pef_xlib_data_struct

Definition at line 173 of file pef.h.

Class Members
bfd_pef_xlib_header header

Define Documentation

#define BFD_PEF_BLIB_TAG2   0x424C6962 /* 'BLib' */

Definition at line 143 of file pef.h.

#define BFD_PEF_SECTION_CODE   0

Definition at line 119 of file pef.h.

#define BFD_PEF_SECTION_CONSTANT   3

Definition at line 122 of file pef.h.

#define BFD_PEF_SECTION_DEBUG   5

Definition at line 124 of file pef.h.

#define BFD_PEF_SECTION_EXCEPTION   7

Definition at line 126 of file pef.h.

#define BFD_PEF_SECTION_EXEC_DATA   6

Definition at line 125 of file pef.h.

#define BFD_PEF_SECTION_LOADER   4

Definition at line 123 of file pef.h.

Definition at line 121 of file pef.h.

#define BFD_PEF_SECTION_TRACEBACK   8

Definition at line 127 of file pef.h.

Definition at line 120 of file pef.h.

#define BFD_PEF_SHARE_GLOBAL   4

Definition at line 130 of file pef.h.

#define BFD_PEF_SHARE_PROCESS   1

Definition at line 129 of file pef.h.

#define BFD_PEF_SHARE_PROTECTED   5

Definition at line 131 of file pef.h.

#define BFD_PEF_TAG1   0x4A6F7921 /* 'Joy!' */

Definition at line 97 of file pef.h.

#define BFD_PEF_TAG2   0x70656666 /* 'peff' */

Definition at line 98 of file pef.h.

#define BFD_PEF_VERSION   0x00000001

Definition at line 100 of file pef.h.

#define BFD_PEF_VLIB_TAG2   0x564C6962 /* 'VLib' */

Definition at line 142 of file pef.h.

#define BFD_PEF_XLIB_TAG1   0xF04D6163 /* '?Mac' */

Definition at line 141 of file pef.h.

#define BFD_PEF_XLIB_VERSION   0x00000001

Definition at line 145 of file pef.h.


Typedef Documentation

Definition at line 139 of file pef.h.

Definition at line 39 of file pef.h.

Definition at line 71 of file pef.h.

Definition at line 84 of file pef.h.

Definition at line 58 of file pef.h.

Definition at line 117 of file pef.h.

Definition at line 177 of file pef.h.

Definition at line 171 of file pef.h.


Enumeration Type Documentation

Enumerator:
BFD_PEF_WEAK_IMPORT_LIB 
BFD_PEF_INIT_LIB_BEFORE 

Definition at line 73 of file pef.h.

Enumerator:
BFD_PEF_CODE_SYMBOL 
BFD_PEF_DATA_SYMBOL 
BFD_PEF_TVECTOR_SYMBOL 
BFD_PEF_TOC_SYMBOL 
BFD_PEF_GLUE_SYMBOL 
BFD_PEF_UNDEFINED_SYMBOL 
BFD_PEF_WEAK_IMPORT_SYMBOL_MASK 

Definition at line 86 of file pef.h.


Function Documentation

void bfd_pef_print_loader_header ( bfd ,
bfd_pef_loader_header ,
FILE *   
)
int bfd_pef_print_loader_section ( bfd ,
FILE *   
)

Definition at line 422 of file pef.c.

{
  bfd_pef_loader_header header;
  asection *loadersec = NULL;
  unsigned char *loaderbuf = NULL;
  size_t loaderlen = 0;

  loadersec = bfd_get_section_by_name (abfd, "loader");
  if (loadersec == NULL)
    return -1;

  loaderlen = loadersec->size;
  loaderbuf = bfd_malloc (loaderlen);

  if (bfd_seek (abfd, loadersec->filepos, SEEK_SET) < 0
      || bfd_bread ((void *) loaderbuf, loaderlen, abfd) != loaderlen
      || loaderlen < 56
      || bfd_pef_parse_loader_header (abfd, loaderbuf, 56, &header) < 0)
    {
      free (loaderbuf);
      return -1;
    }

  bfd_pef_print_loader_header (abfd, &header, file);
  return 0;
}

Here is the call graph for this function:

Definition at line 501 of file pef.c.

{
  unsigned int i;
  enum bfd_architecture cputype;
  unsigned long cpusubtype;

  mdata->header = *header;

  bfd_pef_convert_architecture (header->architecture, &cputype, &cpusubtype);
  if (cputype == bfd_arch_unknown)
    {
      fprintf (stderr, "bfd_pef_scan: unknown architecture 0x%lx\n",
              header->architecture);
      return -1;
    }
  bfd_set_arch_mach (abfd, cputype, cpusubtype);

  mdata->header = *header;

  abfd->flags = (abfd->xvec->object_flags
               | (abfd->flags & (BFD_IN_MEMORY | BFD_IO_FUNCS)));

  if (header->section_count != 0)
    {
      mdata->sections = bfd_alloc (abfd, header->section_count * sizeof (bfd_pef_section));

      if (mdata->sections == NULL)
       return -1;

      for (i = 0; i < header->section_count; i++)
       {
         bfd_pef_section *cur = &mdata->sections[i];
         cur->header_offset = 40 + (i * 28);
         if (bfd_pef_scan_section (abfd, cur) < 0)
           return -1;
       }
    }

  if (bfd_pef_scan_start_address (abfd) < 0)
    return -1;

  abfd->tdata.pef_data = mdata;

  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 369 of file pef.c.

{
  unsigned char buf[28];

  bfd_seek (abfd, section->header_offset, SEEK_SET);
  if (bfd_bread ((void *) buf, 28, abfd) != 28)
    return -1;

  section->name_offset = bfd_h_get_32 (abfd, buf);
  section->default_address = bfd_h_get_32 (abfd, buf + 4);
  section->total_length = bfd_h_get_32 (abfd, buf + 8);
  section->unpacked_length = bfd_h_get_32 (abfd, buf + 12);
  section->container_length = bfd_h_get_32 (abfd, buf + 16);
  section->container_offset = bfd_h_get_32 (abfd, buf + 20);
  section->section_kind = buf[24];
  section->share_kind = buf[25];
  section->alignment = buf[26];
  section->reserved = buf[27];

  section->bfd_section = bfd_pef_make_bfd_section (abfd, section);
  if (section->bfd_section == NULL)
    return -1;

  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 450 of file pef.c.

{
  bfd_pef_loader_header header;
  asection *section;

  asection *loadersec = NULL;
  unsigned char *loaderbuf = NULL;
  size_t loaderlen = 0;
  int ret;

  loadersec = bfd_get_section_by_name (abfd, "loader");
  if (loadersec == NULL)
    goto end;

  loaderlen = loadersec->size;
  loaderbuf = bfd_malloc (loaderlen);
  if (bfd_seek (abfd, loadersec->filepos, SEEK_SET) < 0)
    goto error;
  if (bfd_bread ((void *) loaderbuf, loaderlen, abfd) != loaderlen)
    goto error;

  if (loaderlen < 56)
    goto error;
  ret = bfd_pef_parse_loader_header (abfd, loaderbuf, 56, &header);
  if (ret < 0)
    goto error;

  if (header.main_section < 0)
    goto end;

  for (section = abfd->sections; section != NULL; section = section->next)
    if ((section->index + 1) == header.main_section)
      break;

  if (section == NULL)
    goto error;

  abfd->start_address = section->vma + header.main_offset;

 end:
  if (loaderbuf != NULL)
    free (loaderbuf);
  return 0;

 error:
  if (loaderbuf != NULL)
    free (loaderbuf);
  return -1;
}

Here is the call graph for this function:

Here is the caller graph for this function: