summaryrefslogtreecommitdiff
path: root/src/modelops/toFile.c
diff options
context:
space:
mode:
authornorly <ny-git@enpas.org>2013-06-15 21:42:53 +0100
committernorly <ny-git@enpas.org>2013-06-15 22:02:26 +0100
commit825613b8e4f141a82d2b8be22d7fba68fed5ef96 (patch)
tree8ade4e195c1a77a3814c44109c4f5cc9e1a5ced7 /src/modelops/toFile.c
parent5868bb32246367139f0d17a989650964f90a7958 (diff)
Basic x86-64 support, not very usable in practice
Turns out that x86-64 aligns LOAD segments to 0x200000 bytes. Given that the mapping starts at 0x400000, there is not much room to expand... so there will be a need to add additional LOAD headers.
Diffstat (limited to 'src/modelops/toFile.c')
-rw-r--r--src/modelops/toFile.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/modelops/toFile.c b/src/modelops/toFile.c
index 434130e..90dc247 100644
--- a/src/modelops/toFile.c
+++ b/src/modelops/toFile.c
@@ -49,10 +49,34 @@ static void flattenSymtab(ElfuElf *me)
i++;
}
} else if (me->elfclass == ELFCLASS64) {
- // TODO
- assert(0);
+ size_t newsize = (numsyms + 1) * sizeof(Elf64_Sym);
+ size_t i;
+
+ if (me->symtab->data.d_buf) {
+ free(me->symtab->data.d_buf);
+ }
+ me->symtab->data.d_buf = malloc(newsize);
+ assert(me->symtab->data.d_buf);
+
+ me->symtab->data.d_size = newsize;
+ me->symtab->shdr.sh_size = newsize;
+ memset(me->symtab->data.d_buf, 0, newsize);
+
+ i = 1;
+ CIRCLEQ_FOREACH(sym, &me->symtab->symtab.syms, elem) {
+ Elf64_Sym *es = ((Elf64_Sym*)me->symtab->data.d_buf) + i;
+
+ es->st_name = sym->name;
+ es->st_value = sym->value;
+ es->st_size = sym->size;
+ es->st_info = ELF64_ST_INFO(sym->bind, sym->type);
+ es->st_other = sym->other;
+ es->st_shndx = sym->shndx;
+
+ i++;
+ }
} else {
- // Never reached
+ // Unknown elfclass
assert(0);
}