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