annotate leo-obj/tool/richsym.c @ 144:fd772de226cb

tiobjd: started implementing rich symbolic info parsing
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Mon, 28 Apr 2014 08:04:39 +0000
parents
children 25d3ead621f8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
144
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * Code for working with the "rich" symbolic info
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 * present in TI's GPF libraries
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4 */
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 #include <sys/types.h>
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <stdio.h>
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <stdlib.h>
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 #include <string.h>
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 #include <strings.h>
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 #include "intstruct.h"
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 #include "coffconst.h"
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 #include "globals.h"
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 extern unsigned get_u16(), get_u32();
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 extern char *storage_class_to_string();
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 static int
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 try_typedef_hack(struct_sym)
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 struct internal_syment *struct_sym;
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 {
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 unsigned tpdef_cand;
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 struct internal_syment *tpdef_sym;
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 if (!struct_sym->aux)
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 return(0);
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 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
28 if (tpdef_cand >= nsymtab)
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 return(0);
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 tpdef_sym = symtab[tpdef_cand];
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 if (!tpdef_sym)
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 return(0);
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 if (tpdef_sym->class != C_TPDEF)
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->type != struct_sym->type)
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->name[0] != '_')
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->aux)
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 (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
42 return(0);
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 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
44 return(1);
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 }
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47 static void
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48 preen_strtag_sym(sym, kw, expect_type)
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 struct internal_syment *sym;
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50 char *kw;
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51 {
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
52 char *buf;
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
53 int isund, len;
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
54
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
55 isund = (sym->name[0] == '_');
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56 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
57 if (isund)
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
58 len--;
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
59 else
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
60 len += 2;
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
61 buf = malloc(len);
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
62 if (!buf) {
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
63 perror("malloc");
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
64 exit(1);
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
65 }
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
66 if (isund)
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
67 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
68 else
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);
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
70 sym->struct_name = buf;
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
71 sym->struct_name_raw = buf;
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
72 if (sym->type != expect_type) {
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
73 fprintf(stderr,
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
74 "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
75 sym->number);
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
76 return;
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
77 }
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
78 if (isund)
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
79 return;
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
80 try_typedef_hack(sym);
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
81 }
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
82
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
83 richsym_initial_preen()
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 unsigned n;
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
86 struct internal_syment *sym;
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
87
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
88 for (n = 0; n < nsymtab; n++) {
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
89 sym = symtab[n];
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
90 if (!sym)
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
91 continue;
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
92 switch (sym->class) {
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
93 case C_STRTAG:
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
94 preen_strtag_sym(sym, "struct", T_STRUCT);
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
95 continue;
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
96 case C_UNTAG:
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
97 preen_strtag_sym(sym, "union", T_UNION);
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
98 continue;
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
99 case C_ENTAG:
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
100 preen_strtag_sym(sym, "enum", T_ENUM);
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
101 continue;
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
102 }
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
103 }
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 char *
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
107 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
108 unsigned idx;
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
109 {
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
110 struct internal_syment *sym;
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 if (idx >= nsymtab) {
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
113 inv_idx: fprintf(stderr,
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
114 "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
115 idx);
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
116 exit(1);
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
117 }
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
118 sym = symtab[idx];
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
119 if (!sym)
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
120 goto inv_idx;
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
121 if (sym->class != expect_class) {
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
122 fprintf(stderr,
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
123 "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
124 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
125 exit(1);
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
126 }
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
127 if (is_typedef)
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
128 return(sym->struct_name_raw);
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
129 else
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
130 return(sym->struct_name);
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
131 }
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
132
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
133 char *
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
134 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
135 struct internal_syment *sym;
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
136 {
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
137 switch (sym->type & 0xF) {
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
138 case T_VOID:
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
139 return("void");
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
140 case T_CHAR:
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
141 if (is_typedef)
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
142 return("signed char");
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
143 else
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
144 return("char");
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
145 case T_SHORT:
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
146 return("short");
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
147 case T_INT:
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
148 return("int");
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
149 case T_LONG:
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
150 return("long");
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
151 case T_FLOAT:
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
152 return("float");
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
153 case T_DOUBLE:
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
154 return("double");
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
155 case T_STRUCT:
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
156 return get_struct_type_name(get_u32(sym->aux), C_STRTAG,
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
157 is_typedef);
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
158 case T_UNION:
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
159 return get_struct_type_name(get_u32(sym->aux), C_UNTAG,
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
160 is_typedef);
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
161 case T_ENUM:
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
162 return get_struct_type_name(get_u32(sym->aux), C_ENTAG,
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
163 is_typedef);
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
164 case T_UCHAR:
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
165 if (is_typedef)
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
166 return("unsigned char");
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
167 else
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
168 return("u_char");
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
169 case T_USHORT:
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
170 if (is_typedef)
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
171 return("unsigned short");
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
172 else
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
173 return("u_short");
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
174 case T_UINT:
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
175 return("unsigned");
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
176 case T_ULONG:
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
177 if (is_typedef)
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
178 return("unsigned long");
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
179 else
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
180 return("u_long");
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
181 default:
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
182 return("__unknown_base_type");
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
183 }
fd772de226cb tiobjd: started implementing rich symbolic info parsing
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
184 }