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