Mercurial > hg-old > index.cgi
diff lwasm/output.c @ 387:a741d2e4869f
Various bugfixes; fixed lwobjdump to display symbols with unprintable characters more sensibly; start of a (nonfunctional for now) testing framework
author | lost@l-w.ca |
---|---|
date | Wed, 14 Jul 2010 20:15:23 -0600 |
parents | 55ed7d06b136 |
children | c94436adce83 |
line wrap: on
line diff
--- a/lwasm/output.c Sun May 16 13:03:17 2010 -0600 +++ b/lwasm/output.c Wed Jul 14 20:15:23 2010 -0600 @@ -243,7 +243,7 @@ { case lw_expr_type_oper: buf[0] = 0x04; - switch (lw_expr_intval(e)) + switch (lw_expr_whichop(e)) { case lw_expr_oper_plus: buf[1] = 0x01; @@ -301,7 +301,7 @@ buf[1] = 0xff; } writebytes(buf, 2, 1, of); - break; + return 0; case lw_expr_type_int: v = lw_expr_intval(e); @@ -309,7 +309,7 @@ buf[1] = (v >> 8) & 0xff; buf[2] = v & 0xff; writebytes(buf, 3, 1, of); - break; + return 0; case lw_expr_type_special: v = lw_expr_specint(e); @@ -321,9 +321,9 @@ sectiontab_t *se; se = lw_expr_specptr(e); - writebytes("\x03\x02", 1, 1, of); + writebytes("\x03\x02", 2, 1, of); writebytes(se -> name, strlen(se -> name) + 1, 1, of); - break; + return 0; } case lwasm_expr_import: { @@ -332,7 +332,7 @@ buf[0] = 0x02; writebytes(buf, 1, 1, of); writebytes(ie -> symbol, strlen(ie -> symbol) + 1, 1, of); - break; + return 0; } case lwasm_expr_syment: { @@ -347,13 +347,13 @@ writebytes(buf, strlen(buf), 1, of); } writebytes("", 1, 1, of); - break; + return 0; } - break; } default: // unrecognized term type - replace with integer 0 +// fprintf(stderr, "Unrecognized term type: %s\n", lw_expr_print(e)); buf[0] = 0x01; buf[1] = 0x00; buf[2] = 0x00; @@ -408,7 +408,7 @@ if (l -> outputl > 0) for (i = 0; i < l -> outputl; i++) write_code_obj_sbadd(l -> csect, l -> output[i]); - else if (l -> outputl == 0) + else if (l -> outputl == 0 || l -> outputl == -1) for (i = 0; i < l -> len; i++) write_code_obj_sbadd(l -> csect, 0); } @@ -432,6 +432,8 @@ // a symbol for section base address writebytes("\x02", 1, 1, of); writebytes(s -> name, strlen(s -> name) + 1, 1, of); + // address 0; "\0" is not an error + writebytes("\0", 2, 1, of); for (se = as -> symtab.head; se; se = se -> next) { // ignore symbols not in this section @@ -525,7 +527,7 @@ writebytes(buf, 2, 1, of); } - te = lw_expr_copy(ex -> se -> value); + te = lw_expr_copy(re -> offset); lwasm_reduce_expr(as, te); if (!lw_expr_istype(te, lw_expr_type_int)) {