Mercurial > hg-old > index.cgi
diff lwasm/pseudo.c @ 199:188037f0397c
Allow export to import undefined symbols
author | lost |
---|---|
date | Sun, 22 Mar 2009 18:32:13 +0000 |
parents | 6ddc861a07d4 |
children | 7824f94c5786 |
line wrap: on
line diff
--- a/lwasm/pseudo.c Sun Mar 22 18:26:59 2009 +0000 +++ b/lwasm/pseudo.c Sun Mar 22 18:32:13 2009 +0000 @@ -1093,49 +1093,52 @@ lwasm_register_symbol(as, l, l -> sym, 0, SYMBOL_EXTERN); } - if (!se) - { - register_error(as, l, 2, "Exported symbols must be fully defined within a section"); - return; - } - if (se -> sect == NULL) + else { - register_error(as, l, 2, "Only non-local symbols within a section can be exported"); - return; - } + if (!se) + { + register_error(as, l, 2, "Exported symbols must be fully defined within a section"); + return; + } + if (se -> sect == NULL) + { + register_error(as, l, 2, "Only non-local symbols within a section can be exported"); + return; + } - if (se -> flags & SYMBOL_SET) - { - register_error(as, l, 2, "You cannot export symbols defined with SET"); - return; - } + if (se -> flags & SYMBOL_SET) + { + register_error(as, l, 2, "You cannot export symbols defined with SET"); + return; + } - // if the symbol is not already a simple value, re-evaluate it - // and see if it becomes simple + // if the symbol is not already a simple value, re-evaluate it + // and see if it becomes simple - if (se -> flags & SYMBOL_COMPLEX) - { - register_error(as, l, 2, "Exported symbols must be fully resolved on pass 2"); - return; - } + if (se -> flags & SYMBOL_COMPLEX) + { + register_error(as, l, 2, "Exported symbols must be fully resolved on pass 2"); + return; + } - // search for existing export - for (ex = se -> sect -> exports; ex; ex = ex -> next) - if (!strcmp(l -> sym, ex -> sym)) - break; - if (ex) - { - register_error(as, l, 2, "Symbol %s already exported", l -> sym); - return; + // search for existing export + for (ex = se -> sect -> exports; ex; ex = ex -> next) + if (!strcmp(l -> sym, ex -> sym)) + break; + if (ex) + { + register_error(as, l, 2, "Symbol %s already exported", l -> sym); + return; + } + + // add an external reference + ex = lwasm_alloc(sizeof(export_list_t)); + ex -> next = se -> sect -> exports; + se -> sect -> exports = ex; + ex -> offset = se -> value; + ex -> sym = lwasm_strdup(se -> sym); } - - // add an external reference - ex = lwasm_alloc(sizeof(export_list_t)); - ex -> next = se -> sect -> exports; - se -> sect -> exports = ex; - ex -> offset = se -> value; - ex -> sym = lwasm_strdup(se -> sym); if (after == 1) { if (**p == ',')