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