Mercurial > hg-old > index.cgi
changeset 82:03be43ae19cf
Added EXTERN directive
author | lost |
---|---|
date | Sat, 10 Jan 2009 22:24:29 +0000 |
parents | b6b1e79cc277 |
children | 964d68cde469 |
files | src/instab.c src/lwasm.h src/pseudo.c src/symbol.c |
diffstat | 4 files changed, 28 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/instab.c Sat Jan 10 19:05:15 2009 +0000 +++ b/src/instab.c Sat Jan 10 22:24:29 2009 +0000 @@ -75,7 +75,8 @@ extern OPFUNC(pseudo_endsection); extern OPFUNC(pseudo_pragma); extern OPFUNC(pseudo_starpragma); - +extern OPFUNC(pseudo_extern); +\ instab_t instab[] = { { "abx", { 0x3a, -0x1, -0x1, -0x1 }, insn_inh }, @@ -322,6 +323,9 @@ { "equ", { -1, -1, -1, -1 }, pseudo_equ, 0, 0, 1 }, { "=", { -1, -1, -1, -1 }, pseudo_equ, 0, 0, 1 }, + { "extern", { -1, -1, -1, -1 }, pseudo_extern, 0, 0, 1 }, + { "external", { -1, -1, -1, -1 }, pseudo_extern, 0, 0, 1 }, + { "rmb", { -1, -1, -1, -1 }, pseudo_rmb }, { "rmd", { -1, -1, -1, -1 }, pseudo_rmd },
--- a/src/lwasm.h Sat Jan 10 19:05:15 2009 +0000 +++ b/src/lwasm.h Sat Jan 10 22:24:29 2009 +0000 @@ -98,6 +98,7 @@ #define SYMBOL_COMPLEX 2 // register symbol as a complex symbol (from l -> expr) #define SYMBOL_FORCE 4 // force resetting the symbol value if it already exists on pass 2 #define SYMBOL_NORM 0 // no flags +#define SYMBOL_EXTERN 8 // the symbol is an external reference typedef struct lwasm_symbol_ent_s lwasm_symbol_ent_t; struct lwasm_symbol_ent_s { @@ -105,6 +106,7 @@ int context; // the context number of the symbol (-1 for global) int value; // the value of the symbol int flags; // flags for the symbol + char *externalname; // for external references that are aliased locally sectiontab_t *sect; // the section the symbol exists in; NULL for none lwasm_expr_stack_t *expr; // expression for a symbol that is not constant NULL for const lwasm_symbol_ent_t *next; // next symbol in the table
--- a/src/pseudo.c Sat Jan 10 19:05:15 2009 +0000 +++ b/src/pseudo.c Sat Jan 10 22:24:29 2009 +0000 @@ -761,3 +761,23 @@ as -> csect = 0; as -> context = lwasm_next_context(as); } + +OPFUNC(pseudo_extern) +{ + if (as -> passnum != 1) + return; + + if (as -> outformat != OUTPUT_OBJ) + { + register_error(as, l, 1, "External references only supported for obj target"); + return; + } + + if (as -> csect) + { + register_error(as, l, 1, "Cannot declare external symbols within a section"); + return; + } + + lwasm_register_symbol(as, l, l -> sym, 0, SYMBOL_EXTERN); +}