Back to index

cell-binutils  2.17cvs20070401
pef.h
Go to the documentation of this file.
00001 /* PEF support for BFD.
00002    Copyright 1999, 2000, 2001, 2002
00003    Free Software Foundation, Inc.
00004 
00005    This file is part of BFD, the Binary File Descriptor library.
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 2 of the License, or
00010    (at your option) any later version.
00011 
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with this program; if not, write to the Free Software
00019    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
00020 
00021 #include "bfd.h"
00022 
00023 #include <stdio.h>
00024 
00025 struct bfd_pef_header
00026 {
00027   unsigned long tag1;
00028   unsigned long tag2;
00029   unsigned long architecture;
00030   unsigned long format_version;
00031   unsigned long timestamp;
00032   unsigned long old_definition_version;
00033   unsigned long old_implementation_version;
00034   unsigned long current_version;
00035   unsigned short section_count;
00036   unsigned short instantiated_section_count;
00037   unsigned long reserved;
00038 };
00039 typedef struct bfd_pef_header bfd_pef_header;
00040 
00041 struct bfd_pef_loader_header
00042 {
00043   long main_section;
00044   unsigned long main_offset;
00045   long init_section;
00046   unsigned long init_offset;
00047   long term_section;
00048   unsigned long term_offset;
00049   unsigned long imported_library_count;
00050   unsigned long total_imported_symbol_count;
00051   unsigned long reloc_section_count;
00052   unsigned long reloc_instr_offset;
00053   unsigned long loader_strings_offset;
00054   unsigned long export_hash_offset;
00055   unsigned long export_hash_table_power;
00056   unsigned long exported_symbol_count;
00057 };
00058 typedef struct bfd_pef_loader_header bfd_pef_loader_header;
00059 
00060 struct bfd_pef_imported_library
00061 {
00062   unsigned long name_offset;
00063   unsigned long old_implementation_version;
00064   unsigned long current_version;
00065   unsigned long imported_symbol_count;
00066   unsigned long first_imported_symbol;
00067   unsigned char options;
00068   unsigned char reserved_a;
00069   unsigned short reserved_b;
00070 };
00071 typedef struct bfd_pef_imported_library bfd_pef_imported_library;
00072 
00073 enum bfd_pef_imported_library_options
00074   {
00075     BFD_PEF_WEAK_IMPORT_LIB = 0x40,
00076     BFD_PEF_INIT_LIB_BEFORE = 0x80
00077   };
00078 
00079 struct bfd_pef_imported_symbol
00080 {
00081   unsigned char class;
00082   unsigned long name;
00083 };
00084 typedef struct bfd_pef_imported_symbol bfd_pef_imported_symbol;
00085 
00086 enum bfd_pef_imported_symbol_class
00087   {
00088     BFD_PEF_CODE_SYMBOL = 0x00,
00089     BFD_PEF_DATA_SYMBOL = 0x01,
00090     BFD_PEF_TVECTOR_SYMBOL = 0x02,
00091     BFD_PEF_TOC_SYMBOL = 0x03,
00092     BFD_PEF_GLUE_SYMBOL = 0x04,
00093     BFD_PEF_UNDEFINED_SYMBOL = 0x0F,
00094     BFD_PEF_WEAK_IMPORT_SYMBOL_MASK = 0x80
00095   };
00096 
00097 #define BFD_PEF_TAG1 0x4A6F7921 /* 'Joy!' */
00098 #define BFD_PEF_TAG2 0x70656666 /* 'peff' */
00099 
00100 #define BFD_PEF_VERSION 0x00000001
00101 
00102 struct bfd_pef_section
00103 {
00104   long name_offset;
00105   unsigned long header_offset;
00106   unsigned long default_address;
00107   unsigned long total_length;
00108   unsigned long unpacked_length;
00109   unsigned long container_length;
00110   unsigned long container_offset;
00111   unsigned char section_kind;
00112   unsigned char share_kind;
00113   unsigned char alignment;
00114   unsigned char reserved;
00115   asection *bfd_section;
00116 };
00117 typedef struct bfd_pef_section bfd_pef_section;
00118 
00119 #define BFD_PEF_SECTION_CODE 0
00120 #define BFD_PEF_SECTION_UNPACKED_DATA 1
00121 #define BFD_PEF_SECTION_PACKED_DATA 2
00122 #define BFD_PEF_SECTION_CONSTANT 3
00123 #define BFD_PEF_SECTION_LOADER 4
00124 #define BFD_PEF_SECTION_DEBUG 5
00125 #define BFD_PEF_SECTION_EXEC_DATA 6
00126 #define BFD_PEF_SECTION_EXCEPTION 7
00127 #define BFD_PEF_SECTION_TRACEBACK 8
00128 
00129 #define BFD_PEF_SHARE_PROCESS 1
00130 #define BFD_PEF_SHARE_GLOBAL 4
00131 #define BFD_PEF_SHARE_PROTECTED 5
00132 
00133 struct bfd_pef_data_struct
00134 {
00135   bfd_pef_header header;
00136   bfd_pef_section *sections;
00137   bfd *ibfd;
00138 };
00139 typedef struct bfd_pef_data_struct bfd_pef_data_struct;
00140 
00141 #define BFD_PEF_XLIB_TAG1 0xF04D6163 /* '?Mac' */
00142 #define BFD_PEF_VLIB_TAG2 0x564C6962 /* 'VLib' */
00143 #define BFD_PEF_BLIB_TAG2 0x424C6962 /* 'BLib' */
00144 
00145 #define BFD_PEF_XLIB_VERSION 0x00000001
00146 
00147 struct bfd_pef_xlib_header
00148 {
00149   unsigned long tag1;
00150   unsigned long tag2;
00151   unsigned long current_format;
00152   unsigned long container_strings_offset;
00153   unsigned long export_hash_offset;
00154   unsigned long export_key_offset;
00155   unsigned long export_symbol_offset;
00156   unsigned long export_names_offset;
00157   unsigned long export_hash_table_power;
00158   unsigned long exported_symbol_count;
00159 
00160   unsigned long frag_name_offset;
00161   unsigned long frag_name_length;
00162   unsigned long dylib_path_offset;
00163   unsigned long dylib_path_length;
00164   unsigned long cpu_family;
00165   unsigned long cpu_model;
00166   unsigned long date_time_stamp;
00167   unsigned long current_version;
00168   unsigned long old_definition_version;
00169   unsigned long old_implementation_version;
00170 };
00171 typedef struct bfd_pef_xlib_header bfd_pef_xlib_header;
00172 
00173 struct bfd_pef_xlib_data_struct
00174 {
00175   bfd_pef_xlib_header header;
00176 };
00177 typedef struct bfd_pef_xlib_data_struct bfd_pef_xlib_data_struct;
00178 
00179 int  bfd_pef_parse_loader_header    (bfd *, unsigned char *, size_t, bfd_pef_loader_header *);
00180 int  bfd_pef_print_loader_section   (bfd *, FILE *);
00181 void bfd_pef_print_loader_header    (bfd *, bfd_pef_loader_header *, FILE *);
00182 int  bfd_pef_parse_imported_library (bfd *, unsigned char *, size_t, bfd_pef_imported_library *);
00183 int  bfd_pef_parse_imported_symbol  (bfd *, unsigned char *, size_t, bfd_pef_imported_symbol *);
00184 int  bfd_pef_scan_section           (bfd *, bfd_pef_section *);
00185 int  bfd_pef_scan_start_address     (bfd *);
00186 int  bfd_pef_scan                   (bfd *, bfd_pef_header *, bfd_pef_data_struct *);