diff options
Diffstat (limited to 'plugins/elf/symbols.c')
-rw-r--r-- | plugins/elf/symbols.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/plugins/elf/symbols.c b/plugins/elf/symbols.c index 26876bd..854d724 100644 --- a/plugins/elf/symbols.c +++ b/plugins/elf/symbols.c @@ -101,7 +101,7 @@ static bool do_elf_relocation_loading(GElfLoading *, GElfFormat *, phys_t *); static bool load_elf_relocations(GElfFormat *, const elf_phdr *, elf_rel **, size_t *, wgroup_id_t, GtkStatusStack *); /* Assure l'intégration d'un symbole issu des relocalisations. */ -static bool do_elf_relocation_renaming(GElfLoading *, GElfFormat *, GBinSymbol *); +static bool do_elf_relocation_renaming(GElfLoading *, GElfFormat *, virt_t *, GBinSymbol *); /* Applique les étiquettes issues des relocalisations. */ static bool apply_elf_relocations(GElfFormat *, elf_rel *, size_t, sym_iter_t *, wgroup_id_t, GtkStatusStack *); @@ -1263,6 +1263,7 @@ bool refresh_elf_relocations(GElfFormat *format, wgroup_id_t gid, GtkStatusStack * * * Paramètres : loading = chargement de relocalisations en cours. * * format = format ELF à compléter. * +* valid = dernière adresse virtuelle non couverte. [OUT] * * symbol = symbole courant issu de la liste à analyser. * * * * Description : Assure l'intégration d'un symbole issu des relocalisations. * @@ -1273,7 +1274,7 @@ bool refresh_elf_relocations(GElfFormat *format, wgroup_id_t gid, GtkStatusStack * * ******************************************************************************/ -static bool do_elf_relocation_renaming(GElfLoading *loading, GElfFormat *format, GBinSymbol *symbol) +static bool do_elf_relocation_renaming(GElfLoading *loading, GElfFormat *format, virt_t *valid, GBinSymbol *symbol) { bool result; /* Bilan à retourner */ const mrange_t *range; /* Espace occupé par le symbole*/ @@ -1290,6 +1291,22 @@ static bool do_elf_relocation_renaming(GElfLoading *loading, GElfFormat *format, range = g_binary_symbol_get_range(symbol); + /** + * Il peut arriver qu'un symbole figure par erreur dans la liste des symboles + * importés. Cela fait par exemple suite au désassemblage d'une zone considèrée + * de façon erronée comme du code, opération qui conduit à la création fortuite + * d'un symbole non désiré. + * + * On se prémunit ici d'une erreur de traitement en vérifiant simplement la + * couverture des symboles externes, qui englobe un éventuel symbole superflu. + */ + + if (range->addr.virtual < *valid) + { + result = true; + goto exit; + } + stype = g_binary_symbol_get_stype(symbol); if (stype != STP_ROUTINE && stype != STP_CODE_LABEL && stype != STP_ENTRY_POINT) @@ -1297,7 +1314,7 @@ static bool do_elf_relocation_renaming(GElfLoading *loading, GElfFormat *format, g_binary_format_add_error(G_BIN_FORMAT(format), BFE_SPECIFICATION, get_mrange_addr(range), _("The PLT seems to contains more than routines")); - goto derr_exit; + goto exit; } @@ -1308,10 +1325,10 @@ static bool do_elf_relocation_renaming(GElfLoading *loading, GElfFormat *format, /* Détermination de la relocalisation associée */ result = format->ops.get_linkage_offset(format, range, &offset); - if (!result) goto derr_exit; + if (!result) goto exit; result = g_elf_loading_search_for_relocation(loading, &offset, &reloc); - if (!result) goto derr_exit; + if (!result) goto exit; /* Récupération des données du symbole visé */ @@ -1342,7 +1359,9 @@ static bool do_elf_relocation_renaming(GElfLoading *loading, GElfFormat *format, free(name); - derr_exit: + *valid = range->addr.virtual + range->length; + + exit: return result; |