summaryrefslogtreecommitdiff
path: root/masm/asm.h
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2024-09-09 20:48:08 -0400
committerFreya Murphy <freya@freyacat.org>2024-09-09 20:48:08 -0400
commit0ff948af3d65150f44c9fe801ada806ce0637fe1 (patch)
treeba766d33d12bf1063660c2144af2d5f5c36b4c87 /masm/asm.h
parenti forgor syscall (diff)
downloadmips-0ff948af3d65150f44c9fe801ada806ce0637fe1.tar.gz
mips-0ff948af3d65150f44c9fe801ada806ce0637fe1.tar.bz2
mips-0ff948af3d65150f44c9fe801ada806ce0637fe1.zip
relocation table hell
Diffstat (limited to 'masm/asm.h')
-rw-r--r--masm/asm.h31
1 files changed, 26 insertions, 5 deletions
diff --git a/masm/asm.h b/masm/asm.h
index 1bc7cf5..b8e6214 100644
--- a/masm/asm.h
+++ b/masm/asm.h
@@ -5,13 +5,16 @@
#include <stddef.h>
+#include "lex.h"
+#include "parse.h"
+
struct str_table {
- char *ptr;
- size_t size;
+ char *ptr;
+ size_t size;
};
/* initalize a string table */
-void strtbl_init(struct str_table *str_tbl);
+int strtbl_init(struct str_table *str_tbl);
/* free a string table */
void strtbl_free(struct str_table *str_tbl);
@@ -22,11 +25,29 @@ int strtbl_get_str(struct str_table *str_tbl, const char *str, size_t *res);
/* get or append a string into the string table */
int strtbl_write_str(struct str_table *str_tbl, const char *str, size_t *res);
+struct section_meta {
+ void *reltbl;
+ uint32_t reltbl_len;
+ uint32_t reltbl_idx; // reltbl idx in shdr
+ uint32_t shdr_idx; // sec idx in shdr
+ uint32_t v_addr;
+};
+
struct assembler {
- struct parser *parser;
- struct str_table str_tbl;
+ struct lexer lexer;
+ struct parser parser;
+ struct str_table shstr_tbl;
+ struct str_table str_tbl;
+
+ struct section_meta *meta;
+ size_t shstrtbl_idx;
+ size_t strtbl_idx;
+ size_t symtbl_idx;
};
+int assembler_init(struct assembler *asm, const char *path);
+void assembler_free(struct assembler *asm);
+
/* assemble a mips32 file*/
int assemble_file_mips32(char *path);