This source file includes following definitions.
- STAILQ_HEAD
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45 #include "../queue.h"
46
47 typedef enum {
48 UNINITIALIZED,
49 REGISTER,
50 ALIAS,
51 SCBLOC,
52 SRAMLOC,
53 ENUM_ENTRY,
54 FIELD,
55 MASK,
56 ENUM,
57 CONST,
58 DOWNLOAD_CONST,
59 LABEL,
60 CONDITIONAL,
61 MACRO
62 } symtype;
63
64 typedef enum {
65 RO = 0x01,
66 WO = 0x02,
67 RW = 0x03
68 }amode_t;
69
70 typedef SLIST_HEAD(symlist, symbol_node) symlist_t;
71
72 struct reg_info {
73 u_int address;
74 int size;
75 amode_t mode;
76 symlist_t fields;
77 uint8_t valid_bitmask;
78 uint8_t modes;
79 int typecheck_masks;
80 };
81
82 struct field_info {
83 symlist_t symrefs;
84 uint8_t value;
85 uint8_t mask;
86 };
87
88 struct const_info {
89 u_int value;
90 int define;
91 };
92
93 struct alias_info {
94 struct symbol *parent;
95 };
96
97 struct label_info {
98 int address;
99 int exported;
100 };
101
102 struct cond_info {
103 int func_num;
104 };
105
106 struct macro_arg {
107 STAILQ_ENTRY(macro_arg) links;
108 regex_t arg_regex;
109 char *replacement_text;
110 };
111 STAILQ_HEAD(macro_arg_list, macro_arg) args;
112
113 struct macro_info {
114 struct macro_arg_list args;
115 int narg;
116 const char* body;
117 };
118
119 typedef struct expression_info {
120 symlist_t referenced_syms;
121 int value;
122 } expression_t;
123
124 typedef struct symbol {
125 char *name;
126 symtype type;
127 int count;
128 union {
129 struct reg_info *rinfo;
130 struct field_info *finfo;
131 struct const_info *cinfo;
132 struct alias_info *ainfo;
133 struct label_info *linfo;
134 struct cond_info *condinfo;
135 struct macro_info *macroinfo;
136 } info;
137 int dont_generate_debug_code;
138 } symbol_t;
139
140 typedef struct symbol_ref {
141 symbol_t *symbol;
142 int offset;
143 } symbol_ref_t;
144
145 typedef struct symbol_node {
146 SLIST_ENTRY(symbol_node) links;
147 symbol_t *symbol;
148 } symbol_node_t;
149
150 typedef struct critical_section {
151 TAILQ_ENTRY(critical_section) links;
152 int begin_addr;
153 int end_addr;
154 } critical_section_t;
155
156 typedef enum {
157 SCOPE_ROOT,
158 SCOPE_IF,
159 SCOPE_ELSE_IF,
160 SCOPE_ELSE
161 } scope_type;
162
163 typedef struct patch_info {
164 int skip_patch;
165 int skip_instr;
166 } patch_info_t;
167
168 typedef struct scope {
169 SLIST_ENTRY(scope) scope_stack_links;
170 TAILQ_ENTRY(scope) scope_links;
171 TAILQ_HEAD(, scope) inner_scope;
172 scope_type type;
173 int inner_scope_patches;
174 int begin_addr;
175 int end_addr;
176 patch_info_t patches[2];
177 int func_num;
178 } scope_t;
179
180 TAILQ_HEAD(cs_tailq, critical_section);
181 SLIST_HEAD(scope_list, scope);
182 TAILQ_HEAD(scope_tailq, scope);
183
184 void symbol_delete(symbol_t *symbol);
185
186 void symtable_open(void);
187
188 void symtable_close(void);
189
190 symbol_t *
191 symtable_get(char *name);
192
193 symbol_node_t *
194 symlist_search(symlist_t *symlist, char *symname);
195
196 void
197 symlist_add(symlist_t *symlist, symbol_t *symbol, int how);
198 #define SYMLIST_INSERT_HEAD 0x00
199 #define SYMLIST_SORT 0x01
200
201 void symlist_free(symlist_t *symlist);
202
203 void symlist_merge(symlist_t *symlist_dest, symlist_t *symlist_src1,
204 symlist_t *symlist_src2);
205 void symtable_dump(FILE *ofile, FILE *dfile);