diff options
author | Freya Murphy <freya@freyacat.org> | 2024-09-09 20:48:08 -0400 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2024-09-09 20:48:08 -0400 |
commit | 0ff948af3d65150f44c9fe801ada806ce0637fe1 (patch) | |
tree | ba766d33d12bf1063660c2144af2d5f5c36b4c87 /masm/parse.c | |
parent | i forgor syscall (diff) | |
download | mips-0ff948af3d65150f44c9fe801ada806ce0637fe1.tar.gz mips-0ff948af3d65150f44c9fe801ada806ce0637fe1.tar.bz2 mips-0ff948af3d65150f44c9fe801ada806ce0637fe1.zip |
relocation table hell
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); |