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