diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2017-12-08 20:50:56 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2017-12-08 20:50:56 (GMT) |
commit | 39116dce7d40dab310e929f92fdbfc865b5fac20 (patch) | |
tree | a0b8dc11070f8a68de6b6f7bbc84b3d4ccf25afd /plugins/elf | |
parent | cf11fcf862b98ef57935bcfccd6f2f6ae3f925f6 (diff) |
Introduced the symbol visibility.
Diffstat (limited to 'plugins/elf')
-rw-r--r-- | plugins/elf/symbols.c | 60 |
1 files changed, 36 insertions, 24 deletions
diff --git a/plugins/elf/symbols.c b/plugins/elf/symbols.c index 292913b..b5dc2b8 100644 --- a/plugins/elf/symbols.c +++ b/plugins/elf/symbols.c @@ -521,6 +521,8 @@ static bool do_elf_internal_symbol_loading(GElfLoading *loading, GElfFormat *for { bool result; /* Bilan à retourner */ elf_sym sym; /* Symbole aux infos visées */ + SymbolStatus status; /* Visibilité du symbole */ + vmpa2t addr; /* Localisation d'un symbole */ virt_t virt; /* Adresse virtuelle */ const elf_shdr *section; /* Groupe de sections trouvées */ bool use_virt; /* Choix de construction de nom*/ @@ -529,7 +531,6 @@ static bool do_elf_internal_symbol_loading(GElfLoading *loading, GElfFormat *for phys_t first; /* Position du premier élément */ const char *name; /* Nom du symbole trouvé */ GBinFormat *base; /* Version basique du format */ - vmpa2t addr; /* Localisation d'une routine */ GBinSymbol *symbol; /* Nouveau symbole construit */ char alt_name[6 + VMPA_MAX_LEN]; /* Nom abstrait de substitution*/ virt_t final_virt; /* Adresse virtuelle retenue */ @@ -539,23 +540,23 @@ static bool do_elf_internal_symbol_loading(GElfLoading *loading, GElfFormat *for result = read_elf_symbol(format, iter, &sym); if (!result) goto geslp_done; - /* On rejette les symboles qui ne sont pas définis au sein du binaire */ - - if (ELF_SYM(format, sym, st_shndx) == 0) goto geslp_done; - - /* Résolution précise d'adresse */ - - virt = ELF_SYM(format, sym, st_value); - if (virt == 0) goto geslp_done; + /* Nature de la visibilité et adresse associée */ + if (ELF_SYM(format, sym, st_shndx) == 0) + { + status = SSS_IMPORTED; + init_vmpa(&addr, VMPA_NO_PHYSICAL, VMPA_NO_VIRTUAL); - /* TODO */ - - //init_vmpa(&addr, VMPA_NO_PHYSICAL, ELF_SYM(format, sym, st_value)); + } + else + { + status = SSS_EXPORTED; - //init_mrange(&range, &addr, 0); + virt = ELF_SYM(format, sym, st_value); + if (virt == 0) goto geslp_done; + } /* Première ébauche de nom */ @@ -611,18 +612,25 @@ static bool do_elf_internal_symbol_loading(GElfLoading *loading, GElfFormat *for /* Ajustement de la position */ - if (ELF_HDR(format, format->header, e_machine) == EM_ARM) - final_virt = virt & ~0x1; - else - final_virt = virt; + if (status == SSS_IMPORTED) + init_mrange(&range, &addr, 0); - if (!g_exe_format_translate_address_into_vmpa(G_EXE_FORMAT(format), final_virt, &addr)) + else { - symbol = NULL; - break; - } + if (ELF_HDR(format, format->header, e_machine) == EM_ARM) + final_virt = virt & ~0x1; + else + final_virt = virt; + + if (!g_exe_format_translate_address_into_vmpa(G_EXE_FORMAT(format), final_virt, &addr)) + { + symbol = NULL; + break; + } + + init_mrange(&range, &addr, ELF_SYM(format, sym, st_size)); - init_mrange(&range, &addr, ELF_SYM(format, sym, st_size)); + } /* Création d'un nom unique ? */ @@ -644,8 +652,6 @@ static bool do_elf_internal_symbol_loading(GElfLoading *loading, GElfFormat *for routine = try_to_demangle_routine(name); symbol = G_BIN_SYMBOL(routine); - g_binary_symbol_set_range(symbol, &range); - /* Comptabilisation pour le désassemblage brut */ g_binary_format_register_code_point(G_BIN_FORMAT(format), virt, false); @@ -659,8 +665,14 @@ static bool do_elf_internal_symbol_loading(GElfLoading *loading, GElfFormat *for } if (symbol != NULL) + { + g_binary_symbol_set_range(symbol, &range); + g_binary_symbol_set_status(symbol, status); + g_binary_format_add_symbol(base, symbol); + } + geslp_done: return result; |