FreeCalypso > hg > freecalypso-reveng
annotate leo-obj/tool/richsym.c @ 208:f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
author | Mychaela Falconia <falcon@ivan.Harhan.ORG> |
---|---|
date | Fri, 04 Mar 2016 23:36:16 +0000 |
parents | 15743b40e03a |
children |
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 |
208
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
3 * present in TI's GPF libraries and L1 objects |
144
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 |
150
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
206 switch (sym->name[0]) { |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
207 case '_': |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
208 isund = 1; |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
209 break; |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
210 case '$': |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
211 if ((sym->type & 0x30) == 0x20) |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
212 isund = 1; |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
213 else |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
214 isund = 0; |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
215 break; |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
216 default: |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
217 isund = 0; |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
218 } |
149
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
219 len = strlen(sym->name) + 1; |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
220 if (isund) |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
221 len--; |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
222 else |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
223 len += 2; |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
224 buf = malloc(len); |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
225 if (!buf) { |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
226 perror("malloc"); |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
227 exit(1); |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
228 } |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
229 if (isund) |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
230 strcpy(buf, sym->name + 1); |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
231 else |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
232 sprintf(buf, "\"%s\"", sym->name); |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
233 return(buf); |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
234 } |
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
235 |
145
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
236 richsym_print_in_c(prefix, sym, is_typedef) |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
237 char *prefix; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
238 struct internal_syment *sym; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
239 { |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
240 char *base_type, *s1, *s2; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
241 int dertype, last_ptr, narray; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
242 |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
243 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
|
244 dertype = sym->type >> 4; |
149
fdf3137c703a
tiobjd richsym handling: prep for handling function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
148
diff
changeset
|
245 s1 = cdecl_obj_name(sym); |
145
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
246 last_ptr = 0; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
247 narray = 0; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
248 for (; dertype; dertype >>= 2) { |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
249 switch (dertype & 3) { |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
250 case DT_NON: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
251 fprintf(stderr, |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
252 "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
|
253 sym->number); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
254 exit(1); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
255 case DT_PTR: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
256 s2 = malloc(strlen(s1) + 2); |
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 last_ptr = 1; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
265 continue; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
266 } |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
267 if (last_ptr) { |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
268 s2 = malloc(strlen(s1) + 3); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
269 if (!s2) { |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
270 perror("malloc"); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
271 exit(1); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
272 } |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
273 sprintf(s2, "(%s)", s1); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
274 free(s1); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
275 s1 = s2; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
276 } |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
277 switch (dertype & 3) { |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
278 case DT_FCN: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
279 s2 = malloc(strlen(s1) + 3); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
280 if (!s2) { |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
281 perror("malloc"); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
282 exit(1); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
283 } |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
284 sprintf(s2, "%s()", s1); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
285 free(s1); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
286 s1 = s2; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
287 break; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
288 case DT_ARY: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
289 if (narray >= 4) { |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
290 fprintf(stderr, |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
291 "error: symbol #%u: too many [] types\n", |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
292 sym->number); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
293 exit(1); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
294 } |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
295 s2 = malloc(strlen(s1) + 8); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
296 if (!s2) { |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
297 perror("malloc"); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
298 exit(1); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
299 } |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
300 sprintf(s2, "%s[%u]", s1, |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
301 get_u16(sym->aux + 8 + narray * 2)); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
302 free(s1); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
303 s1 = s2; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
304 narray++; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
305 break; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
306 default: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
307 fprintf(stderr, |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
308 "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
|
309 exit(1); |
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 last_ptr = 0; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
312 } |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
313 printf("%s%s %s;", prefix, base_type, s1); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
314 free(s1); |
148
13cc7e19ecec
tiobjd disasm -g: support -b as well
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
146
diff
changeset
|
315 if (richsym_print_bitsize && (sym->type & 0x30) != 0x20) |
145
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
316 printf("\t/* %u bits */", get_u32(sym->aux + 4)); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
317 putchar('\n'); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
318 } |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
319 |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
320 cmd_ctypes(argc, argv) |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
321 char **argv; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
322 { |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
323 int c; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
324 unsigned n; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
325 struct internal_syment *sym; |
155
15743b40e03a
tiobjd ctypes: print more useful hex byte offsets for struct fields
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
151
diff
changeset
|
326 int print_offsets = 0; |
145
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
327 |
155
15743b40e03a
tiobjd ctypes: print more useful hex byte offsets for struct fields
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
151
diff
changeset
|
328 while ((c = getopt(argc, argv, "bo")) != EOF) |
145
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
329 switch (c) { |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
330 case 'b': |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
331 richsym_print_bitsize++; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
332 continue; |
155
15743b40e03a
tiobjd ctypes: print more useful hex byte offsets for struct fields
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
151
diff
changeset
|
333 case 'o': |
15743b40e03a
tiobjd ctypes: print more useful hex byte offsets for struct fields
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
151
diff
changeset
|
334 print_offsets++; |
15743b40e03a
tiobjd ctypes: print more useful hex byte offsets for struct fields
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
151
diff
changeset
|
335 continue; |
145
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
336 default: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
337 /* error msg already printed */ |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
338 exit(1); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
339 } |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
340 |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
341 get_int_section_table(); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
342 get_int_symbol_table(); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
343 richsym_initial_preen(); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
344 for (n = 0; n < nsymtab; n++) { |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
345 sym = symtab[n]; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
346 if (!sym) |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
347 continue; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
348 switch (sym->class) { |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
349 case C_FILE: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
350 printf("/* from %s */\n", sym->name); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
351 continue; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
352 case C_STRTAG: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
353 case C_UNTAG: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
354 case C_ENTAG: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
355 printf("%s {", sym->struct_name_raw); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
356 if (richsym_print_bitsize && sym->aux) |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
357 printf("\t/* %u bits */", get_u32(sym->aux+4)); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
358 putchar('\n'); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
359 continue; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
360 case C_EOS: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
361 fputs("};", stdout); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
362 if (richsym_print_bitsize && sym->aux) |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
363 printf("\t/* %u bits */", get_u32(sym->aux+4)); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
364 putchar('\n'); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
365 continue; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
366 case C_MOS: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
367 case C_MOU: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
368 case C_MOE: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
369 case C_TPDEF: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
370 break; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
371 default: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
372 continue; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
373 } |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
374 if (sym->name[0] != '_') { |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
375 printf( |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
376 "/* 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
|
377 sym->number, |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
378 storage_class_to_string(sym->class, 0)); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
379 continue; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
380 } |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
381 if (!sym->aux && sym->class != C_MOE) { |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
382 printf( |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
383 "/* 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
|
384 sym->number, |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
385 storage_class_to_string(sym->class, 0)); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
386 continue; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
387 } |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
388 switch (sym->class) { |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
389 case C_MOS: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
390 case C_MOU: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
391 if (sym->scnum != -1) |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
392 printf("\t/* MOS/MOU section != ABS! */\n"); |
155
15743b40e03a
tiobjd ctypes: print more useful hex byte offsets for struct fields
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
151
diff
changeset
|
393 else if (print_offsets && !(sym->value & 7)) |
15743b40e03a
tiobjd ctypes: print more useful hex byte offsets for struct fields
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
151
diff
changeset
|
394 printf("\t/* offset: 0x%x */\n", |
15743b40e03a
tiobjd ctypes: print more useful hex byte offsets for struct fields
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
151
diff
changeset
|
395 sym->value >> 3); |
15743b40e03a
tiobjd ctypes: print more useful hex byte offsets for struct fields
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
151
diff
changeset
|
396 else if (print_offsets || richsym_print_bitsize >= 2) |
146
70631c246df0
tiobjd ctypes: buglet in the -bb mode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
145
diff
changeset
|
397 printf("\t/* offset: %u bits */\n", sym->value); |
145
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
398 richsym_print_in_c("\t", sym, 0); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
399 continue; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
400 case C_MOE: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
401 if (sym->scnum != -1) { |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
402 printf("\t/* MOE section != ABS! */\n"); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
403 continue; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
404 } |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
405 printf("\t%s = %u;", sym->name + 1, sym->value); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
406 if (sym->value >= 10) |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
407 printf("\t/* 0x%x */", sym->value); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
408 putchar('\n'); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
409 continue; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
410 case C_TPDEF: |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
411 richsym_print_in_c("typedef ", sym, |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
412 !(sym->type & 0xFFF0)); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
413 continue; |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
414 } |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
415 } |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
416 exit(0); |
25d3ead621f8
tiobjd: ctypes command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
144
diff
changeset
|
417 } |
150
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
418 |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
419 static int |
208
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
420 localsym_sanity_check_aux(sym) |
150
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
421 struct internal_syment *sym; |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
422 { |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
423 if (!sym->aux) { |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
424 printf("; symbol #%u of class %s has no aux record\n", |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
425 sym->number, storage_class_to_string(sym->class, 0)); |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
426 return(-1); |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
427 } |
208
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
428 return(0); |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
429 } |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
430 |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
431 static int |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
432 localsym_sanity_check_scnum(sym) |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
433 struct internal_syment *sym; |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
434 { |
150
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
435 if (sym->scnum != -1) { |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
436 printf("; symbol #%u of class %s: section != ABS\n", |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
437 sym->number, storage_class_to_string(sym->class, 0)); |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
438 return(-1); |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
439 } |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
440 return(0); |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
441 } |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
442 |
208
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
443 static int |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
444 localsym_sanity_check(sym) |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
445 struct internal_syment *sym; |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
446 { |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
447 int rc; |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
448 |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
449 rc = localsym_sanity_check_aux(sym); |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
450 if (rc) |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
451 return(rc); |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
452 rc = localsym_sanity_check_scnum(sym); |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
453 if (rc) |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
454 return(rc); |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
455 return(0); |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
456 } |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
457 |
150
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
458 richsym_function_locals(headsym) |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
459 struct internal_syment *headsym; |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
460 { |
151
6fe08feee018
tiobjd disasm -g: line break after function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
150
diff
changeset
|
461 unsigned n, count = 0; |
150
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
462 struct internal_syment *sym; |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
463 char classbuf[8]; |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
464 |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
465 for (n = headsym->number + 1; n < nsymtab; n++) { |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
466 sym = symtab[n]; |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
467 if (!sym) |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
468 continue; |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
469 switch (sym->class) { |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
470 case C_REG: |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
471 case C_REGPARM: |
151
6fe08feee018
tiobjd disasm -g: line break after function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
150
diff
changeset
|
472 count++; |
150
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
473 if (localsym_sanity_check(sym) < 0) |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
474 continue; |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
475 if (sym->value > 0xF) { |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
476 printf( |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
477 "; symbol #%u of class %s: value is not a valid register number\n", |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
478 sym->number, |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
479 storage_class_to_string(sym->class, 0)); |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
480 continue; |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
481 } |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
482 printf("; %s r%u: ", |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
483 storage_class_to_string(sym->class, 0), |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
484 sym->value); |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
485 richsym_print_in_c("", sym, 0); |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
486 continue; |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
487 case C_ARG: |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
488 case C_AUTO: |
151
6fe08feee018
tiobjd disasm -g: line break after function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
150
diff
changeset
|
489 count++; |
150
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
490 if (localsym_sanity_check(sym) < 0) |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
491 continue; |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
492 printf("; %s at 0x%x: ", |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
493 storage_class_to_string(sym->class, 0), |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
494 sym->value); |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
495 richsym_print_in_c("", sym, 0); |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
496 continue; |
208
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
497 case C_STRTAG: |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
498 case C_UNTAG: |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
499 case C_ENTAG: |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
500 count++; |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
501 printf("; %s {", sym->struct_name_raw); |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
502 if (richsym_print_bitsize && sym->aux) |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
503 printf("\t/* %u bits */", get_u32(sym->aux+4)); |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
504 putchar('\n'); |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
505 continue; |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
506 case C_EOS: |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
507 count++; |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
508 fputs("; };", stdout); |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
509 if (richsym_print_bitsize && sym->aux) |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
510 printf("\t/* %u bits */", get_u32(sym->aux+4)); |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
511 putchar('\n'); |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
512 continue; |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
513 case C_MOS: |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
514 case C_MOU: |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
515 count++; |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
516 if (localsym_sanity_check(sym) < 0) |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
517 continue; |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
518 richsym_print_in_c("; ", sym, 0); |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
519 continue; |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
520 case C_MOE: |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
521 count++; |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
522 if (localsym_sanity_check_scnum(sym) < 0) |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
523 continue; |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
524 if (sym->name[0] == '_') |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
525 printf("; %s = %u;", sym->name + 1, |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
526 sym->value); |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
527 else |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
528 printf("; \"%s\" = %u;", sym->name, |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
529 sym->value); |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
530 if (sym->value >= 10) |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
531 printf("\t/* 0x%x */", sym->value); |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
532 putchar('\n'); |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
533 continue; |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
534 case C_TPDEF: |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
535 count++; |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
536 if (localsym_sanity_check_aux(sym) < 0) |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
537 continue; |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
538 richsym_print_in_c("; typedef ", sym, |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
539 !(sym->type & 0xFFF0)); |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
540 continue; |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
541 case C_STAT: |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
542 count++; |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
543 if (localsym_sanity_check_aux(sym) < 0) |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
544 continue; |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
545 richsym_print_in_c("; static ", sym, 0); |
f7943bdbb3ea
tiobjd disasm -g: grok struct/union/enum definitions and statics in functions
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
155
diff
changeset
|
546 continue; |
150
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
547 case C_FCN: |
151
6fe08feee018
tiobjd disasm -g: line break after function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
150
diff
changeset
|
548 return(count); |
150
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
549 default: |
151
6fe08feee018
tiobjd disasm -g: line break after function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
150
diff
changeset
|
550 count++; |
150
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
551 printf( |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
552 "; presumed local symbol #%u: unexpected class %s\n", |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
553 sym->number, |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
554 storage_class_to_string(sym->class, classbuf)); |
151
6fe08feee018
tiobjd disasm -g: line break after function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
150
diff
changeset
|
555 return(count); |
150
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
556 } |
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
557 } |
151
6fe08feee018
tiobjd disasm -g: line break after function locals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
150
diff
changeset
|
558 return(count); |
150
df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
149
diff
changeset
|
559 } |