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