summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornorly <ny-git@enpas.org>2013-02-22 16:58:14 +0000
committernorly <ny-git@enpas.org>2013-02-22 17:01:08 +0000
commitc2fa58cbd584e835f0c53c95469fde5a699a6396 (patch)
tree75b845bfac8ca477bbab358d5ef9e0b08af4a6e1
parent5019a1c2a261d5e55a42090612f9748f82404108 (diff)
Add elfu_count{Section,PHDR}s
-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;
+}