Mercurial > hg-old > index.cgi
comparison lwasm/output.c @ 448:5cccf90bf838 3.0 tip
Fixed bug with complex external references generating invalid relocations in the object file
author | lost@l-w.ca |
---|---|
date | Fri, 05 Nov 2010 22:27:00 -0600 |
parents | 35a0b086bf4a |
children |
comparison
equal
deleted
inserted
replaced
447:00924eeb2ec8 | 448:5cccf90bf838 |
---|---|
233 | 233 |
234 int write_code_obj_expraux(lw_expr_t e, void *of) | 234 int write_code_obj_expraux(lw_expr_t e, void *of) |
235 { | 235 { |
236 int tt; | 236 int tt; |
237 int v; | 237 int v; |
238 int count = 1; | |
238 unsigned char buf[16]; | 239 unsigned char buf[16]; |
239 | 240 |
240 tt = lw_expr_type(e); | 241 tt = lw_expr_type(e); |
241 | 242 |
242 switch (tt) | 243 switch (tt) |
243 { | 244 { |
244 case lw_expr_type_oper: | 245 case lw_expr_type_oper: |
245 buf[0] = 0x04; | 246 buf[0] = 0x04; |
247 | |
246 switch (lw_expr_whichop(e)) | 248 switch (lw_expr_whichop(e)) |
247 { | 249 { |
248 case lw_expr_oper_plus: | 250 case lw_expr_oper_plus: |
249 buf[1] = 0x01; | 251 buf[1] = 0x01; |
252 count = lw_expr_operandcount(e) - 1; | |
250 break; | 253 break; |
251 | 254 |
252 case lw_expr_oper_minus: | 255 case lw_expr_oper_minus: |
253 buf[1] = 0x02; | 256 buf[1] = 0x02; |
254 break; | 257 break; |
255 | 258 |
256 case lw_expr_oper_times: | 259 case lw_expr_oper_times: |
257 buf[1] = 0x03; | 260 buf[1] = 0x03; |
261 count = lw_expr_operandcount(e) - 1; | |
258 break; | 262 break; |
259 | 263 |
260 case lw_expr_oper_divide: | 264 case lw_expr_oper_divide: |
261 buf[1] = 0x04; | 265 buf[1] = 0x04; |
262 break; | 266 break; |
298 break; | 302 break; |
299 | 303 |
300 default: | 304 default: |
301 buf[1] = 0xff; | 305 buf[1] = 0xff; |
302 } | 306 } |
303 writebytes(buf, 2, 1, of); | 307 while (count--) |
308 writebytes(buf, 2, 1, of); | |
304 return 0; | 309 return 0; |
305 | 310 |
306 case lw_expr_type_int: | 311 case lw_expr_type_int: |
307 v = lw_expr_intval(e); | 312 v = lw_expr_intval(e); |
308 buf[0] = 0x01; | 313 buf[0] = 0x01; |