comparison lwasm/lwasm.c @ 447:00924eeb2ec8 3.0

Fixed segfault with output outside of a section
author lost@l-w.ca
date Thu, 04 Nov 2010 23:25:18 -0600
parents 4b137a8cf32a
children
comparison
equal deleted inserted replaced
446:194787ce2a77 447:00924eeb2ec8
226 return r; 226 return r;
227 } 227 }
228 228
229 void lwasm_emit(line_t *cl, int byte) 229 void lwasm_emit(line_t *cl, int byte)
230 { 230 {
231 if (cl -> as -> output_format == OUTPUT_OBJ && cl -> csect == NULL)
232 {
233 lwasm_register_error(cl -> as, cl, "Instruction generating output outside of a section");
234 return;
235 }
231 if (cl -> outputl < 0) 236 if (cl -> outputl < 0)
232 cl -> outputl = 0; 237 cl -> outputl = 0;
233 238
234 if (cl -> outputl == cl -> outputbl) 239 if (cl -> outputl == cl -> outputbl)
235 { 240 {
660 { 665 {
661 if (l -> as -> output_format == OUTPUT_OBJ) 666 if (l -> as -> output_format == OUTPUT_OBJ)
662 { 667 {
663 reloctab_t *re; 668 reloctab_t *re;
664 lw_expr_t te; 669 lw_expr_t te;
670
671 if (l->csect == NULL)
672 {
673 lwasm_register_error(l -> as, l, "Instruction generating output outside of a section");
674 return -1;
675 }
665 676
666 if (size == 4) 677 if (size == 4)
667 { 678 {
668 // create a two part reference because lwlink doesn't 679 // create a two part reference because lwlink doesn't
669 // support 32 bit references 680 // support 32 bit references