FreeCalypso > hg > freecalypso-reveng
annotate leo-obj/tool/richsym.c @ 149:fdf3137c703a
tiobjd richsym handling: prep for handling function locals
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Tue, 29 Apr 2014 07:11:33 +0000 |
parents | 13cc7e19ecec |
children | df01a4f4c272 |
rev | line source |
---|---|
144
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * Code for working with the "rich" symbolic info |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 * present in TI's GPF libraries |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 */ |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 #include <sys/types.h> |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 #include <stdio.h> |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 #include <stdlib.h> |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 #include <string.h> |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 #include <strings.h> |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 #include "intstruct.h" |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 #include "coffconst.h" |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 #include "globals.h" |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 extern unsigned get_u16(), get_u32(); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 extern char *storage_class_to_string(); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 |
145
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
18 int richsym_print_bitsize; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
19 |
144
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 static int |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 try_typedef_hack(struct_sym) |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 struct internal_syment *struct_sym; |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 { |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 unsigned tpdef_cand; |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 struct internal_syment *tpdef_sym; |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 if (!struct_sym->aux) |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 return(0); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 tpdef_cand = get_u32(struct_sym->aux + 12); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 if (tpdef_cand >= nsymtab) |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 return(0); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 tpdef_sym = symtab[tpdef_cand]; |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 if (!tpdef_sym) |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 return(0); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 if (tpdef_sym->class != C_TPDEF) |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 return(0); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 if (tpdef_sym->type != struct_sym->type) |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 return(0); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 if (tpdef_sym->name[0] != '_') |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 return(0); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 if (!tpdef_sym->aux) |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 return(0); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 if (get_u32(tpdef_sym->aux) != struct_sym->number) |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 return(0); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 struct_sym->struct_name = tpdef_sym->name + 1; |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 return(1); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 } |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 static void |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 preen_strtag_sym(sym, kw, expect_type) |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 struct internal_syment *sym; |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 char *kw; |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 { |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 char *buf; |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 int isund, len; |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
57 isund = (sym->name[0] == '_'); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 len = strlen(kw) + 1 + strlen(sym->name) + 1; |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 if (isund) |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 len--; |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 else |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 len += 2; |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 buf = malloc(len); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
64 if (!buf) { |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
65 perror("malloc"); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
66 exit(1); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
67 } |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
68 if (isund) |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
69 sprintf(buf, "%s %s", kw, sym->name + 1); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
70 else |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
71 sprintf(buf, "%s \"%s\"", kw, sym->name); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
72 sym->struct_name = buf; |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
73 sym->struct_name_raw = buf; |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
74 if (sym->type != expect_type) { |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
75 fprintf(stderr, |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
76 "warning: type/class mismatch on tag symbol #%u\n", |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
77 sym->number); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
78 return; |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
79 } |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
80 if (isund) |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
81 return; |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
82 try_typedef_hack(sym); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
83 } |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
84 |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
85 richsym_initial_preen() |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
86 { |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
87 unsigned n; |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
88 struct internal_syment *sym; |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
89 |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
90 for (n = 0; n < nsymtab; n++) { |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
91 sym = symtab[n]; |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
92 if (!sym) |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
93 continue; |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
94 switch (sym->class) { |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
95 case C_STRTAG: |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
96 preen_strtag_sym(sym, "struct", T_STRUCT); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
97 continue; |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
98 case C_UNTAG: |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
99 preen_strtag_sym(sym, "union", T_UNION); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
100 continue; |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
101 case C_ENTAG: |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
102 preen_strtag_sym(sym, "enum", T_ENUM); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
103 continue; |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
104 } |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
105 } |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
106 } |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
107 |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
108 char * |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
109 get_struct_type_name(idx, expect_class, is_typedef) |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
110 unsigned idx; |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
111 { |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
112 struct internal_syment *sym; |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
113 |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
114 if (idx >= nsymtab) { |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
115 inv_idx: fprintf(stderr, |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
116 "error: ref to invalid syment #%u for struct tag\n", |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
117 idx); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
118 exit(1); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
119 } |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
120 sym = symtab[idx]; |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
121 if (!sym) |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
122 goto inv_idx; |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
123 if (sym->class != expect_class) { |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
124 fprintf(stderr, |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
125 "error: ref to syment #%u for struct tag, class != %s\n", |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
126 idx, storage_class_to_string(expect_class, 0)); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
127 exit(1); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
128 } |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
129 if (is_typedef) |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
130 return(sym->struct_name_raw); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
131 else |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
132 return(sym->struct_name); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
133 } |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
134 |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
135 char * |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
136 get_base_type_of_syment(sym, is_typedef) |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
137 struct internal_syment *sym; |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
138 { |
149
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
139 unsigned idx; |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
140 |
144
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
141 switch (sym->type & 0xF) { |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
142 case T_VOID: |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
143 return("void"); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
144 case T_CHAR: |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
145 if (is_typedef) |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
146 return("signed char"); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
147 else |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
148 return("char"); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
149 case T_SHORT: |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
150 return("short"); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
151 case T_INT: |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
152 return("int"); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
153 case T_LONG: |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
154 return("long"); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
155 case T_FLOAT: |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
156 return("float"); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
157 case T_DOUBLE: |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
158 return("double"); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
159 case T_STRUCT: |
149
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
160 idx = get_u32(sym->aux); |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
161 if (idx) |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
162 return get_struct_type_name(idx, C_STRTAG, is_typedef); |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
163 else |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
164 return("struct ?"); |
144
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
165 case T_UNION: |
149
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
166 idx = get_u32(sym->aux); |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
167 if (idx) |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
168 return get_struct_type_name(idx, C_UNTAG, is_typedef); |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
169 else |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
170 return("union ?"); |
144
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
171 case T_ENUM: |
149
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
172 idx = get_u32(sym->aux); |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
173 if (idx) |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
174 return get_struct_type_name(idx, C_ENTAG, is_typedef); |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
175 else |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
176 return("enum ?"); |
144
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
177 case T_UCHAR: |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
178 if (is_typedef) |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
179 return("unsigned char"); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
180 else |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
181 return("u_char"); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
182 case T_USHORT: |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
183 if (is_typedef) |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
184 return("unsigned short"); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
185 else |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
186 return("u_short"); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
187 case T_UINT: |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
188 return("unsigned"); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
189 case T_ULONG: |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
190 if (is_typedef) |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
191 return("unsigned long"); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
192 else |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
193 return("u_long"); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
194 default: |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
195 return("__unknown_base_type"); |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
196 } |
fd772de226cb
tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
197 } |
145
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
198 |
149
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
199 static char * |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
200 cdecl_obj_name(sym) |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
201 struct internal_syment *sym; |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
202 { |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
203 char *buf; |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
204 int isund, len; |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
205 |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
206 isund = (sym->name[0] == '_'); |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
207 len = strlen(sym->name) + 1; |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
208 if (isund) |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
209 len--; |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
210 else |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
211 len += 2; |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
212 buf = malloc(len); |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
213 if (!buf) { |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
214 perror("malloc"); |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
215 exit(1); |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
216 } |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
217 if (isund) |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
218 strcpy(buf, sym->name + 1); |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
219 else |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
220 sprintf(buf, "\"%s\"", sym->name); |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
221 return(buf); |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
222 } |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
223 |
145
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
224 richsym_print_in_c(prefix, sym, is_typedef) |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
225 char *prefix; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
226 struct internal_syment *sym; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
227 { |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
228 char *base_type, *s1, *s2; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
229 int dertype, last_ptr, narray; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
230 |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
231 base_type = get_base_type_of_syment(sym, is_typedef); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
232 dertype = sym->type >> 4; |
149
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
233 s1 = cdecl_obj_name(sym); |
145
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
234 last_ptr = 0; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
235 narray = 0; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
236 for (; dertype; dertype >>= 2) { |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
237 switch (dertype & 3) { |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
238 case DT_NON: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
239 fprintf(stderr, |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
240 "error: symbol #%u: DT_NON followed by more derived types\n", |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
241 sym->number); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
242 exit(1); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
243 case DT_PTR: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
244 s2 = malloc(strlen(s1) + 2); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
245 if (!s2) { |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
246 perror("malloc"); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
247 exit(1); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
248 } |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
249 sprintf(s2, "*%s", s1); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
250 free(s1); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
251 s1 = s2; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
252 last_ptr = 1; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
253 continue; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
254 } |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
255 if (last_ptr) { |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
256 s2 = malloc(strlen(s1) + 3); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
257 if (!s2) { |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
258 perror("malloc"); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
259 exit(1); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
260 } |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
261 sprintf(s2, "(%s)", s1); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
262 free(s1); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
263 s1 = s2; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
264 } |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
265 switch (dertype & 3) { |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
266 case DT_FCN: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
267 s2 = malloc(strlen(s1) + 3); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
268 if (!s2) { |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
269 perror("malloc"); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
270 exit(1); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
271 } |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
272 sprintf(s2, "%s()", s1); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
273 free(s1); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
274 s1 = s2; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
275 break; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
276 case DT_ARY: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
277 if (narray >= 4) { |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
278 fprintf(stderr, |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
279 "error: symbol #%u: too many [] types\n", |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
280 sym->number); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
281 exit(1); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
282 } |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
283 s2 = malloc(strlen(s1) + 8); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
284 if (!s2) { |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
285 perror("malloc"); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
286 exit(1); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
287 } |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
288 sprintf(s2, "%s[%u]", s1, |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
289 get_u16(sym->aux + 8 + narray * 2)); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
290 free(s1); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
291 s1 = s2; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
292 narray++; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
293 break; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
294 default: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
295 fprintf(stderr, |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
296 "BUG in richsym_print_in_c(): bad derived type\n"); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
297 exit(1); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
298 } |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
299 last_ptr = 0; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
300 } |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
301 printf("%s%s %s;", prefix, base_type, s1); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
302 free(s1); |
148
13cc7e19ecec
tiobjd disasm -g: support -b as well
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
146
diff
changeset
|
303 if (richsym_print_bitsize && (sym->type & 0x30) != 0x20) |
145
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
304 printf("\t/* %u bits */", get_u32(sym->aux + 4)); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
305 putchar('\n'); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
306 } |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
307 |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
308 cmd_ctypes(argc, argv) |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
309 char **argv; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
310 { |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
311 int c; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
312 unsigned n; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
313 struct internal_syment *sym; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
314 |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
315 while ((c = getopt(argc, argv, "b")) != EOF) |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
316 switch (c) { |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
317 case 'b': |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
318 richsym_print_bitsize++; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
319 continue; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
320 default: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
321 /* error msg already printed */ |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
322 exit(1); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
323 } |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
324 |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
325 get_int_section_table(); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
326 get_int_symbol_table(); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
327 richsym_initial_preen(); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
328 for (n = 0; n < nsymtab; n++) { |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
329 sym = symtab[n]; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
330 if (!sym) |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
331 continue; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
332 switch (sym->class) { |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
333 case C_FILE: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
334 printf("/* from %s */\n", sym->name); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
335 continue; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
336 case C_STRTAG: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
337 case C_UNTAG: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
338 case C_ENTAG: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
339 printf("%s {", sym->struct_name_raw); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
340 if (richsym_print_bitsize && sym->aux) |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
341 printf("\t/* %u bits */", get_u32(sym->aux+4)); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
342 putchar('\n'); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
343 continue; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
344 case C_EOS: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
345 fputs("};", stdout); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
346 if (richsym_print_bitsize && sym->aux) |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
347 printf("\t/* %u bits */", get_u32(sym->aux+4)); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
348 putchar('\n'); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
349 continue; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
350 case C_MOS: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
351 case C_MOU: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
352 case C_MOE: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
353 case C_TPDEF: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
354 break; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
355 default: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
356 continue; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
357 } |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
358 if (sym->name[0] != '_') { |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
359 printf( |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
360 "/* symbol #%u of class %s has no leading underscore */\n", |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
361 sym->number, |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
362 storage_class_to_string(sym->class, 0)); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
363 continue; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
364 } |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
365 if (!sym->aux && sym->class != C_MOE) { |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
366 printf( |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
367 "/* symbol #%u of class %s has no aux record */\n", |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
368 sym->number, |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
369 storage_class_to_string(sym->class, 0)); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
370 continue; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
371 } |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
372 switch (sym->class) { |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
373 case C_MOS: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
374 case C_MOU: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
375 if (sym->scnum != -1) |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
376 printf("\t/* MOS/MOU section != ABS! */\n"); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
377 else if (richsym_print_bitsize >= 2) |
146
70631c246df0
tiobjd ctypes: buglet in the -bb mode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
145
diff
changeset
|
378 printf("\t/* offset: %u bits */\n", sym->value); |
145
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
379 richsym_print_in_c("\t", sym, 0); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
380 continue; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
381 case C_MOE: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
382 if (sym->scnum != -1) { |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
383 printf("\t/* MOE section != ABS! */\n"); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
384 continue; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
385 } |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
386 printf("\t%s = %u;", sym->name + 1, sym->value); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
387 if (sym->value >= 10) |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
388 printf("\t/* 0x%x */", sym->value); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
389 putchar('\n'); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
390 continue; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
391 case C_TPDEF: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
392 richsym_print_in_c("typedef ", sym, |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
393 !(sym->type & 0xFFF0)); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
394 continue; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
395 } |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
396 } |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
397 exit(0); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
398 } |