summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/libelfu/model.h3
-rw-r--r--src/model/count.c33
2 files changed, 36 insertions, 0 deletions
diff --git a/include/libelfu/model.h b/include/libelfu/model.h
index aaf754f..1b5f6b6 100644
--- a/include/libelfu/model.h
+++ b/include/libelfu/model.h
@@ -43,6 +43,9 @@ typedef struct {
+size_t elfu_countSections(ElfuElf *me);
+size_t elfu_countPHDRs(ElfuElf *me);
+
ElfuPhdr* elfu_modelFromPhdr(GElf_Phdr *phdr);
ElfuScn* elfu_modelFromSection(Elf_Scn *scn);
ElfuElf* elfu_modelFromElf(Elf *e);
diff --git a/src/model/count.c b/src/model/count.c
new file mode 100644
index 0000000..02f6a33
--- /dev/null
+++ b/src/model/count.c
@@ -0,0 +1,33 @@
+#include <sys/types.h>
+#include <libelfu/libelfu.h>
+
+
+
+size_t elfu_countSections(ElfuElf *me)
+{
+ ElfuScn *ms;
+ size_t i = 0;
+
+ for (ms = me->scnList.cqh_first;
+ ms != (void *)&me->scnList;
+ ms = ms->elem.cqe_next) {
+ i++;
+ }
+
+ return i;
+}
+
+
+size_t elfu_countPHDRs(ElfuElf *me)
+{
+ ElfuPhdr *mp;
+ size_t i = 0;
+
+ for (mp = me->phdrList.cqh_first;
+ mp != (void *)&me->phdrList;
+ mp = mp->elem.cqe_next) {
+ i++;
+ }
+
+ return i;
+}