comparison lwasm/lwasm.c @ 13:c80e5a063967

Brought forward patch to fix segfault with output outside of a section
author lost@l-w.ca
date Sat, 22 Jan 2011 16:15:32 -0700
parents 7317fbe024af
children 421d7ceb4d86
comparison
equal deleted inserted replaced
12:6b9991fb39b6 13:c80e5a063967
225 return r; 225 return r;
226 } 226 }
227 227
228 void lwasm_emit(line_t *cl, int byte) 228 void lwasm_emit(line_t *cl, int byte)
229 { 229 {
230 if (cl -> as -> output_format == OUTPUT_OBJ && cl -> csect == NULL)
231 {
232 lwasm_register_error(cl -> as, cl, "Instruction generating output outside of a section");
233 return;
234 }
230 if (cl -> outputl < 0) 235 if (cl -> outputl < 0)
231 cl -> outputl = 0; 236 cl -> outputl = 0;
232 237
233 if (cl -> outputl == cl -> outputbl) 238 if (cl -> outputl == cl -> outputbl)
234 { 239 {
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;
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