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