summaryrefslogtreecommitdiff
path: root/masm/symtab.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--masm/symtab.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/masm/symtab.c b/masm/symtab.c
index 897c4f9..c6f9aac 100644
--- a/masm/symtab.c
+++ b/masm/symtab.c
@@ -1,5 +1,6 @@
#include <elf.h>
#include <merror.h>
+#include <netinet/in.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
@@ -21,6 +22,10 @@ int symtab_init(struct symbol_table *symtab)
return M_ERROR;
}
+ Elf32_Sym null = {0};
+ if (symtab_push(symtab, null, -1))
+ return M_ERROR;
+
return M_SUCCESS;
}
@@ -54,7 +59,7 @@ int symtab_find(struct symbol_table *symtab, Elf32_Sym **ptr,
{
for (uint32_t i = 0; i < symtab->len; i++) {
Elf32_Sym *sym = &symtab->symbols[i];
- const char *str = &symtab->strtab->ptr[sym->st_name];
+ const char *str = &symtab->strtab->ptr[ntohl(sym->st_name)];
if (strcmp(str, name) == 0) {
if (ptr != NULL)
*ptr = sym;