Commit | Line | Data |
---|---|---|
3af9a47b | 1 | /* xSYM symbol-file support for BFD. |
f075ee0c | 2 | Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005 |
3af9a47b NC |
3 | Free Software Foundation, Inc. |
4 | ||
5 | This file is part of BFD, the Binary File Descriptor library. | |
6 | ||
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. | |
11 | ||
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. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
e84d6fca | 18 | along with this program; if not, write to the Free Software |
3af9a47b NC |
19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
20 | ||
21 | #include "xsym.h" | |
22 | #include "bfd.h" | |
23 | #include "sysdep.h" | |
24 | #include "libbfd.h" | |
25 | ||
26 | #define bfd_sym_close_and_cleanup _bfd_generic_close_and_cleanup | |
27 | #define bfd_sym_bfd_free_cached_info _bfd_generic_bfd_free_cached_info | |
28 | #define bfd_sym_new_section_hook _bfd_generic_new_section_hook | |
29 | #define bfd_sym_bfd_is_local_label_name bfd_generic_is_local_label_name | |
3c9458e9 | 30 | #define bfd_sym_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false) |
3af9a47b NC |
31 | #define bfd_sym_get_lineno _bfd_nosymbols_get_lineno |
32 | #define bfd_sym_find_nearest_line _bfd_nosymbols_find_nearest_line | |
33 | #define bfd_sym_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol | |
34 | #define bfd_sym_read_minisymbols _bfd_generic_read_minisymbols | |
35 | #define bfd_sym_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol | |
36 | #define bfd_sym_get_reloc_upper_bound _bfd_norelocs_get_reloc_upper_bound | |
37 | #define bfd_sym_canonicalize_reloc _bfd_norelocs_canonicalize_reloc | |
38 | #define bfd_sym_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup | |
39 | #define bfd_sym_set_arch_mach _bfd_generic_set_arch_mach | |
40 | #define bfd_sym_get_section_contents _bfd_generic_get_section_contents | |
41 | #define bfd_sym_set_section_contents _bfd_generic_set_section_contents | |
42 | #define bfd_sym_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents | |
43 | #define bfd_sym_bfd_relax_section bfd_generic_relax_section | |
44 | #define bfd_sym_bfd_gc_sections bfd_generic_gc_sections | |
45 | #define bfd_sym_bfd_merge_sections bfd_generic_merge_sections | |
72adc230 | 46 | #define bfd_sym_bfd_is_group_section bfd_generic_is_group_section |
3af9a47b | 47 | #define bfd_sym_bfd_discard_group bfd_generic_discard_group |
082b7297 L |
48 | #define bfd_sym_section_already_linked \ |
49 | _bfd_generic_section_already_linked | |
3af9a47b NC |
50 | #define bfd_sym_bfd_link_hash_table_create _bfd_generic_link_hash_table_create |
51 | #define bfd_sym_bfd_link_hash_table_free _bfd_generic_link_hash_table_free | |
52 | #define bfd_sym_bfd_link_add_symbols _bfd_generic_link_add_symbols | |
53 | #define bfd_sym_bfd_link_just_syms _bfd_generic_link_just_syms | |
54 | #define bfd_sym_bfd_final_link _bfd_generic_final_link | |
55 | #define bfd_sym_bfd_link_split_section _bfd_generic_link_split_section | |
56 | #define bfd_sym_get_section_contents_in_window _bfd_generic_get_section_contents_in_window | |
57 | ||
3af9a47b NC |
58 | static unsigned long compute_offset |
59 | PARAMS ((unsigned long, unsigned long, unsigned long, unsigned long)); | |
60 | ||
61 | extern const bfd_target sym_vec; | |
62 | ||
63 | static int | |
f075ee0c | 64 | pstrcmp (const char *as, const char *bs) |
3af9a47b | 65 | { |
f075ee0c AM |
66 | const unsigned char *a = (const unsigned char *) as; |
67 | const unsigned char *b = (const unsigned char *) bs; | |
3af9a47b NC |
68 | unsigned char clen; |
69 | int ret; | |
70 | ||
f075ee0c | 71 | clen = (a[0] > b[0]) ? b[0] : a[0]; |
3af9a47b NC |
72 | ret = memcmp (a + 1, b + 1, clen); |
73 | if (ret != 0) | |
74 | return ret; | |
75 | ||
76 | if (a[0] == b[0]) | |
77 | return 0; | |
78 | else if (a[0] < b[0]) | |
79 | return -1; | |
80 | else | |
f075ee0c | 81 | return 1; |
3af9a47b NC |
82 | } |
83 | ||
84 | static unsigned long | |
85 | compute_offset (first_page, page_size, entry_size, index) | |
86 | unsigned long first_page; | |
87 | unsigned long page_size; | |
88 | unsigned long entry_size; | |
89 | unsigned long index; | |
90 | { | |
91 | unsigned long entries_per_page = page_size / entry_size; | |
92 | unsigned long page_number = first_page + (index / entries_per_page); | |
93 | unsigned long page_offset = (index % entries_per_page) * entry_size; | |
94 | ||
95 | return (page_number * page_size) + page_offset; | |
96 | } | |
97 | ||
b34976b6 | 98 | bfd_boolean |
3af9a47b NC |
99 | bfd_sym_mkobject (abfd) |
100 | bfd *abfd ATTRIBUTE_UNUSED; | |
101 | { | |
b34976b6 | 102 | return 1; |
3af9a47b NC |
103 | } |
104 | ||
105 | void | |
106 | bfd_sym_print_symbol (abfd, afile, symbol, how) | |
107 | bfd *abfd ATTRIBUTE_UNUSED; | |
108 | PTR afile ATTRIBUTE_UNUSED; | |
109 | asymbol *symbol ATTRIBUTE_UNUSED; | |
110 | bfd_print_symbol_type how ATTRIBUTE_UNUSED; | |
111 | { | |
112 | return; | |
113 | } | |
114 | ||
b34976b6 | 115 | bfd_boolean |
3af9a47b NC |
116 | bfd_sym_valid (abfd) |
117 | bfd *abfd; | |
118 | { | |
119 | if (abfd == NULL || abfd->xvec == NULL) | |
120 | return 0; | |
121 | ||
e84d6fca | 122 | return abfd->xvec == &sym_vec; |
3af9a47b NC |
123 | } |
124 | ||
125 | unsigned char * | |
126 | bfd_sym_read_name_table (abfd, dshb) | |
127 | bfd *abfd; | |
128 | bfd_sym_header_block *dshb; | |
129 | { | |
130 | unsigned char *rstr; | |
131 | long ret; | |
132 | size_t table_size = dshb->dshb_nte.dti_page_count * dshb->dshb_page_size; | |
133 | size_t table_offset = dshb->dshb_nte.dti_first_page * dshb->dshb_page_size; | |
e84d6fca | 134 | |
3af9a47b NC |
135 | rstr = (unsigned char *) bfd_alloc (abfd, table_size); |
136 | if (rstr == NULL) | |
137 | return rstr; | |
138 | ||
139 | bfd_seek (abfd, table_offset, SEEK_SET); | |
140 | ret = bfd_bread (rstr, table_size, abfd); | |
e84d6fca | 141 | if (ret < 0 || (unsigned long) ret != table_size) |
3af9a47b NC |
142 | { |
143 | bfd_release (abfd, rstr); | |
144 | return NULL; | |
145 | } | |
e84d6fca | 146 | |
3af9a47b NC |
147 | return rstr; |
148 | } | |
149 | ||
150 | void | |
151 | bfd_sym_parse_file_reference_v32 (buf, len, entry) | |
152 | unsigned char *buf; | |
153 | size_t len; | |
154 | bfd_sym_file_reference *entry; | |
155 | { | |
156 | BFD_ASSERT (len == 6); | |
157 | ||
158 | entry->fref_frte_index = bfd_getb16 (buf); | |
159 | entry->fref_offset = bfd_getb32 (buf + 2); | |
160 | } | |
161 | ||
162 | void | |
163 | bfd_sym_parse_disk_table_v32 (buf, len, table) | |
164 | unsigned char *buf; | |
165 | size_t len; | |
166 | bfd_sym_table_info *table; | |
167 | { | |
168 | BFD_ASSERT (len == 8); | |
e84d6fca | 169 | |
3af9a47b NC |
170 | table->dti_first_page = bfd_getb16 (buf); |
171 | table->dti_page_count = bfd_getb16 (buf + 2); | |
172 | table->dti_object_count = bfd_getb32 (buf + 4); | |
e84d6fca | 173 | } |
3af9a47b NC |
174 | |
175 | void | |
176 | bfd_sym_parse_header_v32 (buf, len, header) | |
177 | unsigned char *buf; | |
178 | size_t len; | |
179 | bfd_sym_header_block *header; | |
180 | { | |
181 | BFD_ASSERT (len == 154); | |
e84d6fca | 182 | |
3af9a47b NC |
183 | memcpy (header->dshb_id, buf, 32); |
184 | header->dshb_page_size = bfd_getb16 (buf + 32); | |
185 | header->dshb_hash_page = bfd_getb16 (buf + 34); | |
186 | header->dshb_root_mte = bfd_getb16 (buf + 36); | |
187 | header->dshb_mod_date = bfd_getb32 (buf + 38); | |
e84d6fca | 188 | |
3af9a47b NC |
189 | bfd_sym_parse_disk_table_v32 (buf + 42, 8, &header->dshb_frte); |
190 | bfd_sym_parse_disk_table_v32 (buf + 50, 8, &header->dshb_rte); | |
191 | bfd_sym_parse_disk_table_v32 (buf + 58, 8, &header->dshb_mte); | |
192 | bfd_sym_parse_disk_table_v32 (buf + 66, 8, &header->dshb_cmte); | |
193 | bfd_sym_parse_disk_table_v32 (buf + 74, 8, &header->dshb_cvte); | |
194 | bfd_sym_parse_disk_table_v32 (buf + 82, 8, &header->dshb_csnte); | |
195 | bfd_sym_parse_disk_table_v32 (buf + 90, 8, &header->dshb_clte); | |
196 | bfd_sym_parse_disk_table_v32 (buf + 98, 8, &header->dshb_ctte); | |
197 | bfd_sym_parse_disk_table_v32 (buf + 106, 8, &header->dshb_tte); | |
198 | bfd_sym_parse_disk_table_v32 (buf + 114, 8, &header->dshb_nte); | |
199 | bfd_sym_parse_disk_table_v32 (buf + 122, 8, &header->dshb_tinfo); | |
200 | bfd_sym_parse_disk_table_v32 (buf + 130, 8, &header->dshb_fite); | |
201 | bfd_sym_parse_disk_table_v32 (buf + 138, 8, &header->dshb_const); | |
e84d6fca | 202 | |
3af9a47b NC |
203 | memcpy (&header->dshb_file_creator, buf + 146, 4); |
204 | memcpy (&header->dshb_file_type, buf + 150, 4); | |
205 | } | |
206 | ||
207 | int | |
208 | bfd_sym_read_header_v32 (abfd, header) | |
209 | bfd *abfd; | |
210 | bfd_sym_header_block *header; | |
211 | { | |
212 | unsigned char buf[154]; | |
213 | long ret; | |
e84d6fca | 214 | |
3af9a47b NC |
215 | ret = bfd_bread (buf, 154, abfd); |
216 | if (ret != 154) | |
217 | return -1; | |
e84d6fca | 218 | |
3af9a47b | 219 | bfd_sym_parse_header_v32 (buf, 154, header); |
e84d6fca | 220 | |
3af9a47b NC |
221 | return 0; |
222 | } | |
223 | ||
224 | int | |
225 | bfd_sym_read_header_v34 (abfd, header) | |
226 | bfd *abfd ATTRIBUTE_UNUSED; | |
227 | bfd_sym_header_block *header ATTRIBUTE_UNUSED; | |
228 | { | |
229 | abort (); | |
230 | } | |
231 | ||
232 | int | |
233 | bfd_sym_read_header (abfd, header, version) | |
234 | bfd *abfd; | |
235 | bfd_sym_header_block *header; | |
236 | bfd_sym_version version; | |
237 | { | |
238 | switch (version) | |
239 | { | |
240 | case BFD_SYM_VERSION_3_5: | |
241 | case BFD_SYM_VERSION_3_4: | |
242 | return bfd_sym_read_header_v34 (abfd, header); | |
243 | case BFD_SYM_VERSION_3_3: | |
244 | case BFD_SYM_VERSION_3_2: | |
245 | return bfd_sym_read_header_v32 (abfd, header); | |
246 | case BFD_SYM_VERSION_3_1: | |
247 | default: | |
b34976b6 | 248 | return FALSE; |
3af9a47b NC |
249 | } |
250 | } | |
251 | ||
252 | int | |
253 | bfd_sym_read_version (abfd, version) | |
254 | bfd *abfd; | |
255 | bfd_sym_version *version; | |
256 | { | |
f075ee0c | 257 | char version_string[32]; |
3af9a47b | 258 | long ret; |
e84d6fca | 259 | |
3af9a47b NC |
260 | ret = bfd_bread (version_string, sizeof (version_string), abfd); |
261 | if (ret != sizeof (version_string)) | |
262 | return -1; | |
e84d6fca | 263 | |
3af9a47b NC |
264 | if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_1) == 0) |
265 | *version = BFD_SYM_VERSION_3_1; | |
266 | else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_2) == 0) | |
267 | *version = BFD_SYM_VERSION_3_2; | |
268 | else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_3) == 0) | |
269 | *version = BFD_SYM_VERSION_3_3; | |
270 | else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_4) == 0) | |
271 | *version = BFD_SYM_VERSION_3_4; | |
272 | else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_5) == 0) | |
273 | *version = BFD_SYM_VERSION_3_5; | |
274 | else | |
275 | return -1; | |
e84d6fca | 276 | |
3af9a47b NC |
277 | return 0; |
278 | } | |
279 | ||
280 | void | |
281 | bfd_sym_display_table_summary (f, dti, name) | |
282 | FILE *f; | |
283 | bfd_sym_table_info *dti; | |
284 | const char *name; | |
285 | { | |
286 | fprintf (f, "%-6s %13ld %13ld %13ld\n", | |
287 | name, | |
288 | dti->dti_first_page, | |
289 | dti->dti_page_count, | |
290 | dti->dti_object_count); | |
291 | } | |
292 | ||
293 | void | |
294 | bfd_sym_display_header (f, dshb) | |
295 | FILE *f; | |
296 | bfd_sym_header_block *dshb; | |
297 | { | |
298 | fprintf (f, " Version: %.*s\n", dshb->dshb_id[0], dshb->dshb_id + 1); | |
299 | fprintf (f, " Page Size: 0x%x\n", dshb->dshb_page_size); | |
300 | fprintf (f, " Hash Page: %lu\n", dshb->dshb_hash_page); | |
301 | fprintf (f, " Root MTE: %lu\n", dshb->dshb_root_mte); | |
302 | fprintf (f, " Modification Date: "); | |
303 | fprintf (f, "[unimplemented]"); | |
304 | fprintf (f, " (0x%lx)\n", dshb->dshb_mod_date); | |
305 | ||
306 | fprintf (f, " File Creator: %.4s Type: %.4s\n\n", | |
307 | dshb->dshb_file_creator, dshb->dshb_file_type); | |
e84d6fca | 308 | |
3af9a47b NC |
309 | fprintf (f, "Table Name First Page Page Count Object Count\n"); |
310 | fprintf (f, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"); | |
e84d6fca | 311 | |
3af9a47b NC |
312 | bfd_sym_display_table_summary (f, &dshb->dshb_nte, "NTE"); |
313 | bfd_sym_display_table_summary (f, &dshb->dshb_rte, "RTE"); | |
314 | bfd_sym_display_table_summary (f, &dshb->dshb_mte, "MTE"); | |
315 | bfd_sym_display_table_summary (f, &dshb->dshb_frte, "FRTE"); | |
316 | bfd_sym_display_table_summary (f, &dshb->dshb_cmte, "CMTE"); | |
317 | bfd_sym_display_table_summary (f, &dshb->dshb_cvte, "CVTE"); | |
318 | bfd_sym_display_table_summary (f, &dshb->dshb_csnte, "CSNTE"); | |
319 | bfd_sym_display_table_summary (f, &dshb->dshb_clte, "CLTE"); | |
320 | bfd_sym_display_table_summary (f, &dshb->dshb_ctte, "CTTE"); | |
321 | bfd_sym_display_table_summary (f, &dshb->dshb_tte, "TTE"); | |
322 | bfd_sym_display_table_summary (f, &dshb->dshb_tinfo, "TINFO"); | |
323 | bfd_sym_display_table_summary (f, &dshb->dshb_fite, "FITE"); | |
324 | bfd_sym_display_table_summary (f, &dshb->dshb_const, "CONST"); | |
e84d6fca | 325 | |
3af9a47b NC |
326 | fprintf (f, "\n"); |
327 | } | |
328 | ||
329 | void | |
330 | bfd_sym_parse_resources_table_entry_v32 (buf, len, entry) | |
331 | unsigned char *buf; | |
332 | size_t len; | |
333 | bfd_sym_resources_table_entry *entry; | |
334 | { | |
335 | BFD_ASSERT (len == 18); | |
336 | ||
337 | memcpy (&entry->rte_res_type, buf, 4); | |
338 | entry->rte_res_number = bfd_getb16 (buf + 4); | |
339 | entry->rte_nte_index = bfd_getb32 (buf + 6); | |
340 | entry->rte_mte_first = bfd_getb16 (buf + 10); | |
341 | entry->rte_mte_last = bfd_getb16 (buf + 12); | |
342 | entry->rte_res_size = bfd_getb32 (buf + 14); | |
343 | } | |
344 | ||
345 | void | |
346 | bfd_sym_parse_modules_table_entry_v33 (buf, len, entry) | |
347 | unsigned char *buf; | |
348 | size_t len; | |
349 | bfd_sym_modules_table_entry *entry; | |
350 | { | |
351 | BFD_ASSERT (len == 46); | |
352 | ||
353 | entry->mte_rte_index = bfd_getb16 (buf); | |
354 | entry->mte_res_offset = bfd_getb32 (buf + 2); | |
355 | entry->mte_size = bfd_getb32 (buf + 6); | |
356 | entry->mte_kind = buf[10]; | |
357 | entry->mte_scope = buf[11]; | |
358 | entry->mte_parent = bfd_getb16 (buf + 12); | |
359 | bfd_sym_parse_file_reference_v32 (buf + 14, 6, &entry->mte_imp_fref); | |
360 | entry->mte_imp_end = bfd_getb32 (buf + 20); | |
361 | entry->mte_nte_index = bfd_getb32 (buf + 24); | |
362 | entry->mte_cmte_index = bfd_getb16 (buf + 28); | |
363 | entry->mte_cvte_index = bfd_getb32 (buf + 30); | |
364 | entry->mte_clte_index = bfd_getb16 (buf + 34); | |
365 | entry->mte_ctte_index = bfd_getb16 (buf + 36); | |
366 | entry->mte_csnte_idx_1 = bfd_getb32 (buf + 38); | |
367 | entry->mte_csnte_idx_2 = bfd_getb32 (buf + 42); | |
368 | } | |
369 | ||
370 | void | |
371 | bfd_sym_parse_file_references_table_entry_v32 (buf, len, entry) | |
372 | unsigned char *buf; | |
373 | size_t len; | |
374 | bfd_sym_file_references_table_entry *entry; | |
375 | { | |
376 | unsigned int type; | |
e84d6fca | 377 | |
3af9a47b NC |
378 | BFD_ASSERT (len == 10); |
379 | ||
380 | memset (entry, 0, sizeof (bfd_sym_file_references_table_entry)); | |
381 | type = bfd_getb16 (buf); | |
382 | ||
383 | switch (type) | |
384 | { | |
385 | case BFD_SYM_END_OF_LIST_3_2: | |
386 | entry->generic.type = BFD_SYM_END_OF_LIST; | |
387 | break; | |
388 | ||
389 | case BFD_SYM_FILE_NAME_INDEX_3_2: | |
390 | entry->filename.type = BFD_SYM_FILE_NAME_INDEX; | |
391 | entry->filename.nte_index = bfd_getb32 (buf + 2); | |
392 | entry->filename.mod_date = bfd_getb32 (buf + 6); | |
393 | break; | |
394 | ||
395 | default: | |
396 | entry->entry.mte_index = type; | |
397 | entry->entry.file_offset = bfd_getb32 (buf + 2); | |
398 | } | |
399 | } | |
400 | ||
401 | void | |
402 | bfd_sym_parse_contained_modules_table_entry_v32 (buf, len, entry) | |
403 | unsigned char *buf; | |
404 | size_t len; | |
405 | bfd_sym_contained_modules_table_entry *entry; | |
406 | { | |
407 | unsigned int type; | |
408 | ||
409 | BFD_ASSERT (len == 6); | |
410 | ||
411 | memset (entry, 0, sizeof (bfd_sym_contained_modules_table_entry)); | |
412 | type = bfd_getb16 (buf); | |
e84d6fca | 413 | |
3af9a47b NC |
414 | switch (type) |
415 | { | |
416 | case BFD_SYM_END_OF_LIST_3_2: | |
417 | entry->generic.type = BFD_SYM_END_OF_LIST; | |
418 | break; | |
419 | ||
420 | default: | |
421 | entry->entry.mte_index = type; | |
422 | entry->entry.nte_index = bfd_getb32 (buf + 2); | |
423 | break; | |
424 | } | |
425 | } | |
426 | ||
427 | void | |
428 | bfd_sym_parse_contained_variables_table_entry_v32 (buf, len, entry) | |
429 | unsigned char *buf; | |
430 | size_t len; | |
431 | bfd_sym_contained_variables_table_entry *entry; | |
432 | { | |
433 | unsigned int type; | |
e84d6fca | 434 | |
3af9a47b NC |
435 | BFD_ASSERT (len == 26); |
436 | ||
437 | memset (entry, 0, sizeof (bfd_sym_contained_variables_table_entry)); | |
438 | type = bfd_getb16 (buf); | |
439 | ||
440 | switch (type) | |
441 | { | |
442 | case BFD_SYM_END_OF_LIST_3_2: | |
443 | entry->generic.type = BFD_SYM_END_OF_LIST; | |
444 | break; | |
445 | ||
446 | case BFD_SYM_SOURCE_FILE_CHANGE_3_2: | |
447 | entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE; | |
448 | bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref); | |
449 | break; | |
450 | ||
451 | default: | |
452 | entry->entry.tte_index = type; | |
453 | entry->entry.nte_index = bfd_getb32 (buf + 2); | |
454 | entry->entry.file_delta = bfd_getb16 (buf + 6); | |
455 | entry->entry.scope = buf[8]; | |
456 | entry->entry.la_size = buf[9]; | |
457 | ||
458 | if (entry->entry.la_size == BFD_SYM_CVTE_SCA) | |
459 | { | |
460 | entry->entry.address.scstruct.sca_kind = buf[10]; | |
461 | entry->entry.address.scstruct.sca_class = buf[11]; | |
462 | entry->entry.address.scstruct.sca_offset = bfd_getb32 (buf + 12); | |
463 | } | |
464 | else if (entry->entry.la_size <= BFD_SYM_CVTE_SCA) | |
465 | { | |
169a6afd | 466 | #if BFD_SYM_CVTE_SCA > 0 |
3af9a47b | 467 | memcpy (&entry->entry.address.lastruct.la, buf + 10, BFD_SYM_CVTE_SCA); |
169a6afd | 468 | #endif |
3af9a47b NC |
469 | entry->entry.address.lastruct.la_kind = buf[23]; |
470 | } | |
471 | else if (entry->entry.la_size == BFD_SYM_CVTE_BIG_LA) | |
472 | { | |
473 | entry->entry.address.biglastruct.big_la = bfd_getb32 (buf + 10); | |
474 | entry->entry.address.biglastruct.big_la_kind = buf[12]; | |
475 | } | |
476 | } | |
477 | } | |
478 | ||
479 | void | |
480 | bfd_sym_parse_contained_statements_table_entry_v32 (buf, len, entry) | |
481 | unsigned char *buf; | |
482 | size_t len; | |
483 | bfd_sym_contained_statements_table_entry *entry; | |
484 | { | |
485 | unsigned int type; | |
486 | ||
487 | BFD_ASSERT (len == 8); | |
488 | ||
489 | memset (entry, 0, sizeof (bfd_sym_contained_statements_table_entry)); | |
490 | type = bfd_getb16 (buf); | |
e84d6fca | 491 | |
3af9a47b NC |
492 | switch (type) |
493 | { | |
494 | case BFD_SYM_END_OF_LIST_3_2: | |
495 | entry->generic.type = BFD_SYM_END_OF_LIST; | |
496 | break; | |
497 | ||
498 | case BFD_SYM_SOURCE_FILE_CHANGE_3_2: | |
499 | entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE; | |
500 | bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref); | |
501 | break; | |
502 | ||
503 | default: | |
504 | entry->entry.mte_index = type; | |
505 | entry->entry.mte_offset = bfd_getb16 (buf + 2); | |
506 | entry->entry.file_delta = bfd_getb32 (buf + 4); | |
507 | break; | |
508 | } | |
509 | } | |
510 | ||
511 | void | |
512 | bfd_sym_parse_contained_labels_table_entry_v32 (buf, len, entry) | |
513 | unsigned char *buf; | |
514 | size_t len; | |
515 | bfd_sym_contained_labels_table_entry *entry; | |
516 | { | |
517 | unsigned int type; | |
518 | ||
519 | BFD_ASSERT (len == 12); | |
520 | ||
521 | memset (entry, 0, sizeof (bfd_sym_contained_labels_table_entry)); | |
522 | type = bfd_getb16 (buf); | |
e84d6fca | 523 | |
3af9a47b NC |
524 | switch (type) |
525 | { | |
526 | case BFD_SYM_END_OF_LIST_3_2: | |
527 | entry->generic.type = BFD_SYM_END_OF_LIST; | |
528 | break; | |
529 | ||
530 | case BFD_SYM_SOURCE_FILE_CHANGE_3_2: | |
531 | entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE; | |
532 | bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref); | |
533 | break; | |
534 | ||
535 | default: | |
536 | entry->entry.mte_index = type; | |
537 | entry->entry.mte_offset = bfd_getb16 (buf + 2); | |
538 | entry->entry.nte_index = bfd_getb32 (buf + 4); | |
539 | entry->entry.file_delta = bfd_getb16 (buf + 8); | |
540 | entry->entry.scope = bfd_getb16 (buf + 10); | |
541 | break; | |
542 | } | |
543 | } | |
544 | ||
545 | void | |
546 | bfd_sym_parse_type_table_entry_v32 (buf, len, entry) | |
547 | unsigned char *buf; | |
548 | size_t len; | |
549 | bfd_sym_type_table_entry *entry; | |
550 | { | |
551 | BFD_ASSERT (len == 4); | |
e84d6fca | 552 | |
3af9a47b NC |
553 | *entry = bfd_getb32 (buf); |
554 | } | |
555 | ||
556 | int | |
557 | bfd_sym_fetch_resources_table_entry (abfd, entry, index) | |
558 | bfd *abfd; | |
559 | bfd_sym_resources_table_entry *entry; | |
560 | unsigned long index; | |
561 | { | |
e84d6fca AM |
562 | void (*parser) PARAMS ((unsigned char *, size_t, |
563 | bfd_sym_resources_table_entry *)); | |
3af9a47b NC |
564 | unsigned long offset; |
565 | unsigned long entry_size; | |
566 | unsigned char buf[18]; | |
567 | bfd_sym_data_struct *sdata = NULL; | |
568 | ||
e84d6fca | 569 | parser = NULL; |
3af9a47b NC |
570 | BFD_ASSERT (bfd_sym_valid (abfd)); |
571 | sdata = abfd->tdata.sym_data; | |
572 | ||
573 | if (index == 0) | |
574 | return -1; | |
575 | ||
576 | switch (sdata->version) | |
577 | { | |
578 | case BFD_SYM_VERSION_3_5: | |
579 | case BFD_SYM_VERSION_3_4: | |
580 | return -1; | |
581 | ||
582 | case BFD_SYM_VERSION_3_3: | |
583 | case BFD_SYM_VERSION_3_2: | |
584 | entry_size = 18; | |
585 | parser = bfd_sym_parse_resources_table_entry_v32; | |
586 | break; | |
587 | ||
588 | case BFD_SYM_VERSION_3_1: | |
589 | default: | |
590 | return -1; | |
591 | } | |
592 | if (parser == NULL) | |
593 | return -1; | |
594 | ||
595 | offset = compute_offset (sdata->header.dshb_rte.dti_first_page, | |
596 | sdata->header.dshb_page_size, | |
597 | entry_size, index); | |
e84d6fca | 598 | |
3af9a47b NC |
599 | if (bfd_seek (abfd, offset, SEEK_SET) < 0) |
600 | return -1; | |
601 | if (bfd_bread (buf, entry_size, abfd) != entry_size) | |
602 | return -1; | |
603 | ||
604 | (*parser) (buf, entry_size, entry); | |
e84d6fca | 605 | |
3af9a47b NC |
606 | return 0; |
607 | } | |
608 | ||
609 | int | |
610 | bfd_sym_fetch_modules_table_entry (abfd, entry, index) | |
611 | bfd *abfd; | |
612 | bfd_sym_modules_table_entry *entry; | |
613 | unsigned long index; | |
614 | { | |
e84d6fca AM |
615 | void (*parser) PARAMS ((unsigned char *, size_t, |
616 | bfd_sym_modules_table_entry *)); | |
3af9a47b NC |
617 | unsigned long offset; |
618 | unsigned long entry_size; | |
619 | unsigned char buf[46]; | |
620 | bfd_sym_data_struct *sdata = NULL; | |
621 | ||
e84d6fca | 622 | parser = NULL; |
3af9a47b NC |
623 | BFD_ASSERT (bfd_sym_valid (abfd)); |
624 | sdata = abfd->tdata.sym_data; | |
625 | ||
626 | if (index == 0) | |
627 | return -1; | |
628 | ||
629 | switch (sdata->version) | |
630 | { | |
631 | case BFD_SYM_VERSION_3_5: | |
632 | case BFD_SYM_VERSION_3_4: | |
633 | return -1; | |
634 | ||
635 | case BFD_SYM_VERSION_3_3: | |
636 | entry_size = 46; | |
637 | parser = bfd_sym_parse_modules_table_entry_v33; | |
638 | break; | |
639 | ||
640 | case BFD_SYM_VERSION_3_2: | |
641 | case BFD_SYM_VERSION_3_1: | |
642 | default: | |
643 | return -1; | |
644 | } | |
645 | if (parser == NULL) | |
646 | return -1; | |
647 | ||
648 | offset = compute_offset (sdata->header.dshb_mte.dti_first_page, | |
649 | sdata->header.dshb_page_size, | |
650 | entry_size, index); | |
e84d6fca | 651 | |
3af9a47b NC |
652 | if (bfd_seek (abfd, offset, SEEK_SET) < 0) |
653 | return -1; | |
654 | if (bfd_bread (buf, entry_size, abfd) != entry_size) | |
655 | return -1; | |
656 | ||
657 | (*parser) (buf, entry_size, entry); | |
e84d6fca | 658 | |
3af9a47b NC |
659 | return 0; |
660 | } | |
661 | ||
662 | int | |
663 | bfd_sym_fetch_file_references_table_entry (abfd, entry, index) | |
664 | bfd *abfd; | |
665 | bfd_sym_file_references_table_entry *entry; | |
666 | unsigned long index; | |
667 | { | |
e84d6fca AM |
668 | void (*parser) PARAMS ((unsigned char *, size_t, |
669 | bfd_sym_file_references_table_entry *)); | |
3af9a47b NC |
670 | unsigned long offset; |
671 | unsigned long entry_size = 0; | |
672 | unsigned char buf[8]; | |
673 | bfd_sym_data_struct *sdata = NULL; | |
674 | ||
e84d6fca | 675 | parser = NULL; |
3af9a47b NC |
676 | BFD_ASSERT (bfd_sym_valid (abfd)); |
677 | sdata = abfd->tdata.sym_data; | |
678 | ||
679 | if (index == 0) | |
680 | return -1; | |
681 | ||
682 | switch (sdata->version) | |
683 | { | |
684 | case BFD_SYM_VERSION_3_3: | |
685 | case BFD_SYM_VERSION_3_2: | |
686 | entry_size = 10; | |
687 | parser = bfd_sym_parse_file_references_table_entry_v32; | |
688 | break; | |
689 | ||
690 | case BFD_SYM_VERSION_3_5: | |
691 | case BFD_SYM_VERSION_3_4: | |
692 | case BFD_SYM_VERSION_3_1: | |
693 | default: | |
694 | break; | |
695 | } | |
696 | ||
697 | if (parser == NULL) | |
698 | return -1; | |
699 | ||
700 | offset = compute_offset (sdata->header.dshb_frte.dti_first_page, | |
701 | sdata->header.dshb_page_size, | |
702 | entry_size, index); | |
e84d6fca | 703 | |
3af9a47b NC |
704 | if (bfd_seek (abfd, offset, SEEK_SET) < 0) |
705 | return -1; | |
706 | if (bfd_bread (buf, entry_size, abfd) != entry_size) | |
707 | return -1; | |
708 | ||
709 | (*parser) (buf, entry_size, entry); | |
e84d6fca | 710 | |
3af9a47b NC |
711 | return 0; |
712 | } | |
713 | ||
714 | int | |
715 | bfd_sym_fetch_contained_modules_table_entry (abfd, entry, index) | |
716 | bfd *abfd; | |
717 | bfd_sym_contained_modules_table_entry *entry; | |
718 | unsigned long index; | |
719 | { | |
e84d6fca AM |
720 | void (*parser) PARAMS ((unsigned char *, size_t, |
721 | bfd_sym_contained_modules_table_entry *)); | |
3af9a47b NC |
722 | unsigned long offset; |
723 | unsigned long entry_size = 0; | |
724 | unsigned char buf[6]; | |
725 | bfd_sym_data_struct *sdata = NULL; | |
726 | ||
e84d6fca | 727 | parser = NULL; |
3af9a47b NC |
728 | BFD_ASSERT (bfd_sym_valid (abfd)); |
729 | sdata = abfd->tdata.sym_data; | |
730 | ||
731 | if (index == 0) | |
732 | return -1; | |
733 | ||
734 | switch (sdata->version) | |
735 | { | |
736 | case BFD_SYM_VERSION_3_3: | |
737 | case BFD_SYM_VERSION_3_2: | |
738 | entry_size = 6; | |
739 | parser = bfd_sym_parse_contained_modules_table_entry_v32; | |
740 | break; | |
741 | ||
742 | case BFD_SYM_VERSION_3_5: | |
743 | case BFD_SYM_VERSION_3_4: | |
744 | case BFD_SYM_VERSION_3_1: | |
745 | default: | |
746 | break; | |
747 | } | |
748 | ||
749 | if (parser == NULL) | |
750 | return -1; | |
751 | ||
752 | offset = compute_offset (sdata->header.dshb_cmte.dti_first_page, | |
753 | sdata->header.dshb_page_size, | |
754 | entry_size, index); | |
e84d6fca | 755 | |
3af9a47b NC |
756 | if (bfd_seek (abfd, offset, SEEK_SET) < 0) |
757 | return -1; | |
758 | if (bfd_bread (buf, entry_size, abfd) != entry_size) | |
759 | return -1; | |
760 | ||
761 | (*parser) (buf, entry_size, entry); | |
e84d6fca | 762 | |
3af9a47b NC |
763 | return 0; |
764 | } | |
765 | ||
766 | int | |
767 | bfd_sym_fetch_contained_variables_table_entry (abfd, entry, index) | |
768 | bfd *abfd; | |
769 | bfd_sym_contained_variables_table_entry *entry; | |
770 | unsigned long index; | |
771 | { | |
e84d6fca AM |
772 | void (*parser) PARAMS ((unsigned char *, size_t, |
773 | bfd_sym_contained_variables_table_entry *)); | |
3af9a47b NC |
774 | unsigned long offset; |
775 | unsigned long entry_size = 0; | |
776 | unsigned char buf[26]; | |
777 | bfd_sym_data_struct *sdata = NULL; | |
778 | ||
e84d6fca | 779 | parser = NULL; |
3af9a47b NC |
780 | BFD_ASSERT (bfd_sym_valid (abfd)); |
781 | sdata = abfd->tdata.sym_data; | |
782 | ||
783 | if (index == 0) | |
784 | return -1; | |
785 | ||
786 | switch (sdata->version) | |
787 | { | |
788 | case BFD_SYM_VERSION_3_3: | |
789 | case BFD_SYM_VERSION_3_2: | |
790 | entry_size = 26; | |
791 | parser = bfd_sym_parse_contained_variables_table_entry_v32; | |
792 | break; | |
793 | ||
794 | case BFD_SYM_VERSION_3_5: | |
795 | case BFD_SYM_VERSION_3_4: | |
796 | case BFD_SYM_VERSION_3_1: | |
797 | default: | |
798 | break; | |
799 | } | |
800 | ||
801 | if (parser == NULL) | |
802 | return -1; | |
803 | ||
804 | offset = compute_offset (sdata->header.dshb_cvte.dti_first_page, | |
805 | sdata->header.dshb_page_size, | |
806 | entry_size, index); | |
e84d6fca | 807 | |
3af9a47b NC |
808 | if (bfd_seek (abfd, offset, SEEK_SET) < 0) |
809 | return -1; | |
810 | if (bfd_bread (buf, entry_size, abfd) != entry_size) | |
811 | return -1; | |
812 | ||
813 | (*parser) (buf, entry_size, entry); | |
e84d6fca | 814 | |
3af9a47b NC |
815 | return 0; |
816 | } | |
817 | ||
818 | int | |
819 | bfd_sym_fetch_contained_statements_table_entry (abfd, entry, index) | |
820 | bfd *abfd; | |
821 | bfd_sym_contained_statements_table_entry *entry; | |
822 | unsigned long index; | |
823 | { | |
e84d6fca AM |
824 | void (*parser) PARAMS ((unsigned char *, size_t, |
825 | bfd_sym_contained_statements_table_entry *)); | |
3af9a47b NC |
826 | unsigned long offset; |
827 | unsigned long entry_size = 0; | |
828 | unsigned char buf[8]; | |
829 | bfd_sym_data_struct *sdata = NULL; | |
830 | ||
e84d6fca | 831 | parser = NULL; |
3af9a47b NC |
832 | BFD_ASSERT (bfd_sym_valid (abfd)); |
833 | sdata = abfd->tdata.sym_data; | |
834 | ||
835 | if (index == 0) | |
836 | return -1; | |
837 | ||
838 | switch (sdata->version) | |
839 | { | |
840 | case BFD_SYM_VERSION_3_3: | |
841 | case BFD_SYM_VERSION_3_2: | |
842 | entry_size = 8; | |
843 | parser = bfd_sym_parse_contained_statements_table_entry_v32; | |
844 | break; | |
845 | ||
846 | case BFD_SYM_VERSION_3_5: | |
847 | case BFD_SYM_VERSION_3_4: | |
848 | case BFD_SYM_VERSION_3_1: | |
849 | default: | |
850 | break; | |
851 | } | |
852 | ||
853 | if (parser == NULL) | |
854 | return -1; | |
855 | ||
856 | offset = compute_offset (sdata->header.dshb_csnte.dti_first_page, | |
857 | sdata->header.dshb_page_size, | |
858 | entry_size, index); | |
e84d6fca | 859 | |
3af9a47b NC |
860 | if (bfd_seek (abfd, offset, SEEK_SET) < 0) |
861 | return -1; | |
862 | if (bfd_bread (buf, entry_size, abfd) != entry_size) | |
863 | return -1; | |
864 | ||
865 | (*parser) (buf, entry_size, entry); | |
e84d6fca | 866 | |
3af9a47b NC |
867 | return 0; |
868 | } | |
869 | ||
870 | int | |
871 | bfd_sym_fetch_contained_labels_table_entry (abfd, entry, index) | |
872 | bfd *abfd; | |
873 | bfd_sym_contained_labels_table_entry *entry; | |
874 | unsigned long index; | |
875 | { | |
e84d6fca AM |
876 | void (*parser) PARAMS ((unsigned char *, size_t, |
877 | bfd_sym_contained_labels_table_entry *)); | |
3af9a47b NC |
878 | unsigned long offset; |
879 | unsigned long entry_size = 0; | |
880 | unsigned char buf[12]; | |
881 | bfd_sym_data_struct *sdata = NULL; | |
882 | ||
e84d6fca | 883 | parser = NULL; |
3af9a47b NC |
884 | BFD_ASSERT (bfd_sym_valid (abfd)); |
885 | sdata = abfd->tdata.sym_data; | |
886 | ||
887 | if (index == 0) | |
888 | return -1; | |
889 | ||
890 | switch (sdata->version) | |
891 | { | |
892 | case BFD_SYM_VERSION_3_3: | |
893 | case BFD_SYM_VERSION_3_2: | |
894 | entry_size = 12; | |
895 | parser = bfd_sym_parse_contained_labels_table_entry_v32; | |
896 | break; | |
897 | ||
898 | case BFD_SYM_VERSION_3_5: | |
899 | case BFD_SYM_VERSION_3_4: | |
900 | case BFD_SYM_VERSION_3_1: | |
901 | default: | |
902 | break; | |
903 | } | |
904 | ||
905 | if (parser == NULL) | |
906 | return -1; | |
907 | ||
908 | offset = compute_offset (sdata->header.dshb_clte.dti_first_page, | |
909 | sdata->header.dshb_page_size, | |
910 | entry_size, index); | |
e84d6fca | 911 | |
3af9a47b NC |
912 | if (bfd_seek (abfd, offset, SEEK_SET) < 0) |
913 | return -1; | |
914 | if (bfd_bread (buf, entry_size, abfd) != entry_size) | |
915 | return -1; | |
916 | ||
917 | (*parser) (buf, entry_size, entry); | |
e84d6fca | 918 | |
3af9a47b NC |
919 | return 0; |
920 | } | |
921 | ||
922 | int | |
923 | bfd_sym_fetch_contained_types_table_entry (abfd, entry, index) | |
924 | bfd *abfd; | |
925 | bfd_sym_contained_types_table_entry *entry; | |
926 | unsigned long index; | |
927 | { | |
e84d6fca AM |
928 | void (*parser) PARAMS ((unsigned char *, size_t, |
929 | bfd_sym_contained_types_table_entry *)); | |
3af9a47b NC |
930 | unsigned long offset; |
931 | unsigned long entry_size = 0; | |
932 | unsigned char buf[0]; | |
933 | bfd_sym_data_struct *sdata = NULL; | |
934 | ||
e84d6fca | 935 | parser = NULL; |
3af9a47b NC |
936 | BFD_ASSERT (bfd_sym_valid (abfd)); |
937 | sdata = abfd->tdata.sym_data; | |
938 | ||
939 | if (index == 0) | |
940 | return -1; | |
941 | ||
942 | switch (sdata->version) | |
943 | { | |
944 | case BFD_SYM_VERSION_3_3: | |
945 | case BFD_SYM_VERSION_3_2: | |
946 | entry_size = 0; | |
947 | parser = NULL; | |
948 | break; | |
949 | ||
950 | case BFD_SYM_VERSION_3_5: | |
951 | case BFD_SYM_VERSION_3_4: | |
952 | case BFD_SYM_VERSION_3_1: | |
953 | default: | |
954 | break; | |
955 | } | |
956 | ||
957 | if (parser == NULL) | |
958 | return -1; | |
959 | ||
960 | offset = compute_offset (sdata->header.dshb_ctte.dti_first_page, | |
961 | sdata->header.dshb_page_size, | |
962 | entry_size, index); | |
e84d6fca | 963 | |
3af9a47b NC |
964 | if (bfd_seek (abfd, offset, SEEK_SET) < 0) |
965 | return -1; | |
966 | if (bfd_bread (buf, entry_size, abfd) != entry_size) | |
967 | return -1; | |
968 | ||
969 | (*parser) (buf, entry_size, entry); | |
e84d6fca | 970 | |
3af9a47b NC |
971 | return 0; |
972 | } | |
973 | ||
974 | int | |
975 | bfd_sym_fetch_file_references_index_table_entry (abfd, entry, index) | |
976 | bfd *abfd; | |
977 | bfd_sym_file_references_index_table_entry *entry; | |
978 | unsigned long index; | |
979 | { | |
e84d6fca AM |
980 | void (*parser) PARAMS ((unsigned char *, size_t, |
981 | bfd_sym_file_references_index_table_entry *)); | |
3af9a47b NC |
982 | unsigned long offset; |
983 | unsigned long entry_size = 0; | |
984 | unsigned char buf[0]; | |
985 | bfd_sym_data_struct *sdata = NULL; | |
986 | ||
e84d6fca | 987 | parser = NULL; |
3af9a47b NC |
988 | BFD_ASSERT (bfd_sym_valid (abfd)); |
989 | sdata = abfd->tdata.sym_data; | |
990 | ||
991 | if (index == 0) | |
992 | return -1; | |
993 | ||
994 | switch (sdata->version) | |
995 | { | |
996 | case BFD_SYM_VERSION_3_3: | |
997 | case BFD_SYM_VERSION_3_2: | |
998 | entry_size = 0; | |
999 | parser = NULL; | |
1000 | break; | |
1001 | ||
1002 | case BFD_SYM_VERSION_3_5: | |
1003 | case BFD_SYM_VERSION_3_4: | |
1004 | case BFD_SYM_VERSION_3_1: | |
1005 | default: | |
1006 | break; | |
1007 | } | |
1008 | ||
1009 | if (parser == NULL) | |
1010 | return -1; | |
1011 | ||
1012 | offset = compute_offset (sdata->header.dshb_fite.dti_first_page, | |
1013 | sdata->header.dshb_page_size, | |
1014 | entry_size, index); | |
e84d6fca | 1015 | |
3af9a47b NC |
1016 | if (bfd_seek (abfd, offset, SEEK_SET) < 0) |
1017 | return -1; | |
1018 | if (bfd_bread (buf, entry_size, abfd) != entry_size) | |
1019 | return -1; | |
1020 | ||
1021 | (*parser) (buf, entry_size, entry); | |
e84d6fca | 1022 | |
3af9a47b NC |
1023 | return 0; |
1024 | } | |
1025 | ||
1026 | int | |
1027 | bfd_sym_fetch_constant_pool_entry (abfd, entry, index) | |
1028 | bfd *abfd; | |
1029 | bfd_sym_constant_pool_entry *entry; | |
1030 | unsigned long index; | |
1031 | { | |
e84d6fca AM |
1032 | void (*parser) PARAMS ((unsigned char *, size_t, |
1033 | bfd_sym_constant_pool_entry *)); | |
3af9a47b NC |
1034 | unsigned long offset; |
1035 | unsigned long entry_size = 0; | |
1036 | unsigned char buf[0]; | |
1037 | bfd_sym_data_struct *sdata = NULL; | |
1038 | ||
e84d6fca | 1039 | parser = NULL; |
3af9a47b NC |
1040 | BFD_ASSERT (bfd_sym_valid (abfd)); |
1041 | sdata = abfd->tdata.sym_data; | |
1042 | ||
1043 | if (index == 0) | |
1044 | return -1; | |
1045 | ||
1046 | switch (sdata->version) | |
1047 | { | |
1048 | case BFD_SYM_VERSION_3_3: | |
1049 | case BFD_SYM_VERSION_3_2: | |
1050 | entry_size = 0; | |
1051 | parser = NULL; | |
1052 | break; | |
1053 | ||
1054 | case BFD_SYM_VERSION_3_5: | |
1055 | case BFD_SYM_VERSION_3_4: | |
1056 | case BFD_SYM_VERSION_3_1: | |
1057 | default: | |
1058 | break; | |
1059 | } | |
1060 | ||
1061 | if (parser == NULL) | |
1062 | return -1; | |
1063 | ||
1064 | offset = compute_offset (sdata->header.dshb_fite.dti_first_page, | |
1065 | sdata->header.dshb_page_size, | |
1066 | entry_size, index); | |
e84d6fca | 1067 | |
3af9a47b NC |
1068 | if (bfd_seek (abfd, offset, SEEK_SET) < 0) |
1069 | return -1; | |
1070 | if (bfd_bread (buf, entry_size, abfd) != entry_size) | |
1071 | return -1; | |
1072 | ||
1073 | (*parser) (buf, entry_size, entry); | |
e84d6fca | 1074 | |
3af9a47b NC |
1075 | return 0; |
1076 | } | |
1077 | ||
1078 | int | |
1079 | bfd_sym_fetch_type_table_entry (abfd, entry, index) | |
1080 | bfd *abfd; | |
1081 | bfd_sym_type_table_entry *entry; | |
1082 | unsigned long index; | |
1083 | { | |
e84d6fca AM |
1084 | void (*parser) PARAMS ((unsigned char *, size_t, |
1085 | bfd_sym_type_table_entry *)); | |
3af9a47b NC |
1086 | unsigned long offset; |
1087 | unsigned long entry_size = 0; | |
1088 | unsigned char buf[4]; | |
1089 | bfd_sym_data_struct *sdata = NULL; | |
1090 | ||
e84d6fca | 1091 | parser = NULL; |
3af9a47b NC |
1092 | BFD_ASSERT (bfd_sym_valid (abfd)); |
1093 | sdata = abfd->tdata.sym_data; | |
1094 | ||
1095 | switch (sdata->version) | |
1096 | { | |
1097 | case BFD_SYM_VERSION_3_3: | |
1098 | case BFD_SYM_VERSION_3_2: | |
1099 | entry_size = 4; | |
1100 | parser = bfd_sym_parse_type_table_entry_v32; | |
1101 | break; | |
1102 | ||
1103 | case BFD_SYM_VERSION_3_5: | |
1104 | case BFD_SYM_VERSION_3_4: | |
1105 | case BFD_SYM_VERSION_3_1: | |
1106 | default: | |
1107 | break; | |
1108 | } | |
1109 | ||
1110 | if (parser == NULL) | |
1111 | return -1; | |
1112 | ||
1113 | offset = compute_offset (sdata->header.dshb_tte.dti_first_page, | |
1114 | sdata->header.dshb_page_size, | |
1115 | entry_size, index); | |
e84d6fca | 1116 | |
3af9a47b NC |
1117 | if (bfd_seek (abfd, offset, SEEK_SET) < 0) |
1118 | return -1; | |
1119 | if (bfd_bread (buf, entry_size, abfd) != entry_size) | |
1120 | return -1; | |
1121 | ||
1122 | (*parser) (buf, entry_size, entry); | |
e84d6fca | 1123 | |
3af9a47b NC |
1124 | return 0; |
1125 | } | |
1126 | ||
1127 | int | |
1128 | bfd_sym_fetch_type_information_table_entry (abfd, entry, offset) | |
1129 | bfd *abfd; | |
1130 | bfd_sym_type_information_table_entry *entry; | |
1131 | unsigned long offset; | |
1132 | { | |
1133 | unsigned char buf[4]; | |
1134 | bfd_sym_data_struct *sdata = NULL; | |
1135 | ||
1136 | BFD_ASSERT (bfd_sym_valid (abfd)); | |
1137 | sdata = abfd->tdata.sym_data; | |
1138 | ||
64fb1839 | 1139 | if (offset == 0) |
3af9a47b NC |
1140 | return -1; |
1141 | ||
1142 | if (bfd_seek (abfd, offset, SEEK_SET) < 0) | |
1143 | return -1; | |
1144 | ||
1145 | if (bfd_bread (buf, 4, abfd) != 4) | |
1146 | return -1; | |
1147 | entry->nte_index = bfd_getb32 (buf); | |
e84d6fca | 1148 | |
3af9a47b NC |
1149 | if (bfd_bread (buf, 2, abfd) != 2) |
1150 | return -1; | |
1151 | entry->physical_size = bfd_getb16 (buf); | |
e84d6fca | 1152 | |
3af9a47b NC |
1153 | if (entry->physical_size & 0x8000) |
1154 | { | |
1155 | if (bfd_bread (buf, 4, abfd) != 4) | |
1156 | return -1; | |
1157 | entry->physical_size &= 0x7fff; | |
1158 | entry->logical_size = bfd_getb32 (buf); | |
1159 | entry->offset = offset + 10; | |
1160 | } | |
1161 | else | |
1162 | { | |
1163 | if (bfd_bread (buf, 2, abfd) != 2) | |
1164 | return -1; | |
1165 | entry->physical_size &= 0x7fff; | |
1166 | entry->logical_size = bfd_getb16 (buf); | |
1167 | entry->offset = offset + 8; | |
1168 | } | |
1169 | ||
1170 | return 0; | |
1171 | } | |
1172 | ||
1173 | int | |
1174 | bfd_sym_fetch_type_table_information (abfd, entry, index) | |
1175 | bfd *abfd; | |
1176 | bfd_sym_type_information_table_entry *entry; | |
1177 | unsigned long index; | |
1178 | { | |
1179 | bfd_sym_type_table_entry tindex; | |
1180 | bfd_sym_data_struct *sdata = NULL; | |
1181 | ||
1182 | BFD_ASSERT (bfd_sym_valid (abfd)); | |
1183 | sdata = abfd->tdata.sym_data; | |
1184 | ||
1185 | if (sdata->header.dshb_tte.dti_object_count <= 99) | |
1186 | return -1; | |
1187 | if (index < 100) | |
1188 | return -1; | |
1189 | ||
1190 | if (bfd_sym_fetch_type_table_entry (abfd, &tindex, index - 100) < 0) | |
1191 | return -1; | |
1192 | if (bfd_sym_fetch_type_information_table_entry (abfd, entry, tindex) < 0) | |
1193 | return -1; | |
1194 | ||
1195 | return 0; | |
1196 | } | |
1197 | ||
1198 | const unsigned char * | |
1199 | bfd_sym_symbol_name (abfd, index) | |
1200 | bfd *abfd; | |
1201 | unsigned long index; | |
1202 | { | |
1203 | bfd_sym_data_struct *sdata = NULL; | |
1204 | ||
1205 | BFD_ASSERT (bfd_sym_valid (abfd)); | |
1206 | sdata = abfd->tdata.sym_data; | |
1207 | ||
1208 | if (index == 0) | |
f075ee0c | 1209 | return (const unsigned char *) ""; |
e84d6fca | 1210 | |
3af9a47b | 1211 | index *= 2; |
e84d6fca AM |
1212 | if ((index / sdata->header.dshb_page_size) |
1213 | > sdata->header.dshb_nte.dti_page_count) | |
f075ee0c | 1214 | return (const unsigned char *) "\09[INVALID]"; |
e84d6fca AM |
1215 | |
1216 | return (const unsigned char *) sdata->name_table + index; | |
3af9a47b NC |
1217 | } |
1218 | ||
1219 | const unsigned char * | |
1220 | bfd_sym_module_name (abfd, index) | |
1221 | bfd *abfd; | |
1222 | unsigned long index; | |
1223 | { | |
1224 | bfd_sym_modules_table_entry entry; | |
e84d6fca | 1225 | |
3af9a47b | 1226 | if (bfd_sym_fetch_modules_table_entry (abfd, &entry, index) < 0) |
f075ee0c | 1227 | return (const unsigned char *) "\09[INVALID]"; |
3af9a47b NC |
1228 | |
1229 | return bfd_sym_symbol_name (abfd, entry.mte_nte_index); | |
1230 | } | |
1231 | ||
1232 | const char * | |
1233 | bfd_sym_unparse_storage_kind (kind) | |
1234 | enum bfd_sym_storage_kind kind; | |
1235 | { | |
1236 | switch (kind) | |
1237 | { | |
1238 | case BFD_SYM_STORAGE_KIND_LOCAL: return "LOCAL"; | |
1239 | case BFD_SYM_STORAGE_KIND_VALUE: return "VALUE"; | |
1240 | case BFD_SYM_STORAGE_KIND_REFERENCE: return "REFERENCE"; | |
1241 | case BFD_SYM_STORAGE_KIND_WITH: return "WITH"; | |
1242 | default: return "[UNKNOWN]"; | |
1243 | } | |
1244 | } | |
1245 | ||
1246 | const char * | |
1247 | bfd_sym_unparse_storage_class (kind) | |
1248 | enum bfd_sym_storage_class kind; | |
1249 | { | |
1250 | switch (kind) | |
1251 | { | |
1252 | case BFD_SYM_STORAGE_CLASS_REGISTER: return "REGISTER"; | |
1253 | case BFD_SYM_STORAGE_CLASS_GLOBAL: return "GLOBAL"; | |
1254 | case BFD_SYM_STORAGE_CLASS_FRAME_RELATIVE: return "FRAME_RELATIVE"; | |
1255 | case BFD_SYM_STORAGE_CLASS_STACK_RELATIVE: return "STACK_RELATIVE"; | |
1256 | case BFD_SYM_STORAGE_CLASS_ABSOLUTE: return "ABSOLUTE"; | |
1257 | case BFD_SYM_STORAGE_CLASS_CONSTANT: return "CONSTANT"; | |
1258 | case BFD_SYM_STORAGE_CLASS_RESOURCE: return "RESOURCE"; | |
1259 | case BFD_SYM_STORAGE_CLASS_BIGCONSTANT: return "BIGCONSTANT"; | |
1260 | default: return "[UNKNOWN]"; | |
1261 | } | |
1262 | } | |
1263 | ||
1264 | const char * | |
1265 | bfd_sym_unparse_module_kind (kind) | |
1266 | enum bfd_sym_module_kind kind; | |
1267 | { | |
1268 | switch (kind) | |
1269 | { | |
1270 | case BFD_SYM_MODULE_KIND_NONE: return "NONE"; | |
1271 | case BFD_SYM_MODULE_KIND_PROGRAM: return "PROGRAM"; | |
1272 | case BFD_SYM_MODULE_KIND_UNIT: return "UNIT"; | |
1273 | case BFD_SYM_MODULE_KIND_PROCEDURE: return "PROCEDURE"; | |
1274 | case BFD_SYM_MODULE_KIND_FUNCTION: return "FUNCTION"; | |
1275 | case BFD_SYM_MODULE_KIND_DATA: return "DATA"; | |
1276 | case BFD_SYM_MODULE_KIND_BLOCK: return "BLOCK"; | |
1277 | default: return "[UNKNOWN]"; | |
1278 | } | |
1279 | } | |
1280 | ||
1281 | const char * | |
1282 | bfd_sym_unparse_symbol_scope (scope) | |
1283 | enum bfd_sym_symbol_scope scope; | |
1284 | { | |
1285 | switch (scope) | |
1286 | { | |
1287 | case BFD_SYM_SYMBOL_SCOPE_LOCAL: return "LOCAL"; | |
1288 | case BFD_SYM_SYMBOL_SCOPE_GLOBAL: return "GLOBAL"; | |
1289 | default: | |
1290 | return "[UNKNOWN]"; | |
1291 | } | |
1292 | } | |
1293 | ||
1294 | void | |
1295 | bfd_sym_print_file_reference (abfd, f, entry) | |
1296 | bfd *abfd; | |
1297 | FILE *f; | |
1298 | bfd_sym_file_reference *entry; | |
1299 | { | |
1300 | bfd_sym_file_references_table_entry frtentry; | |
1301 | int ret; | |
1302 | ||
e84d6fca AM |
1303 | ret = bfd_sym_fetch_file_references_table_entry (abfd, &frtentry, |
1304 | entry->fref_frte_index); | |
3af9a47b NC |
1305 | fprintf (f, "FILE "); |
1306 | ||
1307 | if ((ret < 0) || (frtentry.generic.type != BFD_SYM_FILE_NAME_INDEX)) | |
1308 | fprintf (f, "[INVALID]"); | |
1309 | else | |
1310 | fprintf (f, "\"%.*s\"", | |
1311 | bfd_sym_symbol_name (abfd, frtentry.filename.nte_index)[0], | |
1312 | &bfd_sym_symbol_name (abfd, frtentry.filename.nte_index)[1]); | |
1313 | ||
1314 | fprintf (f, " (FRTE %lu)", entry->fref_frte_index); | |
1315 | } | |
1316 | ||
1317 | void | |
1318 | bfd_sym_print_resources_table_entry (abfd, f, entry) | |
1319 | bfd *abfd; | |
1320 | FILE *f; | |
1321 | bfd_sym_resources_table_entry *entry; | |
1322 | { | |
1323 | fprintf (f, " \"%.*s\" (NTE %lu), type \"%.4s\", num %u, size %lu, MTE %lu -- %lu", | |
1324 | bfd_sym_symbol_name (abfd, entry->rte_nte_index)[0], | |
1325 | &bfd_sym_symbol_name (abfd, entry->rte_nte_index)[1], | |
1326 | entry->rte_nte_index, entry->rte_res_type, entry->rte_res_number, | |
1327 | entry->rte_res_size, entry->rte_mte_first, entry->rte_mte_last); | |
e84d6fca | 1328 | } |
3af9a47b NC |
1329 | |
1330 | void | |
1331 | bfd_sym_print_modules_table_entry (abfd, f, entry) | |
1332 | bfd *abfd; | |
1333 | FILE *f; | |
1334 | bfd_sym_modules_table_entry *entry; | |
1335 | { | |
1336 | fprintf (f, "\"%.*s\" (NTE %lu)", | |
1337 | bfd_sym_symbol_name (abfd, entry->mte_nte_index)[0], | |
1338 | &bfd_sym_symbol_name (abfd, entry->mte_nte_index)[1], | |
1339 | entry->mte_nte_index); | |
e84d6fca AM |
1340 | |
1341 | fprintf (f, "\n "); | |
3af9a47b NC |
1342 | |
1343 | bfd_sym_print_file_reference (abfd, f, &entry->mte_imp_fref); | |
e84d6fca AM |
1344 | fprintf (f, " range %lu -- %lu", |
1345 | entry->mte_imp_fref.fref_offset, entry->mte_imp_end); | |
3af9a47b | 1346 | |
e84d6fca | 1347 | fprintf (f, "\n "); |
3af9a47b NC |
1348 | |
1349 | fprintf (f, "kind %s", bfd_sym_unparse_module_kind (entry->mte_kind)); | |
1350 | fprintf (f, ", scope %s", bfd_sym_unparse_symbol_scope (entry->mte_scope)); | |
e84d6fca | 1351 | |
3af9a47b NC |
1352 | fprintf (f, ", RTE %lu, offset %lu, size %lu", |
1353 | entry->mte_rte_index, entry->mte_res_offset, entry->mte_size); | |
1354 | ||
e84d6fca | 1355 | fprintf (f, "\n "); |
3af9a47b | 1356 | |
e84d6fca | 1357 | fprintf (f, "CMTE %lu, CVTE %lu, CLTE %lu, CTTE %lu, CSNTE1 %lu, CSNTE2 %lu", |
3af9a47b NC |
1358 | entry->mte_cmte_index, entry->mte_cvte_index, |
1359 | entry->mte_clte_index, entry->mte_ctte_index, | |
1360 | entry->mte_csnte_idx_1, entry->mte_csnte_idx_2); | |
e84d6fca | 1361 | |
3af9a47b NC |
1362 | if (entry->mte_parent != 0) |
1363 | fprintf (f, ", parent %lu", entry->mte_parent); | |
1364 | else | |
1365 | fprintf (f, ", no parent"); | |
1366 | ||
1367 | if (entry->mte_cmte_index != 0) | |
1368 | fprintf (f, ", child %lu", entry->mte_cmte_index); | |
1369 | else | |
1370 | fprintf (f, ", no child"); | |
3af9a47b NC |
1371 | } |
1372 | ||
1373 | void | |
1374 | bfd_sym_print_file_references_table_entry (abfd, f, entry) | |
1375 | bfd *abfd; | |
1376 | FILE *f; | |
1377 | bfd_sym_file_references_table_entry *entry; | |
1378 | { | |
1379 | switch (entry->generic.type) | |
1380 | { | |
1381 | case BFD_SYM_FILE_NAME_INDEX: | |
e84d6fca | 1382 | fprintf (f, "FILE \"%.*s\" (NTE %lu), modtime ", |
3af9a47b NC |
1383 | bfd_sym_symbol_name (abfd, entry->filename.nte_index)[0], |
1384 | &bfd_sym_symbol_name (abfd, entry->filename.nte_index)[1], | |
1385 | entry->filename.nte_index); | |
1386 | ||
1387 | fprintf (f, "[UNIMPLEMENTED]"); | |
1388 | /* printModDate (entry->filename.mod_date); */ | |
1389 | fprintf (f, " (0x%lx)", entry->filename.mod_date); | |
1390 | break; | |
1391 | ||
1392 | case BFD_SYM_END_OF_LIST: | |
1393 | fprintf (f, "END"); | |
1394 | break; | |
1395 | ||
1396 | default: | |
1397 | fprintf (f, "\"%.*s\" (MTE %lu), offset %lu", | |
1398 | bfd_sym_module_name (abfd, entry->entry.mte_index)[0], | |
1399 | &bfd_sym_module_name (abfd, entry->entry.mte_index)[1], | |
1400 | entry->entry.mte_index, | |
1401 | entry->entry.file_offset); | |
1402 | break; | |
1403 | } | |
1404 | } | |
1405 | ||
1406 | void | |
1407 | bfd_sym_print_contained_modules_table_entry (abfd, f, entry) | |
1408 | bfd *abfd; | |
1409 | FILE *f; | |
1410 | bfd_sym_contained_modules_table_entry *entry; | |
1411 | { | |
1412 | switch (entry->generic.type) | |
1413 | { | |
1414 | case BFD_SYM_END_OF_LIST: | |
1415 | fprintf (f, "END"); | |
1416 | break; | |
1417 | ||
1418 | default: | |
1419 | fprintf (f, "\"%.*s\" (MTE %lu, NTE %lu)", | |
1420 | bfd_sym_module_name (abfd, entry->entry.mte_index)[0], | |
1421 | &bfd_sym_module_name (abfd, entry->entry.mte_index)[1], | |
1422 | entry->entry.mte_index, | |
1423 | entry->entry.nte_index); | |
1424 | break; | |
1425 | } | |
1426 | } | |
1427 | ||
1428 | void | |
1429 | bfd_sym_print_contained_variables_table_entry (abfd, f, entry) | |
1430 | bfd *abfd; | |
1431 | FILE *f; | |
1432 | bfd_sym_contained_variables_table_entry *entry; | |
1433 | { | |
1434 | if (entry->generic.type == BFD_SYM_END_OF_LIST) | |
1435 | { | |
1436 | fprintf (f, "END"); | |
1437 | return; | |
1438 | } | |
e84d6fca | 1439 | |
3af9a47b NC |
1440 | if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE) |
1441 | { | |
1442 | bfd_sym_print_file_reference (abfd, f, &entry->file.fref); | |
1443 | fprintf (f, " offset %lu", entry->file.fref.fref_offset); | |
1444 | return; | |
1445 | } | |
e84d6fca | 1446 | |
3af9a47b NC |
1447 | fprintf (f, "\"%.*s\" (NTE %lu)", |
1448 | bfd_sym_symbol_name (abfd, entry->entry.nte_index)[0], | |
1449 | &bfd_sym_symbol_name (abfd, entry->entry.nte_index)[1], | |
1450 | entry->entry.nte_index); | |
e84d6fca | 1451 | |
3af9a47b NC |
1452 | fprintf (f, ", TTE %lu", entry->entry.tte_index); |
1453 | fprintf (f, ", offset %lu", entry->entry.file_delta); | |
1454 | fprintf (f, ", scope %s", bfd_sym_unparse_symbol_scope (entry->entry.scope)); | |
1455 | ||
1456 | if (entry->entry.la_size == BFD_SYM_CVTE_SCA) | |
1457 | fprintf (f, ", latype %s, laclass %s, laoffset %lu", | |
1458 | bfd_sym_unparse_storage_kind (entry->entry.address.scstruct.sca_kind), | |
1459 | bfd_sym_unparse_storage_class (entry->entry.address.scstruct.sca_class), | |
1460 | entry->entry.address.scstruct.sca_offset); | |
1461 | else if (entry->entry.la_size <= BFD_SYM_CVTE_LA_MAX_SIZE) | |
1462 | { | |
1463 | unsigned long i; | |
1464 | ||
1465 | fprintf (f, ", la ["); | |
1466 | for (i = 0; i < entry->entry.la_size; i++) | |
1467 | fprintf (f, "0x%02x ", entry->entry.address.lastruct.la[i]); | |
1468 | fprintf (f, "]"); | |
1469 | } | |
1470 | else if (entry->entry.la_size == BFD_SYM_CVTE_BIG_LA) | |
1471 | fprintf (f, ", bigla %lu, biglakind %u", | |
e84d6fca | 1472 | entry->entry.address.biglastruct.big_la, |
3af9a47b NC |
1473 | entry->entry.address.biglastruct.big_la_kind); |
1474 | ||
1475 | else | |
1476 | fprintf (f, ", la [INVALID]"); | |
1477 | } | |
1478 | ||
1479 | void | |
1480 | bfd_sym_print_contained_statements_table_entry (abfd, f, entry) | |
1481 | bfd *abfd; | |
1482 | FILE *f; | |
1483 | bfd_sym_contained_statements_table_entry *entry; | |
1484 | { | |
1485 | if (entry->generic.type == BFD_SYM_END_OF_LIST) | |
1486 | { | |
1487 | fprintf (f, "END"); | |
1488 | return; | |
1489 | } | |
e84d6fca | 1490 | |
3af9a47b NC |
1491 | if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE) |
1492 | { | |
1493 | bfd_sym_print_file_reference (abfd, f, &entry->file.fref); | |
1494 | fprintf (f, " offset %lu", entry->file.fref.fref_offset); | |
1495 | return; | |
1496 | } | |
1497 | ||
1498 | fprintf (f, "\"%.*s\" (MTE %lu), offset %lu, delta %lu", | |
1499 | bfd_sym_module_name (abfd, entry->entry.mte_index)[0], | |
1500 | &bfd_sym_module_name (abfd, entry->entry.mte_index)[1], | |
1501 | entry->entry.mte_index, | |
1502 | entry->entry.mte_offset, | |
1503 | entry->entry.file_delta); | |
1504 | } | |
1505 | ||
1506 | void | |
1507 | bfd_sym_print_contained_labels_table_entry (abfd, f, entry) | |
1508 | bfd *abfd; | |
1509 | FILE *f; | |
1510 | bfd_sym_contained_labels_table_entry *entry; | |
1511 | { | |
1512 | if (entry->generic.type == BFD_SYM_END_OF_LIST) | |
1513 | { | |
1514 | fprintf (f, "END"); | |
1515 | return; | |
1516 | } | |
1517 | ||
1518 | if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE) | |
1519 | { | |
1520 | bfd_sym_print_file_reference (abfd, f, &entry->file.fref); | |
1521 | fprintf (f, " offset %lu", entry->file.fref.fref_offset); | |
1522 | return; | |
1523 | } | |
1524 | ||
1525 | fprintf (f, "\"%.*s\" (MTE %lu), offset %lu, delta %lu, scope %s", | |
1526 | bfd_sym_module_name (abfd, entry->entry.mte_index)[0], | |
1527 | &bfd_sym_module_name (abfd, entry->entry.mte_index)[1], | |
1528 | entry->entry.mte_index, | |
1529 | entry->entry.mte_offset, | |
1530 | entry->entry.file_delta, | |
1531 | bfd_sym_unparse_symbol_scope (entry->entry.scope)); | |
1532 | } | |
1533 | ||
1534 | void | |
1535 | bfd_sym_print_contained_types_table_entry (abfd, f, entry) | |
1536 | bfd *abfd ATTRIBUTE_UNUSED; | |
1537 | FILE *f; | |
1538 | bfd_sym_contained_types_table_entry *entry ATTRIBUTE_UNUSED; | |
1539 | { | |
1540 | fprintf (f, "[UNIMPLEMENTED]"); | |
1541 | } | |
1542 | ||
1543 | const char * | |
1544 | bfd_sym_type_operator_name (num) | |
1545 | unsigned char num; | |
1546 | { | |
1547 | switch (num) | |
1548 | { | |
1549 | case 1: return "TTE"; | |
1550 | case 2: return "PointerTo"; | |
1551 | case 3: return "ScalarOf"; | |
1552 | case 4: return "ConstantOf"; | |
1553 | case 5: return "EnumerationOf"; | |
1554 | case 6: return "VectorOf"; | |
1555 | case 7: return "RecordOf"; | |
1556 | case 8: return "UnionOf"; | |
1557 | case 9: return "SubRangeOf"; | |
1558 | case 10: return "SetOf"; | |
1559 | case 11: return "NamedTypeOf"; | |
1560 | case 12: return "ProcOf"; | |
1561 | case 13: return "ValueOf"; | |
1562 | case 14: return "ArrayOf"; | |
1563 | default: return "[UNKNOWN OPERATOR]"; | |
1564 | } | |
1565 | } | |
1566 | ||
1567 | const char * | |
1568 | bfd_sym_type_basic_name (num) | |
1569 | unsigned char num; | |
1570 | { | |
1571 | switch (num) | |
1572 | { | |
1573 | case 0: return "void"; | |
1574 | case 1: return "pascal string"; | |
1575 | case 2: return "unsigned long"; | |
1576 | case 3: return "signed long"; | |
1577 | case 4: return "extended (10 bytes)"; | |
1578 | case 5: return "pascal boolean (1 byte)"; | |
1579 | case 6: return "unsigned byte"; | |
1580 | case 7: return "signed byte"; | |
1581 | case 8: return "character (1 byte)"; | |
1582 | case 9: return "wide character (2 bytes)"; | |
1583 | case 10: return "unsigned short"; | |
1584 | case 11: return "signed short"; | |
1585 | case 12: return "singled"; | |
1586 | case 13: return "double"; | |
1587 | case 14: return "extended (12 bytes)"; | |
1588 | case 15: return "computational (8 bytes)"; | |
1589 | case 16: return "c string"; | |
1590 | case 17: return "as-is string"; | |
1591 | default: return "[UNKNOWN BASIC TYPE]"; | |
1592 | } | |
1593 | } | |
1594 | ||
1595 | int | |
1596 | bfd_sym_fetch_long (buf, len, offset, offsetptr, value) | |
1597 | unsigned char *buf; | |
1598 | unsigned long len; | |
1599 | unsigned long offset; | |
1600 | unsigned long *offsetptr; | |
1601 | long *value; | |
1602 | { | |
1603 | int ret; | |
1604 | ||
1605 | if (offset >= len) | |
1606 | { | |
1607 | *value = 0; | |
1608 | offset += 0; | |
1609 | ret = -1; | |
1610 | } | |
1611 | else if (! (buf[offset] & 0x80)) | |
1612 | { | |
1613 | *value = buf[offset]; | |
1614 | offset += 1; | |
1615 | ret = 0; | |
1616 | } | |
1617 | else if (buf[offset] == 0xc0) | |
1618 | { | |
1619 | if ((offset + 5) > len) | |
1620 | { | |
1621 | *value = 0; | |
1622 | offset = len; | |
1623 | ret = -1; | |
1624 | } | |
1625 | else | |
1626 | { | |
1627 | *value = bfd_getb32 (buf + offset + 1); | |
1628 | offset += 5; | |
1629 | ret = 0; | |
1630 | } | |
1631 | } | |
1632 | else if ((buf[offset] & 0xc0) == 0xc0) | |
1633 | { | |
1634 | *value = -(buf[offset] & 0x3f); | |
1635 | offset += 1; | |
1636 | ret = 0; | |
1637 | } | |
1638 | else if ((buf[offset] & 0xc0) == 0x80) | |
1639 | { | |
1640 | if ((offset + 2) > len) | |
1641 | { | |
1642 | *value = 0; | |
1643 | offset = len; | |
1644 | ret = -1; | |
1645 | } | |
1646 | else | |
1647 | { | |
1648 | *value = bfd_getb16 (buf + offset) & 0x3fff; | |
1649 | offset += 2; | |
1650 | ret = 0; | |
1651 | } | |
1652 | } | |
1653 | else | |
1654 | abort (); | |
1655 | ||
1656 | if (offsetptr != NULL) | |
1657 | *offsetptr = offset; | |
1658 | ||
1659 | return ret; | |
1660 | } | |
1661 | ||
1662 | void | |
1663 | bfd_sym_print_type_information (abfd, f, buf, len, offset, offsetptr) | |
1664 | bfd *abfd; | |
1665 | FILE *f; | |
1666 | unsigned char *buf; | |
1667 | unsigned long len; | |
1668 | unsigned long offset; | |
1669 | unsigned long *offsetptr; | |
1670 | { | |
1671 | unsigned int type; | |
1672 | ||
1673 | if (offset >= len) | |
1674 | { | |
1675 | fprintf (f, "[NULL]"); | |
1676 | ||
1677 | if (offsetptr != NULL) | |
1678 | *offsetptr = offset; | |
e84d6fca | 1679 | return; |
3af9a47b | 1680 | } |
e84d6fca | 1681 | |
3af9a47b NC |
1682 | type = buf[offset]; |
1683 | offset++; | |
1684 | ||
1685 | if (! (type & 0x80)) | |
1686 | { | |
1687 | fprintf (f, "[%s] (0x%x)", bfd_sym_type_basic_name (type & 0x7f), type); | |
1688 | ||
1689 | if (offsetptr != NULL) | |
1690 | *offsetptr = offset; | |
1691 | return; | |
1692 | } | |
1693 | ||
1694 | if (type & 0x40) | |
1695 | fprintf (f, "[packed "); | |
1696 | else | |
1697 | fprintf (f, "["); | |
1698 | ||
1699 | switch (type & 0x3f) | |
1700 | { | |
1701 | case 1: | |
1702 | { | |
1703 | long value; | |
1704 | bfd_sym_type_information_table_entry tinfo; | |
1705 | ||
e84d6fca | 1706 | bfd_sym_fetch_long (buf, len, offset, &offset, &value); |
3af9a47b NC |
1707 | if (value <= 0) |
1708 | fprintf (f, "[INVALID]"); | |
1709 | else | |
1710 | { | |
1711 | if (bfd_sym_fetch_type_table_information (abfd, &tinfo, value) < 0) | |
1712 | fprintf (f, "[INVALID]"); | |
1713 | else | |
e84d6fca | 1714 | fprintf (f, "\"%.*s\"", |
3af9a47b NC |
1715 | bfd_sym_symbol_name (abfd, tinfo.nte_index)[0], |
1716 | &bfd_sym_symbol_name (abfd, tinfo.nte_index)[1]); | |
1717 | } | |
1718 | fprintf (f, " (TTE %lu)", value); | |
1719 | break; | |
1720 | } | |
1721 | ||
1722 | case 2: | |
1723 | fprintf (f, "pointer (0x%x) to ", type); | |
1724 | bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset); | |
1725 | break; | |
1726 | ||
1727 | case 3: | |
1728 | { | |
f075ee0c | 1729 | long value; |
3af9a47b NC |
1730 | |
1731 | fprintf (f, "scalar (0x%x) of ", type); | |
1732 | bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset); | |
1733 | bfd_sym_fetch_long (buf, len, offset, &offset, &value); | |
f075ee0c | 1734 | fprintf (f, " (%lu)", (unsigned long) value); |
3af9a47b NC |
1735 | break; |
1736 | } | |
e84d6fca | 1737 | |
3af9a47b NC |
1738 | case 5: |
1739 | { | |
f075ee0c AM |
1740 | long lower, upper, nelem; |
1741 | int i; | |
3af9a47b NC |
1742 | |
1743 | fprintf (f, "enumeration (0x%x) of ", type); | |
1744 | bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset); | |
e84d6fca AM |
1745 | bfd_sym_fetch_long (buf, len, offset, &offset, &lower); |
1746 | bfd_sym_fetch_long (buf, len, offset, &offset, &upper); | |
1747 | bfd_sym_fetch_long (buf, len, offset, &offset, &nelem); | |
f075ee0c AM |
1748 | fprintf (f, " from %lu to %lu with %lu elements: ", |
1749 | (unsigned long) lower, (unsigned long) upper, | |
1750 | (unsigned long) nelem); | |
3af9a47b NC |
1751 | |
1752 | for (i = 0; i < nelem; i++) | |
1753 | { | |
1754 | fprintf (f, "\n "); | |
1755 | bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset); | |
1756 | } | |
1757 | break; | |
1758 | } | |
1759 | ||
1760 | case 6: | |
1761 | fprintf (f, "vector (0x%x)", type); | |
1762 | fprintf (f, "\n index "); | |
1763 | bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset); | |
1764 | fprintf (f, "\n target "); | |
1765 | bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset); | |
1766 | break; | |
1767 | ||
1768 | case 7: | |
1769 | case 8: | |
1770 | { | |
1771 | long nrec, eloff, i; | |
1772 | ||
1773 | if ((type & 0x3f) == 7) | |
1774 | fprintf (f, "record (0x%x) of ", type); | |
1775 | else | |
1776 | fprintf (f, "union (0x%x) of ", type); | |
e84d6fca AM |
1777 | |
1778 | bfd_sym_fetch_long (buf, len, offset, &offset, &nrec); | |
1779 | fprintf (f, "%lu elements: ", nrec); | |
3af9a47b NC |
1780 | |
1781 | for (i = 0; i < nrec; i++) | |
1782 | { | |
e84d6fca | 1783 | bfd_sym_fetch_long (buf, len, offset, &offset, &eloff); |
3af9a47b | 1784 | fprintf (f, "\n "); |
e84d6fca | 1785 | fprintf (f, "offset %lu: ", eloff); |
3af9a47b NC |
1786 | bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset); |
1787 | } | |
1788 | break; | |
1789 | } | |
1790 | ||
1791 | case 9: | |
1792 | fprintf (f, "subrange (0x%x) of ", type); | |
1793 | bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset); | |
1794 | fprintf (f, " lower "); | |
1795 | bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset); | |
1796 | fprintf (f, " upper "); | |
1797 | bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset); | |
1798 | break; | |
1799 | ||
1800 | case 11: | |
1801 | { | |
1802 | long value; | |
1803 | ||
1804 | fprintf (f, "named type (0x%x) ", type); | |
e84d6fca | 1805 | bfd_sym_fetch_long (buf, len, offset, &offset, &value); |
3af9a47b NC |
1806 | if (value <= 0) |
1807 | fprintf (f, "[INVALID]"); | |
1808 | else | |
e84d6fca | 1809 | fprintf (f, "\"%.*s\"", |
3af9a47b NC |
1810 | bfd_sym_symbol_name (abfd, value)[0], |
1811 | &bfd_sym_symbol_name (abfd, value)[1]); | |
1812 | ||
1813 | fprintf (f, " (NTE %lu) with type ", value); | |
1814 | bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset); | |
1815 | break; | |
1816 | } | |
1817 | ||
1818 | default: | |
1819 | fprintf (f, "%s (0x%x)", bfd_sym_type_operator_name (type), type); | |
1820 | break; | |
1821 | } | |
e84d6fca | 1822 | |
3af9a47b NC |
1823 | if (type == (0x40 | 0x6)) |
1824 | { | |
1825 | /* Vector. */ | |
1826 | long n, width, m; | |
1827 | long l; | |
1828 | long i; | |
1829 | ||
e84d6fca AM |
1830 | bfd_sym_fetch_long (buf, len, offset, &offset, &n); |
1831 | bfd_sym_fetch_long (buf, len, offset, &offset, &width); | |
1832 | bfd_sym_fetch_long (buf, len, offset, &offset, &m); | |
3af9a47b NC |
1833 | /* fprintf (f, "\n "); */ |
1834 | fprintf (f, " N %ld, width %ld, M %ld, ", n, width, m); | |
1835 | for (i = 0; i < m; i++) | |
1836 | { | |
e84d6fca | 1837 | bfd_sym_fetch_long (buf, len, offset, &offset, &l); |
3af9a47b NC |
1838 | if (i != 0) |
1839 | fprintf (f, " "); | |
1840 | fprintf (f, "%ld", l); | |
1841 | } | |
1842 | } | |
1843 | else if (type & 0x40) | |
1844 | { | |
1845 | /* Other packed type. */ | |
1846 | long msb, lsb; | |
1847 | ||
e84d6fca AM |
1848 | bfd_sym_fetch_long (buf, len, offset, &offset, &msb); |
1849 | bfd_sym_fetch_long (buf, len, offset, &offset, &lsb); | |
3af9a47b NC |
1850 | /* fprintf (f, "\n "); */ |
1851 | fprintf (f, " msb %ld, lsb %ld", msb, lsb); | |
1852 | } | |
1853 | ||
1854 | fprintf (f, "]"); | |
1855 | ||
1856 | if (offsetptr != NULL) | |
1857 | *offsetptr = offset; | |
1858 | } | |
1859 | ||
1860 | void | |
1861 | bfd_sym_print_type_information_table_entry (abfd, f, entry) | |
1862 | bfd *abfd; | |
1863 | FILE *f; | |
1864 | bfd_sym_type_information_table_entry *entry; | |
1865 | { | |
1866 | unsigned char *buf; | |
1867 | unsigned long offset; | |
1868 | unsigned int i; | |
1869 | ||
1870 | fprintf (f, "\"%.*s\" (NTE %lu), %lu bytes at %lu, logical size %lu", | |
1871 | bfd_sym_symbol_name (abfd, entry->nte_index)[0], | |
1872 | &bfd_sym_symbol_name (abfd, entry->nte_index)[1], | |
1873 | entry->nte_index, | |
1874 | entry->physical_size, entry->offset, entry->logical_size); | |
1875 | ||
e84d6fca | 1876 | fprintf (f, "\n "); |
3af9a47b NC |
1877 | |
1878 | buf = alloca (entry->physical_size); | |
1879 | if (buf == NULL) | |
1880 | { | |
1881 | fprintf (f, "[ERROR]\n"); | |
1882 | return; | |
1883 | } | |
1884 | if (bfd_seek (abfd, entry->offset, SEEK_SET) < 0) | |
1885 | { | |
1886 | fprintf (f, "[ERROR]\n"); | |
1887 | return; | |
1888 | } | |
1889 | if (bfd_bread (buf, entry->physical_size, abfd) != entry->physical_size) | |
1890 | { | |
1891 | fprintf (f, "[ERROR]\n"); | |
1892 | return; | |
1893 | } | |
1894 | ||
1895 | fprintf (f, "["); | |
1896 | for (i = 0; i < entry->physical_size; i++) | |
1897 | { | |
1898 | if (i == 0) | |
1899 | fprintf (f, "0x%02x", buf[i]); | |
1900 | else | |
1901 | fprintf (f, " 0x%02x", buf[i]); | |
1902 | } | |
1903 | ||
1904 | fprintf (f, "]"); | |
e84d6fca | 1905 | fprintf (f, "\n "); |
3af9a47b NC |
1906 | |
1907 | bfd_sym_print_type_information (abfd, f, buf, entry->physical_size, 0, &offset); | |
1908 | ||
1909 | if (offset != entry->physical_size) | |
1910 | fprintf (f, "\n [parser used %lu bytes instead of %lu]", offset, entry->physical_size); } | |
1911 | ||
1912 | void | |
1913 | bfd_sym_print_file_references_index_table_entry (abfd, f, entry) | |
1914 | bfd *abfd ATTRIBUTE_UNUSED; | |
1915 | FILE *f; | |
1916 | bfd_sym_file_references_index_table_entry *entry ATTRIBUTE_UNUSED; | |
1917 | { | |
1918 | fprintf (f, "[UNIMPLEMENTED]"); | |
1919 | } | |
1920 | ||
1921 | void | |
1922 | bfd_sym_print_constant_pool_entry (abfd, f, entry) | |
1923 | bfd *abfd ATTRIBUTE_UNUSED; | |
1924 | FILE *f; | |
1925 | bfd_sym_constant_pool_entry *entry ATTRIBUTE_UNUSED; | |
1926 | { | |
1927 | fprintf (f, "[UNIMPLEMENTED]"); | |
1928 | } | |
1929 | ||
1930 | unsigned char * | |
1931 | bfd_sym_display_name_table_entry (abfd, f, entry) | |
1932 | bfd *abfd; | |
1933 | FILE *f; | |
1934 | unsigned char *entry; | |
1935 | { | |
1936 | unsigned long index; | |
1937 | unsigned long offset; | |
1938 | bfd_sym_data_struct *sdata = NULL; | |
1939 | ||
1940 | BFD_ASSERT (bfd_sym_valid (abfd)); | |
1941 | sdata = abfd->tdata.sym_data; | |
1942 | index = (entry - sdata->name_table) / 2; | |
e84d6fca AM |
1943 | |
1944 | if (sdata->version >= BFD_SYM_VERSION_3_4 && entry[0] == 255 && entry[1] == 0) | |
3af9a47b | 1945 | { |
e84d6fca | 1946 | unsigned short length = bfd_getb16 (entry + 2); |
3af9a47b NC |
1947 | fprintf (f, "[%8lu] \"%.*s\"\n", index, length, entry + 4); |
1948 | offset = 2 + length + 1; | |
1949 | } | |
1950 | else | |
1951 | { | |
e84d6fca | 1952 | if (! (entry[0] == 0 || (entry[0] == 1 && entry[1] == '\0'))) |
3af9a47b NC |
1953 | fprintf (f, "[%8lu] \"%.*s\"\n", index, entry[0], entry + 1); |
1954 | ||
1955 | if (sdata->version >= BFD_SYM_VERSION_3_4) | |
1956 | offset = entry[0] + 2; | |
1957 | else | |
1958 | offset = entry[0] + 1; | |
1959 | } | |
1960 | ||
1961 | return (entry + offset + (offset % 2)); | |
1962 | } | |
1963 | ||
1964 | void | |
1965 | bfd_sym_display_name_table (abfd, f) | |
1966 | bfd *abfd; | |
1967 | FILE *f; | |
1968 | { | |
1969 | unsigned long name_table_len; | |
1970 | unsigned char *name_table, *name_table_end, *cur; | |
1971 | bfd_sym_data_struct *sdata = NULL; | |
1972 | ||
1973 | BFD_ASSERT (bfd_sym_valid (abfd)); | |
1974 | sdata = abfd->tdata.sym_data; | |
1975 | ||
1976 | name_table_len = sdata->header.dshb_nte.dti_page_count * sdata->header.dshb_page_size; | |
1977 | name_table = sdata->name_table; | |
1978 | name_table_end = name_table + name_table_len; | |
e84d6fca | 1979 | |
3af9a47b | 1980 | fprintf (f, "name table (NTE) contains %lu bytes:\n\n", name_table_len); |
e84d6fca | 1981 | |
3af9a47b NC |
1982 | cur = name_table; |
1983 | for (;;) | |
1984 | { | |
1985 | cur = bfd_sym_display_name_table_entry (abfd, f, cur); | |
1986 | if (cur >= name_table_end) | |
1987 | break; | |
1988 | } | |
1989 | } | |
1990 | ||
1991 | void | |
1992 | bfd_sym_display_resources_table (abfd, f) | |
1993 | bfd *abfd; | |
1994 | FILE *f; | |
1995 | { | |
1996 | unsigned long i; | |
1997 | bfd_sym_resources_table_entry entry; | |
1998 | bfd_sym_data_struct *sdata = NULL; | |
1999 | ||
2000 | BFD_ASSERT (bfd_sym_valid (abfd)); | |
2001 | sdata = abfd->tdata.sym_data; | |
2002 | ||
2003 | fprintf (f, "resource table (RTE) contains %lu objects:\n\n", | |
2004 | sdata->header.dshb_rte.dti_object_count); | |
e84d6fca | 2005 | |
3af9a47b NC |
2006 | for (i = 1; i <= sdata->header.dshb_rte.dti_object_count; i++) |
2007 | { | |
2008 | if (bfd_sym_fetch_resources_table_entry (abfd, &entry, i) < 0) | |
2009 | fprintf (f, " [%8lu] [INVALID]\n", i); | |
2010 | else | |
2011 | { | |
2012 | fprintf (f, " [%8lu] ", i); | |
2013 | bfd_sym_print_resources_table_entry (abfd, f, &entry); | |
2014 | fprintf (f, "\n"); | |
2015 | } | |
2016 | } | |
2017 | } | |
2018 | ||
2019 | void | |
2020 | bfd_sym_display_modules_table (abfd, f) | |
2021 | bfd *abfd; | |
2022 | FILE *f; | |
2023 | { | |
2024 | unsigned long i; | |
2025 | bfd_sym_modules_table_entry entry; | |
2026 | bfd_sym_data_struct *sdata = NULL; | |
2027 | ||
2028 | BFD_ASSERT (bfd_sym_valid (abfd)); | |
2029 | sdata = abfd->tdata.sym_data; | |
2030 | ||
2031 | fprintf (f, "module table (MTE) contains %lu objects:\n\n", | |
2032 | sdata->header.dshb_mte.dti_object_count); | |
2033 | ||
2034 | for (i = 1; i <= sdata->header.dshb_mte.dti_object_count; i++) | |
2035 | { | |
2036 | if (bfd_sym_fetch_modules_table_entry (abfd, &entry, i) < 0) | |
2037 | fprintf (f, " [%8lu] [INVALID]\n", i); | |
2038 | else | |
2039 | { | |
2040 | fprintf (f, " [%8lu] ", i); | |
2041 | bfd_sym_print_modules_table_entry (abfd, f, &entry); | |
2042 | fprintf (f, "\n"); | |
2043 | } | |
2044 | } | |
2045 | } | |
2046 | ||
2047 | void | |
2048 | bfd_sym_display_file_references_table (abfd, f) | |
2049 | bfd *abfd; | |
2050 | FILE *f; | |
2051 | { | |
2052 | unsigned long i; | |
2053 | bfd_sym_file_references_table_entry entry; | |
2054 | bfd_sym_data_struct *sdata = NULL; | |
2055 | ||
2056 | BFD_ASSERT (bfd_sym_valid (abfd)); | |
2057 | sdata = abfd->tdata.sym_data; | |
2058 | ||
2059 | fprintf (f, "file reference table (FRTE) contains %lu objects:\n\n", | |
2060 | sdata->header.dshb_frte.dti_object_count); | |
2061 | ||
2062 | for (i = 1; i <= sdata->header.dshb_frte.dti_object_count; i++) | |
2063 | { | |
2064 | if (bfd_sym_fetch_file_references_table_entry (abfd, &entry, i) < 0) | |
2065 | fprintf (f, " [%8lu] [INVALID]\n", i); | |
2066 | else | |
2067 | { | |
2068 | fprintf (f, " [%8lu] ", i); | |
2069 | bfd_sym_print_file_references_table_entry (abfd, f, &entry); | |
2070 | fprintf (f, "\n"); | |
2071 | } | |
2072 | } | |
2073 | } | |
2074 | ||
2075 | void | |
2076 | bfd_sym_display_contained_modules_table (abfd, f) | |
2077 | bfd *abfd; | |
2078 | FILE *f; | |
2079 | { | |
2080 | unsigned long i; | |
e84d6fca | 2081 | bfd_sym_contained_modules_table_entry entry; |
3af9a47b NC |
2082 | bfd_sym_data_struct *sdata = NULL; |
2083 | ||
2084 | BFD_ASSERT (bfd_sym_valid (abfd)); | |
2085 | sdata = abfd->tdata.sym_data; | |
2086 | ||
2087 | fprintf (f, "contained modules table (CMTE) contains %lu objects:\n\n", | |
2088 | sdata->header.dshb_cmte.dti_object_count); | |
e84d6fca | 2089 | |
3af9a47b NC |
2090 | for (i = 1; i <= sdata->header.dshb_cmte.dti_object_count; i++) |
2091 | { | |
2092 | if (bfd_sym_fetch_contained_modules_table_entry (abfd, &entry, i) < 0) | |
2093 | fprintf (f, " [%8lu] [INVALID]\n", i); | |
2094 | else | |
2095 | { | |
2096 | fprintf (f, " [%8lu] ", i); | |
2097 | bfd_sym_print_contained_modules_table_entry (abfd, f, &entry); | |
2098 | fprintf (f, "\n"); | |
2099 | } | |
2100 | } | |
2101 | } | |
2102 | ||
2103 | void | |
2104 | bfd_sym_display_contained_variables_table (abfd, f) | |
2105 | bfd *abfd; | |
2106 | FILE *f; | |
2107 | { | |
2108 | unsigned long i; | |
2109 | bfd_sym_contained_variables_table_entry entry; | |
2110 | bfd_sym_data_struct *sdata = NULL; | |
2111 | ||
2112 | BFD_ASSERT (bfd_sym_valid (abfd)); | |
2113 | sdata = abfd->tdata.sym_data; | |
2114 | ||
2115 | fprintf (f, "contained variables table (CVTE) contains %lu objects:\n\n", | |
2116 | sdata->header.dshb_cvte.dti_object_count); | |
e84d6fca | 2117 | |
3af9a47b NC |
2118 | for (i = 1; i <= sdata->header.dshb_cvte.dti_object_count; i++) |
2119 | { | |
2120 | if (bfd_sym_fetch_contained_variables_table_entry (abfd, &entry, i) < 0) | |
2121 | fprintf (f, " [%8lu] [INVALID]\n", i); | |
2122 | else | |
2123 | { | |
2124 | fprintf (f, " [%8lu] ", i); | |
2125 | bfd_sym_print_contained_variables_table_entry (abfd, f, &entry); | |
2126 | fprintf (f, "\n"); | |
2127 | } | |
2128 | } | |
2129 | ||
2130 | fprintf (f, "\n"); | |
2131 | } | |
2132 | ||
2133 | void | |
2134 | bfd_sym_display_contained_statements_table (abfd, f) | |
2135 | bfd *abfd; | |
2136 | FILE *f; | |
2137 | { | |
2138 | unsigned long i; | |
e84d6fca | 2139 | bfd_sym_contained_statements_table_entry entry; |
3af9a47b NC |
2140 | bfd_sym_data_struct *sdata = NULL; |
2141 | ||
2142 | BFD_ASSERT (bfd_sym_valid (abfd)); | |
2143 | sdata = abfd->tdata.sym_data; | |
2144 | ||
2145 | fprintf (f, "contained statements table (CSNTE) contains %lu objects:\n\n", | |
2146 | sdata->header.dshb_csnte.dti_object_count); | |
e84d6fca | 2147 | |
3af9a47b NC |
2148 | for (i = 1; i <= sdata->header.dshb_csnte.dti_object_count; i++) |
2149 | { | |
2150 | if (bfd_sym_fetch_contained_statements_table_entry (abfd, &entry, i) < 0) | |
2151 | fprintf (f, " [%8lu] [INVALID]\n", i); | |
2152 | else | |
2153 | { | |
2154 | fprintf (f, " [%8lu] ", i); | |
2155 | bfd_sym_print_contained_statements_table_entry (abfd, f, &entry); | |
2156 | fprintf (f, "\n"); | |
2157 | } | |
2158 | } | |
2159 | } | |
2160 | ||
2161 | void | |
2162 | bfd_sym_display_contained_labels_table (abfd, f) | |
2163 | bfd *abfd; | |
2164 | FILE *f; | |
2165 | { | |
2166 | unsigned long i; | |
2167 | bfd_sym_contained_labels_table_entry entry; | |
2168 | bfd_sym_data_struct *sdata = NULL; | |
2169 | ||
2170 | BFD_ASSERT (bfd_sym_valid (abfd)); | |
2171 | sdata = abfd->tdata.sym_data; | |
2172 | ||
2173 | fprintf (f, "contained labels table (CLTE) contains %lu objects:\n\n", | |
2174 | sdata->header.dshb_clte.dti_object_count); | |
e84d6fca | 2175 | |
3af9a47b NC |
2176 | for (i = 1; i <= sdata->header.dshb_clte.dti_object_count; i++) |
2177 | { | |
2178 | if (bfd_sym_fetch_contained_labels_table_entry (abfd, &entry, i) < 0) | |
2179 | fprintf (f, " [%8lu] [INVALID]\n", i); | |
2180 | else | |
2181 | { | |
2182 | fprintf (f, " [%8lu] ", i); | |
2183 | bfd_sym_print_contained_labels_table_entry (abfd, f, &entry); | |
2184 | fprintf (f, "\n"); | |
2185 | } | |
2186 | } | |
2187 | } | |
2188 | ||
2189 | void | |
2190 | bfd_sym_display_contained_types_table (abfd, f) | |
2191 | bfd *abfd; | |
2192 | FILE *f; | |
2193 | { | |
2194 | unsigned long i; | |
e84d6fca | 2195 | bfd_sym_contained_types_table_entry entry; |
3af9a47b NC |
2196 | bfd_sym_data_struct *sdata = NULL; |
2197 | ||
2198 | BFD_ASSERT (bfd_sym_valid (abfd)); | |
2199 | sdata = abfd->tdata.sym_data; | |
2200 | ||
2201 | fprintf (f, "contained types table (CTTE) contains %lu objects:\n\n", | |
2202 | sdata->header.dshb_ctte.dti_object_count); | |
e84d6fca | 2203 | |
3af9a47b NC |
2204 | for (i = 1; i <= sdata->header.dshb_ctte.dti_object_count; i++) |
2205 | { | |
2206 | if (bfd_sym_fetch_contained_types_table_entry (abfd, &entry, i) < 0) | |
2207 | fprintf (f, " [%8lu] [INVALID]\n", i); | |
2208 | else | |
2209 | { | |
2210 | fprintf (f, " [%8lu] ", i); | |
2211 | bfd_sym_print_contained_types_table_entry (abfd, f, &entry); | |
2212 | fprintf (f, "\n"); | |
2213 | } | |
2214 | } | |
2215 | } | |
2216 | ||
2217 | void | |
2218 | bfd_sym_display_file_references_index_table (abfd, f) | |
2219 | bfd *abfd; | |
2220 | FILE *f; | |
2221 | { | |
2222 | unsigned long i; | |
e84d6fca | 2223 | bfd_sym_file_references_index_table_entry entry; |
3af9a47b NC |
2224 | bfd_sym_data_struct *sdata = NULL; |
2225 | ||
2226 | BFD_ASSERT (bfd_sym_valid (abfd)); | |
2227 | sdata = abfd->tdata.sym_data; | |
2228 | ||
2229 | fprintf (f, "file references index table (FITE) contains %lu objects:\n\n", | |
2230 | sdata->header.dshb_fite.dti_object_count); | |
e84d6fca | 2231 | |
3af9a47b NC |
2232 | for (i = 1; i <= sdata->header.dshb_fite.dti_object_count; i++) |
2233 | { | |
2234 | if (bfd_sym_fetch_file_references_index_table_entry (abfd, &entry, i) < 0) | |
2235 | fprintf (f, " [%8lu] [INVALID]\n", i); | |
2236 | else | |
2237 | { | |
2238 | fprintf (f, " [%8lu] ", i); | |
2239 | bfd_sym_print_file_references_index_table_entry (abfd, f, &entry); | |
2240 | fprintf (f, "\n"); | |
2241 | } | |
2242 | } | |
2243 | } | |
2244 | ||
2245 | void | |
2246 | bfd_sym_display_constant_pool (abfd, f) | |
2247 | bfd *abfd; | |
2248 | FILE *f; | |
2249 | { | |
2250 | unsigned long i; | |
e84d6fca | 2251 | bfd_sym_constant_pool_entry entry; |
3af9a47b NC |
2252 | bfd_sym_data_struct *sdata = NULL; |
2253 | ||
2254 | BFD_ASSERT (bfd_sym_valid (abfd)); | |
2255 | sdata = abfd->tdata.sym_data; | |
2256 | ||
2257 | fprintf (f, "constant pool (CONST) contains %lu objects:\n\n", | |
2258 | sdata->header.dshb_const.dti_object_count); | |
e84d6fca | 2259 | |
3af9a47b NC |
2260 | for (i = 1; i <= sdata->header.dshb_const.dti_object_count; i++) |
2261 | { | |
2262 | if (bfd_sym_fetch_constant_pool_entry (abfd, &entry, i) < 0) | |
2263 | fprintf (f, " [%8lu] [INVALID]\n", i); | |
2264 | else | |
2265 | { | |
2266 | fprintf (f, " [%8lu] ", i); | |
2267 | bfd_sym_print_constant_pool_entry (abfd, f, &entry); | |
2268 | fprintf (f, "\n"); | |
2269 | } | |
2270 | } | |
2271 | } | |
2272 | ||
2273 | void | |
2274 | bfd_sym_display_type_information_table (abfd, f) | |
2275 | bfd *abfd; | |
2276 | FILE *f; | |
2277 | { | |
2278 | unsigned long i; | |
2279 | bfd_sym_type_table_entry index; | |
e84d6fca | 2280 | bfd_sym_type_information_table_entry entry; |
3af9a47b NC |
2281 | bfd_sym_data_struct *sdata = NULL; |
2282 | ||
2283 | BFD_ASSERT (bfd_sym_valid (abfd)); | |
2284 | sdata = abfd->tdata.sym_data; | |
2285 | ||
2286 | if (sdata->header.dshb_tte.dti_object_count > 99) | |
2287 | fprintf (f, "type table (TINFO) contains %lu objects:\n\n", | |
2288 | sdata->header.dshb_tte.dti_object_count - 99); | |
2289 | else | |
2290 | { | |
2291 | fprintf (f, "type table (TINFO) contains [INVALID] objects:\n\n"); | |
2292 | return; | |
2293 | } | |
e84d6fca | 2294 | |
3af9a47b NC |
2295 | for (i = 100; i <= sdata->header.dshb_tte.dti_object_count; i++) |
2296 | { | |
2297 | if (bfd_sym_fetch_type_table_entry (abfd, &index, i - 100) < 0) | |
2298 | fprintf (f, " [%8lu] [INVALID]\n", i); | |
2299 | else | |
2300 | { | |
2301 | fprintf (f, " [%8lu] (TINFO %lu) ", i, index); | |
2302 | ||
2303 | if (bfd_sym_fetch_type_information_table_entry (abfd, &entry, index) < 0) | |
2304 | fprintf (f, "[INVALID]"); | |
2305 | else | |
2306 | bfd_sym_print_type_information_table_entry (abfd, f, &entry); | |
2307 | ||
2308 | fprintf (f, "\n"); | |
2309 | } | |
2310 | } | |
2311 | } | |
2312 | ||
e84d6fca AM |
2313 | int |
2314 | bfd_sym_scan (abfd, version, mdata) | |
3af9a47b | 2315 | bfd *abfd; |
e84d6fca AM |
2316 | bfd_sym_version version; |
2317 | bfd_sym_data_struct *mdata; | |
3af9a47b | 2318 | { |
3af9a47b NC |
2319 | asection *bfdsec; |
2320 | const char *name = "symbols"; | |
3af9a47b NC |
2321 | |
2322 | mdata->name_table = 0; | |
2323 | mdata->sbfd = abfd; | |
e84d6fca | 2324 | mdata->version = version; |
3af9a47b | 2325 | |
3af9a47b NC |
2326 | bfd_seek (abfd, 0, SEEK_SET); |
2327 | if (bfd_sym_read_header (abfd, &mdata->header, mdata->version) != 0) | |
e84d6fca | 2328 | return -1; |
3af9a47b NC |
2329 | |
2330 | mdata->name_table = bfd_sym_read_name_table (abfd, &mdata->header); | |
2331 | if (mdata->name_table == NULL) | |
e84d6fca | 2332 | return -1; |
3af9a47b NC |
2333 | |
2334 | bfdsec = bfd_make_section_anyway (abfd, name); | |
2335 | if (bfdsec == NULL) | |
e84d6fca AM |
2336 | return -1; |
2337 | ||
3af9a47b NC |
2338 | bfdsec->vma = 0; |
2339 | bfdsec->lma = 0; | |
eea6121a | 2340 | bfdsec->size = 0; |
3af9a47b NC |
2341 | bfdsec->filepos = 0; |
2342 | bfdsec->alignment_power = 0; | |
e84d6fca | 2343 | |
3af9a47b NC |
2344 | bfdsec->flags = SEC_HAS_CONTENTS; |
2345 | ||
e84d6fca AM |
2346 | abfd->tdata.sym_data = mdata; |
2347 | ||
2348 | return 0; | |
2349 | } | |
2350 | ||
2351 | const bfd_target * | |
2352 | bfd_sym_object_p (abfd) | |
2353 | bfd *abfd; | |
2354 | { | |
2355 | struct bfd_preserve preserve; | |
2356 | bfd_sym_version version = -1; | |
2357 | ||
2358 | preserve.marker = NULL; | |
2359 | bfd_seek (abfd, 0, SEEK_SET); | |
2360 | if (bfd_sym_read_version (abfd, &version) != 0) | |
2361 | goto wrong; | |
2362 | ||
2363 | preserve.marker = bfd_alloc (abfd, sizeof (bfd_sym_data_struct)); | |
2364 | if (preserve.marker == NULL | |
2365 | || ! bfd_preserve_save (abfd, &preserve)) | |
2366 | goto fail; | |
2367 | ||
2368 | if (bfd_sym_scan (abfd, version, | |
2369 | (bfd_sym_data_struct *) preserve.marker) != 0) | |
2370 | goto wrong; | |
2371 | ||
2372 | bfd_preserve_finish (abfd, &preserve); | |
3af9a47b | 2373 | return abfd->xvec; |
e84d6fca AM |
2374 | |
2375 | wrong: | |
2376 | bfd_set_error (bfd_error_wrong_format); | |
2377 | ||
2378 | fail: | |
2379 | if (preserve.marker != NULL) | |
2380 | bfd_preserve_restore (abfd, &preserve); | |
2381 | return NULL; | |
3af9a47b NC |
2382 | } |
2383 | ||
2384 | asymbol * | |
2385 | bfd_sym_make_empty_symbol (abfd) | |
2386 | bfd *abfd; | |
2387 | { | |
2388 | return (asymbol *) bfd_alloc (abfd, sizeof (asymbol)); | |
2389 | } | |
2390 | ||
2391 | void | |
2392 | bfd_sym_get_symbol_info (abfd, symbol, ret) | |
2393 | bfd *abfd ATTRIBUTE_UNUSED; | |
2394 | asymbol *symbol; | |
2395 | symbol_info *ret; | |
2396 | { | |
2397 | bfd_symbol_info (symbol, ret); | |
2398 | } | |
2399 | ||
2400 | long | |
2401 | bfd_sym_get_symtab_upper_bound (abfd) | |
2402 | bfd *abfd ATTRIBUTE_UNUSED; | |
2403 | { | |
2404 | return 0; | |
2405 | } | |
2406 | ||
2407 | long | |
6cee3f79 | 2408 | bfd_sym_canonicalize_symtab (abfd, sym) |
3af9a47b NC |
2409 | bfd *abfd ATTRIBUTE_UNUSED; |
2410 | asymbol **sym ATTRIBUTE_UNUSED; | |
2411 | { | |
2412 | return 0; | |
2413 | } | |
2414 | ||
2415 | int | |
2416 | bfd_sym_sizeof_headers (abfd, exec) | |
2417 | bfd *abfd ATTRIBUTE_UNUSED; | |
b34976b6 | 2418 | bfd_boolean exec ATTRIBUTE_UNUSED; |
3af9a47b NC |
2419 | { |
2420 | return 0; | |
2421 | } | |
2422 | ||
2423 | const bfd_target sym_vec = | |
2424 | { | |
2425 | "sym", /* name */ | |
2426 | bfd_target_sym_flavour, /* flavour */ | |
2427 | BFD_ENDIAN_BIG, /* byteorder */ | |
2428 | BFD_ENDIAN_BIG, /* header_byteorder */ | |
2429 | (HAS_RELOC | EXEC_P | /* object flags */ | |
2430 | HAS_LINENO | HAS_DEBUG | | |
2431 | HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED), | |
2432 | (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE | SEC_DATA | |
2433 | | SEC_ROM | SEC_HAS_CONTENTS), /* section_flags */ | |
2434 | 0, /* symbol_leading_char */ | |
2435 | ' ', /* ar_pad_char */ | |
2436 | 16, /* ar_max_namelen */ | |
2437 | bfd_getb64, bfd_getb_signed_64, bfd_putb64, | |
2438 | bfd_getb32, bfd_getb_signed_32, bfd_putb32, | |
2439 | bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */ | |
2440 | bfd_getb64, bfd_getb_signed_64, bfd_putb64, | |
2441 | bfd_getb32, bfd_getb_signed_32, bfd_putb32, | |
2442 | bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */ | |
2443 | { /* bfd_check_format */ | |
2444 | _bfd_dummy_target, | |
2445 | bfd_sym_object_p, /* bfd_check_format */ | |
2446 | _bfd_dummy_target, | |
2447 | _bfd_dummy_target, | |
2448 | }, | |
2449 | { /* bfd_set_format */ | |
2450 | bfd_false, | |
2451 | bfd_sym_mkobject, | |
2452 | bfd_false, | |
2453 | bfd_false, | |
2454 | }, | |
2455 | { /* bfd_write_contents */ | |
2456 | bfd_false, | |
2457 | bfd_true, | |
2458 | bfd_false, | |
2459 | bfd_false, | |
2460 | }, | |
2461 | ||
2462 | BFD_JUMP_TABLE_GENERIC (bfd_sym), | |
2463 | BFD_JUMP_TABLE_COPY (_bfd_generic), | |
2464 | BFD_JUMP_TABLE_CORE (_bfd_nocore), | |
2465 | BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive), | |
2466 | BFD_JUMP_TABLE_SYMBOLS (bfd_sym), | |
2467 | BFD_JUMP_TABLE_RELOCS (bfd_sym), | |
2468 | BFD_JUMP_TABLE_WRITE (bfd_sym), | |
2469 | BFD_JUMP_TABLE_LINK (bfd_sym), | |
2470 | BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), | |
2471 | ||
2472 | NULL, | |
e84d6fca | 2473 | |
3af9a47b NC |
2474 | NULL |
2475 | }; | |
2476 |