summaryrefslogtreecommitdiff
path: root/plugins/elf
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2020-03-01 22:54:45 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2020-03-01 22:54:45 (GMT)
commit0c638aecff9482b93621d77279ac77a8788584e9 (patch)
treec207e648c9d8f8429a29ba1c364fb2293dd4274b /plugins/elf
parenteb68c77804d9b85bc9b3c5a87ba3f64dd83afce1 (diff)
Given some priority to Elf PLT entries during the disassembly process.
Diffstat (limited to 'plugins/elf')
-rw-r--r--plugins/elf/symbols.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/plugins/elf/symbols.c b/plugins/elf/symbols.c
index 2a164a0..004ac6a 100644
--- a/plugins/elf/symbols.c
+++ b/plugins/elf/symbols.c
@@ -109,10 +109,10 @@ static bool load_imported_elf_symbols(GElfFormat *, wgroup_id_t, GtkStatusStack
/* Enregistre un point d'entrée au sein d'un binaire ELF. */
-static bool register_elf_entry_point(GElfFormat *, virt_t, GBinRoutine *);
+static bool register_elf_entry_point(GElfFormat *, virt_t, GBinRoutine *, DisassPriorityLevel);
/* Désigne tous les points d'entrée par une étiquette dédiée. */
-static bool load_elf_entry_points_from_array(GElfFormat *, const elf_dyn *, const elf_dyn *, const char *);
+static bool load_elf_entry_points_from_array(GElfFormat *, const elf_dyn *, const elf_dyn *, const char *, DisassPriorityLevel);
/* Enumère tous les points d'entrée principaux d'un binaire ELF. */
static bool load_all_elf_basic_entry_points(GElfFormat *, GtkStatusStack *);
@@ -295,7 +295,7 @@ static bool do_elf_symbol_loading(GElfLoading *loading, GElfFormat *format, bool
/* Comptabilisation pour le désassemblage brut */
- g_binary_format_register_code_point(base, original_virt, false);
+ g_binary_format_register_code_point(base, original_virt, DPL_SYMBOL);
break;
@@ -982,6 +982,10 @@ static GBinSymbol *do_elf_relocation_convert(GElfLoading *loading, GElfFormat *f
g_binary_symbol_set_status(result, SSS_IMPORTED);
+ /* Comptabilisation pour le désassemblage brut */
+
+ g_binary_format_register_code_point(G_BIN_FORMAT(format), start.virtual, DPL_FORMAT_POINT);
+
exit:
return result;
@@ -1165,6 +1169,7 @@ static bool load_imported_elf_symbols(GElfFormat *format, wgroup_id_t gid, GtkSt
* Paramètres : format = description de l'exécutable à compléter. *
* vaddr = adresse virtuelle du symbole à insérer. *
* routine = représentation de la fonction repérée. *
+* level = indication de priorité et d'origine de l'adresse. *
* *
* Description : Enregistre un point d'entrée au sein d'un binaire ELF. *
* *
@@ -1174,7 +1179,7 @@ static bool load_imported_elf_symbols(GElfFormat *format, wgroup_id_t gid, GtkSt
* *
******************************************************************************/
-static bool register_elf_entry_point(GElfFormat *format, virt_t vaddr, GBinRoutine *routine)
+static bool register_elf_entry_point(GElfFormat *format, virt_t vaddr, GBinRoutine *routine, DisassPriorityLevel level)
{
bool result; /* Bilan à renvoyer */
virt_t final_vaddr; /* Adresse virtuelle retenue */
@@ -1226,7 +1231,7 @@ static bool register_elf_entry_point(GElfFormat *format, virt_t vaddr, GBinRouti
g_object_unref(G_OBJECT(symbol));
/* Comptabilisation pour le désassemblage brut */
- g_binary_format_register_code_point(base, vaddr, true);
+ g_binary_format_register_code_point(base, vaddr, level);
exit:
@@ -1241,6 +1246,7 @@ static bool register_elf_entry_point(GElfFormat *format, virt_t vaddr, GBinRouti
* array = indications quant au tableau à charger. *
* size = indications quant à la taille de ce tableau. *
* prefix = désignation de base des éléments du tableau. *
+* level = indication de priorité et d'origine de l'adresse. *
* *
* Description : Désigne tous les points d'entrée par une étiquette dédiée. *
* *
@@ -1250,7 +1256,7 @@ static bool register_elf_entry_point(GElfFormat *format, virt_t vaddr, GBinRouti
* *
******************************************************************************/
-static bool load_elf_entry_points_from_array(GElfFormat *format, const elf_dyn *array, const elf_dyn *size, const char *prefix)
+static bool load_elf_entry_points_from_array(GElfFormat *format, const elf_dyn *array, const elf_dyn *size, const char *prefix, DisassPriorityLevel level)
{
bool result; /* Bilan à renvoyer */
GBinFormat *base; /* Autre version du format */
@@ -1313,7 +1319,7 @@ static bool load_elf_entry_points_from_array(GElfFormat *format, const elf_dyn *
snprintf(fullname, sizeof(fullname), "%s%u", prefix, i);
routine = g_binary_format_decode_routine(base, fullname);
- result = register_elf_entry_point(format, ep, routine);
+ result = register_elf_entry_point(format, ep, routine, level);
}
@@ -1363,7 +1369,7 @@ static bool load_all_elf_basic_entry_points(GElfFormat *format, GtkStatusStack *
if (ep != 0x0)
{
routine = g_binary_format_decode_routine(base, "entry_point");
- result = register_elf_entry_point(format, ep, routine);
+ result = register_elf_entry_point(format, ep, routine, DPL_ENTRY_POINT);
if (!result) goto exit;
}
@@ -1381,7 +1387,7 @@ static bool load_all_elf_basic_entry_points(GElfFormat *format, GtkStatusStack *
if (ep != 0x0)
{
routine = g_binary_format_decode_routine(base, "init_function");
- result = register_elf_entry_point(format, ep, routine);
+ result = register_elf_entry_point(format, ep, routine, DPL_ENTRY_POINT);
if (!result) goto exit;
}
@@ -1394,7 +1400,7 @@ static bool load_all_elf_basic_entry_points(GElfFormat *format, GtkStatusStack *
if (ep != 0x0)
{
routine = g_binary_format_decode_routine(base, "termination_function");
- result = register_elf_entry_point(format, ep, routine);
+ result = register_elf_entry_point(format, ep, routine, DPL_FORMAT_POINT);
if (!result) goto exit;
}
@@ -1404,7 +1410,8 @@ static bool load_all_elf_basic_entry_points(GElfFormat *format, GtkStatusStack *
{
if (_find_elf_dynamic_item_by_type(format, &dynamic, DT_INIT_ARRAYSZ, &item_b))
{
- result = load_elf_entry_points_from_array(format, &item_a, &item_b, "init_array_function_");
+ result = load_elf_entry_points_from_array(format, &item_a, &item_b,
+ "init_array_function_", DPL_ENTRY_POINT);
if (!result) goto exit;
}
@@ -1414,7 +1421,8 @@ static bool load_all_elf_basic_entry_points(GElfFormat *format, GtkStatusStack *
{
if (_find_elf_dynamic_item_by_type(format, &dynamic, DT_FINI_ARRAYSZ, &item_b))
{
- result = load_elf_entry_points_from_array(format, &item_a, &item_b, "fini_array_function_");
+ result = load_elf_entry_points_from_array(format, &item_a, &item_b,
+ "fini_array_function_", DPL_FORMAT_POINT);
if (!result) goto exit;
}
@@ -1424,7 +1432,8 @@ static bool load_all_elf_basic_entry_points(GElfFormat *format, GtkStatusStack *
{
if (_find_elf_dynamic_item_by_type(format, &dynamic, DT_PREINIT_ARRAYSZ, &item_b))
{
- result = load_elf_entry_points_from_array(format, &item_a, &item_b, "preinit_array_function_");
+ result = load_elf_entry_points_from_array(format, &item_a, &item_b,
+ "preinit_array_function_", DPL_ENTRY_POINT);
if (!result) goto exit;
}
@@ -1437,7 +1446,7 @@ static bool load_all_elf_basic_entry_points(GElfFormat *format, GtkStatusStack *
if (ep != 0x0)
{
routine = g_binary_format_decode_routine(base, "plt_entry");
- result = register_elf_entry_point(format, ep, routine);
+ result = register_elf_entry_point(format, ep, routine, DPL_FORMAT_POINT);
}
}