# HG changeset patch # User lost@l-w.ca # Date 1279861864 21600 # Node ID c94436adce83ca0a4a053f1c0e8ed50fe823c828 # Parent e3567a9f0d543d84ecb478d16f3f746405efd357 Actually include local symbols in object files diff -r e3567a9f0d54 -r c94436adce83 lwasm/output.c --- a/lwasm/output.c Wed Jul 21 22:21:35 2010 -0600 +++ b/lwasm/output.c Thu Jul 22 23:11:04 2010 -0600 @@ -436,16 +436,36 @@ writebytes("\0", 2, 1, of); for (se = as -> symtab.head; se; se = se -> next) { + lw_expr_t te; + + debug_message(as, 200, "Consider symbol %s (%p) for export in section %p", se -> symbol, se -> section, s); + // ignore symbols not in this section if (se -> section != s) continue; + debug_message(as, 200, " In section"); + if (se -> flags & symbol_flag_set) continue; + debug_message(as, 200, " Not symbol_flag_set"); + + te = lw_expr_copy(se -> value); + debug_message(as, 200, " Value=%s", lw_expr_print(te)); + as -> exportcheck = 1; + as -> csect = s; + lwasm_reduce_expr(as, te); + as -> exportcheck = 0; + + debug_message(as, 200, " Value2=%s", lw_expr_print(te)); + // don't output non-constant symbols - if (!lw_expr_istype(se -> value, lw_expr_type_int)) + if (!lw_expr_istype(te, lw_expr_type_int)) + { + lw_expr_destroy(te); continue; + } writebytes(se -> symbol, strlen(se -> symbol), 1, of); if (se -> context >= 0) @@ -458,9 +478,10 @@ writebytes("", 1, 1, of); // write the address - buf[0] = (lw_expr_intval(se -> value) >> 8) & 0xff; - buf[1] = lw_expr_intval(se -> value) & 0xff; + buf[0] = (lw_expr_intval(te) >> 8) & 0xff; + buf[1] = lw_expr_intval(te) & 0xff; writebytes(buf, 2, 1, of); + lw_expr_destroy(te); } // flag end of local symbol table - "" is NOT an error writebytes("", 1, 1, of);