Mercurial > hg-old > index.cgi
comparison src/symbol.c @ 143:0ee5f65bccf9
Added pragma to allow all undefined symbols to be considered external and also added a --pragma command line option
author | lost |
---|---|
date | Thu, 29 Jan 2009 01:32:11 +0000 |
parents | ea2cfebef5d0 |
children |
comparison
equal
deleted
inserted
replaced
142:36ca3fa755e0 | 143:0ee5f65bccf9 |
---|---|
136 se -> value = val; | 136 se -> value = val; |
137 if (flags & SYMBOL_COMPLEX) | 137 if (flags & SYMBOL_COMPLEX) |
138 se -> expr = l -> exprs[0]; | 138 se -> expr = l -> exprs[0]; |
139 se -> sym = lwasm_strdup(sym); | 139 se -> sym = lwasm_strdup(sym); |
140 se -> context = scontext; | 140 se -> context = scontext; |
141 se -> sect = as -> csect; | 141 |
142 if (!(flags & SYMBOL_EXTERN)) | |
143 se -> sect = as -> csect; | |
144 else | |
145 se -> sect = NULL; | |
146 | |
142 se -> expr = NULL; | 147 se -> expr = NULL; |
143 se -> flags = flags; | 148 se -> flags = flags; |
144 se -> externalname = NULL; | 149 se -> externalname = NULL; |
145 | 150 |
146 return 0; | 151 return 0; |
147 } | 152 } |
148 | 153 |
149 lwasm_symbol_ent_t *lwasm_find_symbol(asmstate_t *as, char *sym, int scontext) | 154 lwasm_symbol_ent_t *lwasm_find_symbol(asmstate_t *as, char *sym, int scontext) |
150 { | 155 { |
151 lwasm_symbol_ent_t *se; | 156 lwasm_symbol_ent_t *se; |
157 static int st = 0; | |
152 | 158 |
153 for (se = as -> symhead; se; se = se -> next) | 159 for (se = as -> symhead; se; se = se -> next) |
154 { | 160 { |
155 if (scontext == se -> context && !strcmp(sym, se -> sym)) | 161 if (scontext == se -> context && !strcmp(sym, se -> sym)) |
156 { | 162 { |
157 return se; | 163 return se; |
158 } | 164 } |
159 } | 165 } |
166 if (as -> passnum == 2 && st == 0 && scontext == -1 && as -> outformat == OUTPUT_OBJ && as -> pragmas & PRAGMA_UNDEFEXTERN) | |
167 { | |
168 // we want undefined symbols to be considered external | |
169 // we didn't find it on a lookup so register it as external | |
170 // but we only do so when looking up in global context | |
171 st = 1; | |
172 if (lwasm_register_symbol(as, NULL, sym, 0, SYMBOL_EXTERN)) | |
173 { | |
174 st = 0; | |
175 return NULL; | |
176 } | |
177 st = 0; | |
178 | |
179 // find the newly registered symbol and return it | |
180 for (se = as -> symhead; se; se = se -> next) | |
181 { | |
182 if (scontext == se -> context && !strcmp(sym, se -> sym)) | |
183 { | |
184 return se; | |
185 } | |
186 } | |
187 } | |
188 | |
160 return NULL; | 189 return NULL; |
161 } | 190 } |
162 | 191 |
163 // reset the value of a symbol - should not be used normally | 192 // reset the value of a symbol - should not be used normally |
164 // it is intended for use by such operations as EQU | 193 // it is intended for use by such operations as EQU |