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