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