Mercurial > hg-old > index.cgi
changeset 375:3498b2d88376
Added export list to object output
author | lost@starbug |
---|---|
date | Mon, 26 Apr 2010 17:14:04 -0600 |
parents | d99322ef6f21 |
children | 91c0fe026940 |
files | lwasm/lwasm.c lwasm/lwasm.h lwasm/output.c |
diffstat | 3 files changed, 41 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/lwasm/lwasm.c Sat Apr 24 14:15:18 2010 -0600 +++ b/lwasm/lwasm.c Mon Apr 26 17:14:04 2010 -0600 @@ -35,6 +35,16 @@ void lwasm_register_error(asmstate_t *as, line_t *l, const char *msg, ...); +int lwasm_expr_exportable(asmstate_t *as, lw_expr_t expr) +{ + return 0; +} + +int lwasm_expr_exportval(asmstate_t *as, lw_expr_t expr) +{ + return 0; +} + lw_expr_t lwasm_evaluate_var(char *var, void *priv) { asmstate_t *as = (asmstate_t *)priv; @@ -87,6 +97,14 @@ { switch (t) { + case lwasm_expr_secbase: + { + line_t *cl = ptr; + if (cl -> as -> exportcheck && ptr == cl -> as -> csect) + return lw_expr_build(lw_expr_type_int, 0); + return NULL; + } + case lwasm_expr_linelen: { line_t *cl = ptr;
--- a/lwasm/lwasm.h Sat Apr 24 14:15:18 2010 -0600 +++ b/lwasm/lwasm.h Mon Apr 26 17:14:04 2010 -0600 @@ -235,6 +235,8 @@ void *input_data; // opaque data used by the input system lw_stringlist_t include_list; // include paths lw_stack_t file_dir; // stack of the "current file" dir + + int exportcheck; // set if we need to collapse out the section base to 0 }; #ifndef ___symbol_c_seen___
--- a/lwasm/output.c Sat Apr 24 14:15:18 2010 -0600 +++ b/lwasm/output.c Mon Apr 26 17:14:04 2010 -0600 @@ -235,6 +235,7 @@ line_t *l; sectiontab_t *s; reloctab_t *re; + exportlist_t *ex; struct symtabe *se; int i; @@ -325,20 +326,35 @@ writebytes("", 1, 1, of); // now the exports -- FIXME -/* for (ex = as -> exportlist; ex; ex = ex -> next) + for (ex = as -> exportlist; ex; ex = ex -> next) { int eval; - ex -> se -> section != s) + lw_expr_t te; + line_t tl; + + if (ex -> se -> section != s) continue; - if (!lwasm_expr_exportable(ex -> se -> value)) + te = lw_expr_copy(ex -> se -> value); + as -> csect = ex -> se -> section; + as -> exportcheck = 1; + tl.as = as; + as -> cl = &tl; + lwasm_reduce_expr(as, te); + as -> exportcheck = 0; + as -> cl = NULL; + if (!lw_expr_istype(te, lw_expr_type_int)) + { + lw_expr_destroy(te); continue; - eval = lwasm_expr_exportval(ex -> se -> value); + } + eval = lw_expr_intval(te); + lw_expr_destroy(te); writebytes(ex -> symbol, strlen(ex -> symbol) + 1, 1, of); buf[0] = (eval >> 8) & 0xff; buf[1] = eval & 0xff; writebytes(buf, 2, 1, of); } -*/ + // flag end of exported symbols - "" is NOT an error writebytes("", 1, 1, of);