summaryrefslogtreecommitdiff
path: root/src/format/elf/section.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2009-12-13 11:54:32 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2009-12-13 11:54:32 (GMT)
commit7468875c1022337efbff78069d715672ae083150 (patch)
tree0a8e5ce9cce113506a601539c9aa0a1b4ae48680 /src/format/elf/section.c
parentc6409e2c6a390a7cca40da8572c93a5268e90a27 (diff)
Loaded and saved binary parts.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@140 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/format/elf/section.c')
-rw-r--r--src/format/elf/section.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/format/elf/section.c b/src/format/elf/section.c
index f837dbf..b8d6a50 100644
--- a/src/format/elf/section.c
+++ b/src/format/elf/section.c
@@ -275,3 +275,43 @@ const char *extract_name_from_elf_string_section(const GElfFormat *format, const
return result;
}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = description de l'exécutable à consulter. *
+* pos = position dans le flux binaire à retrouver. *
+* addr = adresse virtuelle correspondante. [OUT] *
+* *
+* Description : Fournit l'adresse virtuelle correspondant à une position. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool translate_offset_into_address_using_elf_sections(const GElfFormat *format, off_t pos, vmpa_t *addr)
+{
+ 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, &section);
+
+ if (ELF_SHDR(format, section, sh_offset) <= pos
+ && pos < (ELF_SHDR(format, section, sh_offset) + ELF_SHDR(format, section, sh_size)))
+ {
+ *addr = ELF_SHDR(format, section, sh_addr) + pos - ELF_SHDR(format, section, sh_offset);
+ result = true;
+ }
+
+ }
+
+ return result;
+
+}