diff options
Diffstat (limited to 'masm/parse.c')
-rw-r--r-- | masm/parse.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/masm/parse.c b/masm/parse.c index 9876311..9f8ddb1 100644 --- a/masm/parse.c +++ b/masm/parse.c @@ -105,23 +105,27 @@ static int parse_label(struct parser *parser, struct expr *expr) { struct token token; - struct symbol symbol; - uint32_t index; if (assert_token(parser, TOK_LABEL, &token)) return M_ERROR; strcpy(expr->text, token.text); - if (symtbl_find(&parser->sym_tbl, NULL, token.text) == M_SUCCESS) { + struct symbol *ref; + if (symtbl_find(&parser->sym_tbl, &ref, token.text) == M_SUCCESS) { + if (ref->flag == SYM_GLOBAL && ref->sec == NULL) { + ref->sec = parser->sec_tbl.current; + ref->index = parser->sec_tbl.current->count; + return M_SUCCESS; + } ERROR_POS(token, "redefined symbol '%s'", token.text); return M_ERROR; } - index = parser->sec_tbl.current->start + - parser->sec_tbl.current->count; + struct symbol symbol; symbol = (struct symbol) { .name = "", - .position = index, + .sec = parser->sec_tbl.current, + .index = parser->sec_tbl.current->count, .flag = SYM_LOCAL, }; strcpy(symbol.name, token.text); |