summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-06-21 21:18:35 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-06-21 21:18:35 (GMT)
commit0becef388e9a68ab716583758ade15f8d8ca0cf9 (patch)
treeee8fac9f9333d666234aef31ac3a27dca2afc9a4 /src
parent27f44a381ed8c317a16df450ec00ed87bbb9a4b3 (diff)
Limited the routine size to the containing segment.
Diffstat (limited to 'src')
-rw-r--r--src/analysis/disass/limit.c40
1 files changed, 28 insertions, 12 deletions
diff --git a/src/analysis/disass/limit.c b/src/analysis/disass/limit.c
index 4fb219a..103f878 100644
--- a/src/analysis/disass/limit.c
+++ b/src/analysis/disass/limit.c
@@ -24,6 +24,9 @@
#include "limit.h"
+#include <assert.h>
+
+
/******************************************************************************
* *
@@ -45,8 +48,9 @@ void compute_routine_limit(GBinSymbol *symbol, const vmpa2t *next, GArchProcesso
const mrange_t *range; /* Emplacement courant */
vmpa2t addr; /* Adresse à conserver */
GArchInstruction *start; /* Première instruction */
- phys_t diff; /* Taille définie par déduction*/
GBinPortion *portion; /* Conteneur avec limites */
+ phys_t pdiff; /* Différence avec ces limites */
+ phys_t diff; /* Taille définie par déduction*/
mrange_t new; /* Nouvel emplacement taillé */
range = g_binary_symbol_get_range(symbol);
@@ -70,25 +74,37 @@ void compute_routine_limit(GBinSymbol *symbol, const vmpa2t *next, GArchProcesso
g_object_unref(G_OBJECT(start));
+ /* Dans tous les cas, on va se référer à la portion contenante... */
+
+ portion = g_binary_portion_find_at_addr(portions, &addr, (GdkRectangle []) { });
+ assert(portion != NULL);
+
+ range = g_binary_portion_get_range(portion);
+
+ pdiff = compute_vmpa_diff(&addr, get_mrange_addr(range));
+ pdiff = get_mrange_length(range) - pdiff;
+
+ g_object_unref(G_OBJECT(portion));
+
/* Si on peut se raccrocher à la prochaine adresse... */
if (next != NULL)
- diff = compute_vmpa_diff(&addr, next);
-
- /* Sinon on va jusqu'à la fin de la zone ! */
- else
{
- portion = g_binary_portion_find_at_addr(portions, &addr, (GdkRectangle []) { });
- if (portion == NULL) goto crl_skip;
-
- range = g_binary_portion_get_range(portion);
+ diff = compute_vmpa_diff(&addr, next);
- diff = compute_vmpa_diff(&addr, get_mrange_addr(range));
- diff = get_mrange_length(range) - diff;
+ /**
+ * On considère qu'un symbole ne peut pas déborder d'un segment
+ * sur un autre.
+ */
- g_object_unref(G_OBJECT(portion));
+ if (diff > pdiff)
+ diff = pdiff;
}
+ /* Sinon on va jusqu'à la fin de la zone ! */
+ else
+ diff = pdiff;
+
init_mrange(&new, &addr, diff);
g_binary_symbol_set_range(symbol, &new);