Object file injection, first part
[centaur.git] / src / model / section-by-type.c
diff --git a/src/model/section-by-type.c b/src/model/section-by-type.c
new file mode 100644 (file)
index 0000000..e36865a
--- /dev/null
@@ -0,0 +1,22 @@
+#include <assert.h>
+#include <libelf/gelf.h>
+#include <libelfu/libelfu.h>
+
+
+/*
+ * Returns the first section with the given type.
+ */
+ElfuScn* elfu_mScnByType(ElfuElf *me, Elf32_Word type)
+{
+  ElfuScn *ms;
+
+  assert(me);
+
+  CIRCLEQ_FOREACH(ms, &me->scnList, elem) {
+    if (ms->shdr.sh_type == type) {
+      return ms;
+    }
+  }
+
+  return NULL;
+}