diff options
Diffstat (limited to 'src/format/elf/section.c')
-rw-r--r-- | src/format/elf/section.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/format/elf/section.c b/src/format/elf/section.c index b8d6a50..cb6a04a 100644 --- a/src/format/elf/section.c +++ b/src/format/elf/section.c @@ -280,6 +280,46 @@ const char *extract_name_from_elf_string_section(const GElfFormat *format, const /****************************************************************************** * * * Paramètres : format = description de l'exécutable à consulter. * +* addr = adresse virtuelle à retrouver. * +* pos = position correspondante. [OUT] * +* * +* Description : Fournit la position correspondant à une adresse virtuelle. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool translate_address_into_offset_using_elf_sections(const GElfFormat *format, vmpa_t addr, off_t *pos) +{ + bool result; /* Bilan à retourner */ + uint16_t i; /* Boucle de parcours */ + elf_shdr section; /* Section à analyser */ + + result = false; + + for (i = 0; i < format->header.e_shnum && !result; i++) + { + find_elf_section_by_index(format, i, §ion); + + if (ELF_SHDR(format, section, sh_addr) <= addr + && addr < (ELF_SHDR(format, section, sh_addr) + ELF_SHDR(format, section, sh_size))) + { + *pos = ELF_SHDR(format, section, sh_offset) + addr - ELF_SHDR(format, section, sh_addr); + result = true; + } + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : format = description de l'exécutable à consulter. * * pos = position dans le flux binaire à retrouver. * * addr = adresse virtuelle correspondante. [OUT] * * * |