summaryrefslogtreecommitdiff
path: root/src/format/elf/section.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2015-03-29 17:24:22 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2015-03-29 17:24:22 (GMT)
commit52e036040b5e0ad8acde3d467ac8d9ca43ed414c (patch)
tree9f869999534857786fc8e0870772d8e5cabef2fb /src/format/elf/section.c
parent057cee1c3c109639af8f30e39e00f4884a353f31 (diff)
Used real virtual addresses when describing ELF items.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@496 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/format/elf/section.c')
-rw-r--r--src/format/elf/section.c36
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, &section);
- 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, &section);
- 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;
}