bfd/
[binutils.git] / bfd / pef.h
bloba559cf10aa992e678d63a6b07584631f541cb704
1 /* PEF support for BFD.
2 Copyright 1999, 2000, 2001, 2002
3 Free Software Foundation, Inc.
5 This file is part of BFD, the Binary File Descriptor library.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
21 #include "bfd.h"
23 #include <stdio.h>
25 struct bfd_pef_header
27 unsigned long tag1;
28 unsigned long tag2;
29 unsigned long architecture;
30 unsigned long format_version;
31 unsigned long timestamp;
32 unsigned long old_definition_version;
33 unsigned long old_implementation_version;
34 unsigned long current_version;
35 unsigned short section_count;
36 unsigned short instantiated_section_count;
37 unsigned long reserved;
39 typedef struct bfd_pef_header bfd_pef_header;
41 struct bfd_pef_loader_header
43 long main_section;
44 unsigned long main_offset;
45 long init_section;
46 unsigned long init_offset;
47 long term_section;
48 unsigned long term_offset;
49 unsigned long imported_library_count;
50 unsigned long total_imported_symbol_count;
51 unsigned long reloc_section_count;
52 unsigned long reloc_instr_offset;
53 unsigned long loader_strings_offset;
54 unsigned long export_hash_offset;
55 unsigned long export_hash_table_power;
56 unsigned long exported_symbol_count;
58 typedef struct bfd_pef_loader_header bfd_pef_loader_header;
60 struct bfd_pef_imported_library
62 unsigned long name_offset;
63 unsigned long old_implementation_version;
64 unsigned long current_version;
65 unsigned long imported_symbol_count;
66 unsigned long first_imported_symbol;
67 unsigned char options;
68 unsigned char reserved_a;
69 unsigned short reserved_b;
71 typedef struct bfd_pef_imported_library bfd_pef_imported_library;
73 enum bfd_pef_imported_library_options
75 BFD_PEF_WEAK_IMPORT_LIB = 0x40,
76 BFD_PEF_INIT_LIB_BEFORE = 0x80
79 struct bfd_pef_imported_symbol
81 unsigned char class;
82 unsigned long name;
84 typedef struct bfd_pef_imported_symbol bfd_pef_imported_symbol;
86 enum bfd_pef_imported_symbol_class
88 BFD_PEF_CODE_SYMBOL = 0x00,
89 BFD_PEF_DATA_SYMBOL = 0x01,
90 BFD_PEF_TVECTOR_SYMBOL = 0x02,
91 BFD_PEF_TOC_SYMBOL = 0x03,
92 BFD_PEF_GLUE_SYMBOL = 0x04,
93 BFD_PEF_UNDEFINED_SYMBOL = 0x0F,
94 BFD_PEF_WEAK_IMPORT_SYMBOL_MASK = 0x80
97 #define BFD_PEF_TAG1 0x4A6F7921 /* 'Joy!' */
98 #define BFD_PEF_TAG2 0x70656666 /* 'peff' */
100 #define BFD_PEF_VERSION 0x00000001
102 struct bfd_pef_section
104 long name_offset;
105 unsigned long header_offset;
106 unsigned long default_address;
107 unsigned long total_length;
108 unsigned long unpacked_length;
109 unsigned long container_length;
110 unsigned long container_offset;
111 unsigned char section_kind;
112 unsigned char share_kind;
113 unsigned char alignment;
114 unsigned char reserved;
115 asection *bfd_section;
117 typedef struct bfd_pef_section bfd_pef_section;
119 #define BFD_PEF_SECTION_CODE 0
120 #define BFD_PEF_SECTION_UNPACKED_DATA 1
121 #define BFD_PEF_SECTION_PACKED_DATA 2
122 #define BFD_PEF_SECTION_CONSTANT 3
123 #define BFD_PEF_SECTION_LOADER 4
124 #define BFD_PEF_SECTION_DEBUG 5
125 #define BFD_PEF_SECTION_EXEC_DATA 6
126 #define BFD_PEF_SECTION_EXCEPTION 7
127 #define BFD_PEF_SECTION_TRACEBACK 8
129 #define BFD_PEF_SHARE_PROCESS 1
130 #define BFD_PEF_SHARE_GLOBAL 4
131 #define BFD_PEF_SHARE_PROTECTED 5
133 struct bfd_pef_data_struct
135 bfd_pef_header header;
136 bfd_pef_section *sections;
137 bfd *ibfd;
139 typedef struct bfd_pef_data_struct bfd_pef_data_struct;
141 #define BFD_PEF_XLIB_TAG1 0xF04D6163 /* '?Mac' */
142 #define BFD_PEF_VLIB_TAG2 0x564C6962 /* 'VLib' */
143 #define BFD_PEF_BLIB_TAG2 0x424C6962 /* 'BLib' */
145 #define BFD_PEF_XLIB_VERSION 0x00000001
147 struct bfd_pef_xlib_header
149 unsigned long tag1;
150 unsigned long tag2;
151 unsigned long current_format;
152 unsigned long container_strings_offset;
153 unsigned long export_hash_offset;
154 unsigned long export_key_offset;
155 unsigned long export_symbol_offset;
156 unsigned long export_names_offset;
157 unsigned long export_hash_table_power;
158 unsigned long exported_symbol_count;
160 unsigned long frag_name_offset;
161 unsigned long frag_name_length;
162 unsigned long dylib_path_offset;
163 unsigned long dylib_path_length;
164 unsigned long cpu_family;
165 unsigned long cpu_model;
166 unsigned long date_time_stamp;
167 unsigned long current_version;
168 unsigned long old_definition_version;
169 unsigned long old_implementation_version;
171 typedef struct bfd_pef_xlib_header bfd_pef_xlib_header;
173 struct bfd_pef_xlib_data_struct
175 bfd_pef_xlib_header header;
177 typedef struct bfd_pef_xlib_data_struct bfd_pef_xlib_data_struct;
179 int bfd_pef_parse_loader_header (bfd *, unsigned char *, size_t, bfd_pef_loader_header *);
180 int bfd_pef_print_loader_section (bfd *, FILE *);
181 void bfd_pef_print_loader_header (bfd *, bfd_pef_loader_header *, FILE *);
182 int bfd_pef_parse_imported_library (bfd *, unsigned char *, size_t, bfd_pef_imported_library *);
183 int bfd_pef_parse_imported_symbol (bfd *, unsigned char *, size_t, bfd_pef_imported_symbol *);
184 int bfd_pef_scan_section (bfd *, bfd_pef_section *);
185 int bfd_pef_scan_start_address (bfd *);
186 int bfd_pef_scan (bfd *, bfd_pef_header *, bfd_pef_data_struct *);