summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornorly <ny-git@enpas.org>2013-05-28 23:34:51 +0100
committernorly <ny-git@enpas.org>2013-05-28 23:34:51 +0100
commiteb5a1daba781013ccf168b95510d0f67f0b9c946 (patch)
tree1737caa39931eaec818b992acc5df43bb02b1794
parent11bf2836351cdb0703506d9d24ebd72bb420d1df (diff)
Implement orphaned sections
Orphaned sections are not (fully) included in any LOAD PHDR and can thus be moved and stripped at will without changing the memory image of the program.
-rw-r--r--include/libelfu/modeltypes.h1
-rw-r--r--src/model/dump.c9
-rw-r--r--src/model/fromFile.c3
3 files changed, 13 insertions, 0 deletions
diff --git a/include/libelfu/modeltypes.h b/include/libelfu/modeltypes.h
index e8a9c01..bea9322 100644
--- a/include/libelfu/modeltypes.h
+++ b/include/libelfu/modeltypes.h
@@ -37,6 +37,7 @@ typedef struct {
CIRCLEQ_HEAD(ScnList, ElfuScn) scnList;
CIRCLEQ_HEAD(PhdrList, ElfuPhdr) phdrList;
+ CIRCLEQ_HEAD(OrphanScnList, ElfuScn) orphanScnList;
ElfuScn *shstrtab;
} ElfuElf;
diff --git a/src/model/dump.c b/src/model/dump.c
index 882ba0a..67a498a 100644
--- a/src/model/dump.c
+++ b/src/model/dump.c
@@ -209,6 +209,15 @@ void elfu_mDumpElf(ElfuElf *me)
ELFU_INFO("\n");
+ ELFU_INFO("Orphaned sections:\n");
+ CIRCLEQ_FOREACH(ms, &me->orphanScnList, elemChildScn) {
+ ELFU_INFO(" * %-17s @ %8jx\n",
+ elfu_mScnName(me, ms),
+ ms->shdr.sh_addr);
+ }
+ ELFU_INFO("\n");
+
+
ELFU_INFO("Sections:\n");
ELFU_INFO(" # Name sh_type sh_addr sh_offset sh_size ES Fl Al sh_link sh_info \n");
ELFU_INFO(" | | | | | | | | | | \n");
diff --git a/src/model/fromFile.c b/src/model/fromFile.c
index fd6aba0..cb09352 100644
--- a/src/model/fromFile.c
+++ b/src/model/fromFile.c
@@ -167,6 +167,7 @@ ElfuElf* elfu_mFromElf(Elf *e)
/* General stuff */
CIRCLEQ_INIT(&me->scnList);
CIRCLEQ_INIT(&me->phdrList);
+ CIRCLEQ_INIT(&me->orphanScnList);
me->shstrtab = NULL;
me->elfclass = gelf_getclass(e);
@@ -286,6 +287,8 @@ ElfuElf* elfu_mFromElf(Elf *e)
if (parent) {
CIRCLEQ_INSERT_TAIL(&parent->childScnList, ms, elemChildScn);
+ } else {
+ CIRCLEQ_INSERT_TAIL(&me->orphanScnList, ms, elemChildScn);
}
}