From 4addee4bda6064926b24cd1ae929303003bd9ff1 Mon Sep 17 00:00:00 2001 From: norly Date: Thu, 30 May 2013 04:01:51 +0100 Subject: Redesign data structures, make basic reladd work. The memory ELF model is now a tree structure: ELF +--> PHDRs +--> PHDR +--> Section | | +--> Section | | ... | | \--> Section | | | +--> PHDR +--> Section | | ... | ... | \--> Orphaned sections +--> Section ... \--> Section This effectively introduces semantics into the binary blob we are editing, and allows us to re-layout its contents much more easily while keeping as close as possible to what is assumed to be the original semantics. As a side-effect, a first meta-function had to be introduced (elfu_mScnForall) in order to traverse all leaves of the tree. Much old code has been removed given the leaner environment available now, and automated insertion of .text and .data sections from object files into executables now works. However nothing else is inserted (such as string tables or .bss) and no relocation takes place yet. --- src/model/fromFile.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'src/model/fromFile.c') diff --git a/src/model/fromFile.c b/src/model/fromFile.c index cb09352..ee0536d 100644 --- a/src/model/fromFile.c +++ b/src/model/fromFile.c @@ -132,6 +132,8 @@ static ElfuScn* modelFromSection(Elf_Scn *scn) ms->linkptr = NULL; ms->infoptr = NULL; + ms->oldptr = NULL; + return ms; @@ -165,7 +167,6 @@ ElfuElf* elfu_mFromElf(Elf *e) /* General stuff */ - CIRCLEQ_INIT(&me->scnList); CIRCLEQ_INIT(&me->phdrList); CIRCLEQ_INIT(&me->orphanScnList); me->shstrtab = NULL; @@ -291,12 +292,6 @@ ElfuElf* elfu_mFromElf(Elf *e) CIRCLEQ_INSERT_TAIL(&me->orphanScnList, ms, elemChildScn); } } - - - /* Put sections into list of all sections */ - for (i = 0; i < numShdr - 1; i++) { - CIRCLEQ_INSERT_TAIL(&me->scnList, secArray[i], elem); - } } -- cgit v1.2.3