diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2016-10-28 22:26:53 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2016-10-28 22:26:53 (GMT) |
commit | 8c71b36d401b2473342daddcb9b7eb4b83ba3295 (patch) | |
tree | 13515f99f3e01fc2d1701189e500fa69763da7f9 /plugins | |
parent | 2c70e3332b43bdcbe215081b697395d254418e48 (diff) |
Optimized access to instruction sources and destinations.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/libcsem/exit.c | 9 | ||||
-rw-r--r-- | plugins/pychrysa/arch/instruction.c | 18 |
2 files changed, 12 insertions, 15 deletions
diff --git a/plugins/libcsem/exit.c b/plugins/libcsem/exit.c index aa3ca18..d26d4bf 100644 --- a/plugins/libcsem/exit.c +++ b/plugins/libcsem/exit.c @@ -49,8 +49,7 @@ static void mark_one_kind_of_exit_as_return(const GLoadedBinary *binary, const c const mrange_t *range; /* Emplacement du symbole */ GArchProcessor *proc; /* Architecture du binaire */ GArchInstruction *instr; /* Instruction de sortie */ - GArchInstruction **sources; /* Instructions diverses liées */ - InstructionLinkType *types; /* Types de lien existants */ + instr_link_t *sources; /* Instructions diverses liées */ size_t count; /* Nbre de sources affichées */ size_t i; /* Boucle de parcours */ @@ -69,13 +68,13 @@ static void mark_one_kind_of_exit_as_return(const GLoadedBinary *binary, const c instr = g_arch_processor_find_instr_by_address(proc, get_mrange_addr(range)); g_arch_instruction_rlock_src(instr); - count = g_arch_instruction_get_sources(instr, &sources, &types); + count = g_arch_instruction_get_sources(instr, &sources); for (i = 0; i < count; i++) { - if (types[i] != ILT_CALL) continue; + if (sources[i].type != ILT_CALL) continue; - g_arch_instruction_set_flag(sources[i], AIF_RETURN_POINT); + g_arch_instruction_set_flag(sources[i].linked, AIF_RETURN_POINT); } diff --git a/plugins/pychrysa/arch/instruction.c b/plugins/pychrysa/arch/instruction.c index ff3d2ad..f52b1ad 100644 --- a/plugins/pychrysa/arch/instruction.c +++ b/plugins/pychrysa/arch/instruction.c @@ -103,8 +103,7 @@ static PyObject *py_arch_instruction_get_sources(PyObject *self, PyObject *args) { PyObject *result; /* Instance à retourner */ GArchInstruction *instr; /* Version native */ - GArchInstruction **dests; /* Destination des liens */ - InstructionLinkType *types; /* Nature de ces liens */ + instr_link_t *sources; /* Origine des liens */ size_t count; /* Nombre de liens présents */ size_t i; /* Boucle de parcours */ PyObject *dest; /* Destination de lien Python */ @@ -113,14 +112,14 @@ static PyObject *py_arch_instruction_get_sources(PyObject *self, PyObject *args) instr = G_ARCH_INSTRUCTION(pygobject_get(self)); - count = g_arch_instruction_get_sources(instr, &dests, &types); + count = g_arch_instruction_get_sources(instr, &sources); result = PyTuple_New(count); for (i = 0; i < count; i++) { - dest = pygobject_new(G_OBJECT(dests[i])); - type = PyLong_FromLong(types[i]); + dest = pygobject_new(G_OBJECT(sources[i].linked)); + type = PyLong_FromLong(sources[i].type); ret = PyTuple_SetItem(result, i, Py_BuildValue("(OO)", dest, type)); assert(ret == 0); @@ -149,8 +148,7 @@ static PyObject *py_arch_instruction_get_destinations(PyObject *self, PyObject * { PyObject *result; /* Instance à retourner */ GArchInstruction *instr; /* Version native */ - GArchInstruction **dests; /* Destination des liens */ - InstructionLinkType *types; /* Nature de ces liens */ + instr_link_t *dests; /* Destination des liens */ size_t count; /* Nombre de liens présents */ size_t i; /* Boucle de parcours */ PyObject *dest; /* Destination de lien Python */ @@ -159,14 +157,14 @@ static PyObject *py_arch_instruction_get_destinations(PyObject *self, PyObject * instr = G_ARCH_INSTRUCTION(pygobject_get(self)); - count = g_arch_instruction_get_destinations(instr, &dests, &types); + count = g_arch_instruction_get_destinations(instr, &dests); result = PyTuple_New(count); for (i = 0; i < count; i++) { - dest = pygobject_new(G_OBJECT(dests[i])); - type = PyLong_FromLong(types[i]); + dest = pygobject_new(G_OBJECT(dests[i].linked)); + type = PyLong_FromLong(dests[i].type); ret = PyTuple_SetItem(result, i, Py_BuildValue("(OO)", dest, type)); assert(ret == 0); |