summaryrefslogtreecommitdiff
path: root/src/glibext
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2017-07-15 09:58:58 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2017-07-15 09:58:58 (GMT)
commit52d721c47cce927345cb5e66674ca2cc48d75349 (patch)
treefbfb4e38586f96f17e282b45851c70edaa5e0536 /src/glibext
parentf3184725ec750317c04f1989ac83c2bbc75865a9 (diff)
Truncated binary portions to fit the binary content size if needed.
Diffstat (limited to 'src/glibext')
-rw-r--r--src/glibext/gbinportion.c34
-rw-r--r--src/glibext/gbinportion.h3
2 files changed, 37 insertions, 0 deletions
diff --git a/src/glibext/gbinportion.c b/src/glibext/gbinportion.c
index b8e3ed7..731cd08 100644
--- a/src/glibext/gbinportion.c
+++ b/src/glibext/gbinportion.c
@@ -485,6 +485,40 @@ const mrange_t *g_binary_portion_get_range(const GBinPortion *portion)
}
+/******************************************************************************
+* *
+* Paramètres : portion = description de partie à mettre à jour. *
+* max = première position physique hors limite. *
+* *
+* Description : Assure qu'une portion ne dépasse pas une position donnée. *
+* *
+* Retour : true si la portion a été modifiée, false sinon. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool g_binary_portion_limit_range(GBinPortion *portion, phys_t max)
+{
+ bool result; /* Bilan à retourner */
+ vmpa2t end; /* Limite actuelle de portion */
+ const vmpa2t *start; /* Position de départ */
+
+ compute_mrange_end_addr(&portion->range, &end);
+
+ result = get_phy_addr(&end) > max;
+
+ if (result)
+ {
+ start = get_mrange_addr(&portion->range);
+ set_mrange_length(&portion->range, max - get_phy_addr(start));
+
+ }
+
+ return result;
+
+}
+
/******************************************************************************
* *
diff --git a/src/glibext/gbinportion.h b/src/glibext/gbinportion.h
index 9f22e3d..14a6960 100644
--- a/src/glibext/gbinportion.h
+++ b/src/glibext/gbinportion.h
@@ -99,6 +99,9 @@ const char *g_binary_portion_get_desc(const GBinPortion *);
/* Fournit l'emplacement d'une partie de code binaire. */
const mrange_t *g_binary_portion_get_range(const GBinPortion *);
+/* Assure qu'une portion ne dépasse pas une position donnée. */
+bool g_binary_portion_limit_range(GBinPortion *, phys_t);
+
/* Définit la nature de la portion en terme d'originalité. */
void g_binary_portion_mark_as_continued(GBinPortion *, bool);