diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2017-07-08 10:14:12 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2017-07-08 10:14:12 (GMT) |
commit | 9b018cede5af54594c0a20847239233153b04ce1 (patch) | |
tree | 0492a9d831b682bab10dd113d7bb01e0b2700638 /src/format/elf | |
parent | 1194c79f2b7ccca24d9f89090722ed1157cbc5e1 (diff) |
Scrolled to the main address at startup without using a nested function.
Diffstat (limited to 'src/format/elf')
-rw-r--r-- | src/format/elf/elf.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/format/elf/elf.c b/src/format/elf/elf.c index 0336ba3..1254e52 100644 --- a/src/format/elf/elf.c +++ b/src/format/elf/elf.c @@ -69,6 +69,9 @@ static SourceEndian g_elf_format_get_endianness(const GElfFormat *); /* Indique le type d'architecture visée par le format. */ static const char *g_elf_format_get_target_machine(const GElfFormat *); +/* Fournit l'adresse principale associée à un format Elf. */ +static bool g_elf_format_get_main_address(GElfFormat *, vmpa2t *); + /* Etend la définition des portions au sein d'un binaire. */ static void g_elf_format_refine_portions(GElfFormat *); @@ -161,6 +164,7 @@ static void g_elf_format_class_init(GElfFormatClass *klass) exe = G_EXE_FORMAT_CLASS(klass); exe->get_machine = (get_target_machine_fc)g_elf_format_get_target_machine; + exe->get_main_addr = (get_main_addr_fc)g_elf_format_get_main_address; exe->refine_portions = (refine_portions_fc)g_elf_format_refine_portions; exe->translate_phys = (translate_phys_fc)g_elf_format_translate_offset_into_vmpa; @@ -397,6 +401,57 @@ static const char *g_elf_format_get_target_machine(const GElfFormat *format) /****************************************************************************** * * +* Paramètres : format = description de l'exécutable à consulter. * +* addr = adresse principale trouvée si possible. [OUT] * +* * +* Description : Fournit l'adresse principale associée à un format Elf. * +* * +* Retour : Bilan des recherches. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static bool g_elf_format_get_main_address(GElfFormat *format, vmpa2t *addr) +{ + bool result; /* Bilan à retourner */ + GBinSymbol *symbol; /* Point d'entrée trouvé */ + GBinFormat *base; /* Version d'instance parente */ + const mrange_t *range; /* Emplacement de ce point */ + + result = false; + symbol = NULL; + + base = G_BIN_FORMAT(format); + + if (g_binary_format_find_symbol_by_label(base, "main", &symbol)) + goto done; + + if (g_binary_format_find_symbol_by_label(base, "_start", &symbol)) + goto done; + + if (g_binary_format_find_symbol_by_label(base, "entry_point", &symbol)) + goto done; + + done: + + if (symbol != NULL) + { + result = true; + + range = g_binary_symbol_get_range(symbol); + + copy_vmpa(addr, get_mrange_addr(range)); + + } + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : format = informations chargées à consulter. * * * * Description : Etend la définition des portions au sein d'un binaire. * |