diff options
Diffstat (limited to 'src/format/elf/section.c')
-rw-r--r-- | src/format/elf/section.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/src/format/elf/section.c b/src/format/elf/section.c index 36fca4d..3feb869 100644 --- a/src/format/elf/section.c +++ b/src/format/elf/section.c @@ -280,11 +280,11 @@ 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] * +* Paramètres : format = description de l'exécutable à consulter. * +* off = position physique à retrouver. * +* pos = position correspondante. [OUT] * * * -* Description : Fournit la position correspondant à une adresse virtuelle. * +* Description : Fournit l'emplacement correspondant à une position physique. * * * * Retour : Bilan de l'opération. * * * @@ -292,11 +292,12 @@ const char *extract_name_from_elf_string_section(const GElfFormat *format, const * * ******************************************************************************/ -bool translate_address_into_offset_using_elf_sections(const GElfFormat *format, vmpa_t addr, off_t *pos) +bool translate_offset_into_vmpa_using_elf_sections(const GElfFormat *format, phys_t off, vmpa2t *pos) { bool result; /* Bilan à retourner */ uint16_t i; /* Boucle de parcours */ elf_shdr section; /* Section à analyser */ + virt_t addr; /* Adresse virtuelle calculée */ result = false; @@ -304,10 +305,11 @@ bool translate_address_into_offset_using_elf_sections(const GElfFormat *format, { 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))) + if (ELF_SHDR(format, section, sh_offset) <= off + && off < (ELF_SHDR(format, section, sh_offset) + ELF_SHDR(format, section, sh_size))) { - *pos = ELF_SHDR(format, section, sh_offset) + addr - ELF_SHDR(format, section, sh_addr); + addr = ELF_SHDR(format, section, sh_addr) + off - ELF_SHDR(format, section, sh_offset); + init_vmpa(pos, off, addr); result = true; } @@ -320,11 +322,11 @@ bool translate_address_into_offset_using_elf_sections(const GElfFormat *format, /****************************************************************************** * * -* Paramètres : format = description de l'exécutable à consulter. * -* pos = position dans le flux binaire à retrouver. * -* addr = adresse virtuelle correspondante. [OUT] * +* Paramètres : format = description de l'exécutable à consulter. * +* addr = adresse virtuelle à retrouver. * +* pos = position correspondante. [OUT] * * * -* Description : Fournit l'adresse virtuelle correspondant à une position. * +* Description : Fournit l'emplacement correspondant à une adresse virtuelle. * * * * Retour : Bilan de l'opération. * * * @@ -332,11 +334,12 @@ bool translate_address_into_offset_using_elf_sections(const GElfFormat *format, * * ******************************************************************************/ -bool translate_offset_into_address_using_elf_sections(const GElfFormat *format, off_t pos, vmpa_t *addr) +bool translate_address_into_vmpa_using_elf_sections(const GElfFormat *format, virt_t addr, vmpa2t *pos) { bool result; /* Bilan à retourner */ uint16_t i; /* Boucle de parcours */ elf_shdr section; /* Section à analyser */ + phys_t off; /* Position physique calculée */ result = false; @@ -344,10 +347,11 @@ bool translate_offset_into_address_using_elf_sections(const GElfFormat *format, { find_elf_section_by_index(format, i, §ion); - if (ELF_SHDR(format, section, sh_offset) <= pos - && pos < (ELF_SHDR(format, section, sh_offset) + ELF_SHDR(format, section, sh_size))) + if (ELF_SHDR(format, section, sh_addr) <= addr + && addr < (ELF_SHDR(format, section, sh_addr) + ELF_SHDR(format, section, sh_size))) { - *addr = ELF_SHDR(format, section, sh_addr) + pos - ELF_SHDR(format, section, sh_offset); + off = ELF_SHDR(format, section, sh_offset) + addr - ELF_SHDR(format, section, sh_addr); + init_vmpa(pos, off, addr); result = true; } |