Object file injection, first part
[centaur.git] / src / model / count.c
index b7c80130d63778186bfdbde824d13f3afeea0d3a..671767e04b1b0fa01967a09bfaec1865a8d806a5 100644 (file)
@@ -3,6 +3,26 @@
 #include <libelfu/libelfu.h>
 
 
+size_t elfu_mScnIndex(ElfuElf *me, ElfuScn *ms)
+{
+  ElfuScn *ms2;
+  size_t i = 1;
+
+  assert(me);
+  assert(ms);
+
+  CIRCLEQ_FOREACH(ms2, &me->scnList, elem) {
+    if (ms2 == ms) {
+      return i;
+    }
+
+    i++;
+  }
+
+  /* Section is not in ELF model. This means the calling code is broken. */
+  assert(0);
+}
+
 
 /* NULL section is not counted! */
 size_t elfu_mCountScns(ElfuElf *me)