summaryrefslogtreecommitdiff
path: root/plugins/elf
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-12-27 22:24:07 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-12-27 22:24:07 (GMT)
commitd33e8935c5186ab2459dfa6c9340396377524fb1 (patch)
tree951e4dd3edcf9782c90fda5f564d390c01abce35 /plugins/elf
parentc8dce9ce407b2f8248d669df196a4bf0f9523723 (diff)
Extended the Python bindings.
Diffstat (limited to 'plugins/elf')
-rw-r--r--plugins/elf/python/dynamic.c45
-rw-r--r--plugins/elf/python/dynamic.h3
-rw-r--r--plugins/elf/python/format.c7
3 files changed, 53 insertions, 2 deletions
diff --git a/plugins/elf/python/dynamic.c b/plugins/elf/python/dynamic.c
index 9fe6eb4..32c7826 100644
--- a/plugins/elf/python/dynamic.c
+++ b/plugins/elf/python/dynamic.c
@@ -37,7 +37,7 @@
/******************************************************************************
* *
* Paramètres : self = format Elf à manipuler. *
-* args = indice de la section visée. *
+* args = indice de l'élément recherché. *
* *
* Description : Retrouve un élément dans la section dynamique par son indice.*
* *
@@ -79,6 +79,49 @@ PyObject *py_elf_format_find_dynamic_item_by_index(PyObject *self, PyObject *arg
/******************************************************************************
* *
+* Paramètres : self = format Elf à manipuler. *
+* args = sorte d'élément recherché. *
+* *
+* Description : Retrouve un élément dans la section dynamique par son type. *
+* *
+* Retour : Elément trouvé ou rien (None). *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+PyObject *py_elf_format_find_dynamic_item_by_type(PyObject *self, PyObject *args)
+{
+ PyObject *result; /* Trouvaille à retourner */
+ GElfFormat *format; /* Version GLib du format */
+ unsigned long type; /* Type de l'élément visé */
+ int ret; /* Bilan de lecture des args. */
+ elf_dyn item; /* Informations remontées */
+ bool found; /* Recherches concluantes ? */
+
+ format = G_ELF_FORMAT(pygobject_get(self));
+
+ ret = PyArg_ParseTuple(args, "k", &type);
+ if (!ret) return NULL;
+
+ found = find_elf_dynamic_item_by_type(format, type, &item);
+
+ if (found)
+ result = translate_elf_dyn_to_python(format, &item);
+
+ else
+ {
+ result = Py_None;
+ Py_INCREF(result);
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : self = classe représentant un format ELF. *
* closure = adresse non utilisée ici. *
* *
diff --git a/plugins/elf/python/dynamic.h b/plugins/elf/python/dynamic.h
index 4ef2936..2f209ec 100644
--- a/plugins/elf/python/dynamic.h
+++ b/plugins/elf/python/dynamic.h
@@ -33,6 +33,9 @@
/* Retrouve un élément dans la section dynamique par son indice. */
PyObject *py_elf_format_find_dynamic_item_by_index(PyObject *, PyObject *);
+/* Retrouve un élément dans la section dynamique par son type. */
+PyObject *py_elf_format_find_dynamic_item_by_type(PyObject *, PyObject *);
+
/* Fournit la liste des objets partagés requis. */
PyObject *py_elf_format_get_needed(PyObject *, void *);
diff --git a/plugins/elf/python/format.c b/plugins/elf/python/format.c
index 4e2b7cc..b78dadb 100644
--- a/plugins/elf/python/format.c
+++ b/plugins/elf/python/format.c
@@ -180,7 +180,12 @@ PyTypeObject *get_python_elf_format_type(void)
{
"find_dynamic_item_by_index", py_elf_format_find_dynamic_item_by_index,
METH_VARARGS,
- "find_dynamic_item_by_index($self, type, /)\n--\n\nFind an item from the dynamic segment using a given index."
+ "find_dynamic_item_by_index($self, index, /)\n--\n\nFind an item from the dynamic segment using a given index."
+ },
+ {
+ "find_dynamic_item_by_type", py_elf_format_find_dynamic_item_by_type,
+ METH_VARARGS,
+ "find_dynamic_item_by_type($self, type, /)\n--\n\nFind an item from the dynamic segment using a given type."
},
{ NULL }
};