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