summaryrefslogtreecommitdiff
path: root/plugins/elf
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-05-24 07:43:32 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-05-24 07:43:32 (GMT)
commit08c45a8c7970403c3d658b1b0af9ac09f66b4a7e (patch)
tree25a8108e36b7328c266ba6e71647243dfd6b7cac /plugins/elf
parent7135e7944c91d2e8b787c8782375423b9a90ed5b (diff)
Translated offsets and addresses with more accuracy.
Diffstat (limited to 'plugins/elf')
-rw-r--r--plugins/elf/format.c68
-rw-r--r--plugins/elf/program.c84
-rw-r--r--plugins/elf/program.h6
-rw-r--r--plugins/elf/section.c84
-rw-r--r--plugins/elf/section.h6
5 files changed, 4 insertions, 244 deletions
diff --git a/plugins/elf/format.c b/plugins/elf/format.c
index 9e29a11..3394ba2 100644
--- a/plugins/elf/format.c
+++ b/plugins/elf/format.c
@@ -84,12 +84,6 @@ static bool g_elf_format_get_main_address(GElfFormat *, vmpa2t *);
/* Etend la définition des portions au sein d'un binaire. */
static void g_elf_format_refine_portions(GElfFormat *);
-/* Fournit l'emplacement correspondant à une position physique. */
-static bool g_elf_format_translate_offset_into_vmpa(const GElfFormat *, phys_t, vmpa2t *);
-
-/* Fournit l'emplacement correspondant à une position physique. */
-static bool g_elf_format_translate_address_into_vmpa(const GElfFormat *, virt_t, vmpa2t *);
-
/* Fournit l'emplacement d'une section donnée. */
static bool g_elf_format_get_section_range_by_name(const GElfFormat *, const char *, mrange_t *);
@@ -167,8 +161,8 @@ static void g_elf_format_class_init(GElfFormatClass *klass)
exe->get_main_addr = (get_main_addr_fc)g_elf_format_get_main_address;
exe->refine_portions = (refine_portions_fc)g_elf_format_refine_portions;
- exe->translate_phys = (translate_phys_fc)g_elf_format_translate_offset_into_vmpa;
- exe->translate_virt = (translate_virt_fc)g_elf_format_translate_address_into_vmpa;
+ exe->translate_phys = (translate_phys_fc)g_exe_format_translate_offset_into_vmpa_using_portions;
+ exe->translate_virt = (translate_virt_fc)g_exe_format_translate_address_into_vmpa_using_portions;
exe->get_range_by_name = (get_range_by_name_fc)g_elf_format_get_section_range_by_name;
@@ -382,6 +376,8 @@ static bool g_elf_format_analyze(GElfFormat *format, wgroup_id_t gid, GtkStatusS
/* Chargements des informations utiles */
+ g_executable_format_setup_portions(exe, status);
+
/**
* On inscrit les éléments préchargés avant tout !
*
@@ -698,62 +694,6 @@ static void g_elf_format_refine_portions(GElfFormat *format)
/******************************************************************************
* *
* Paramètres : format = description de l'exécutable à consulter. *
-* off = position physique à retrouver. *
-* pos = position correspondante. [OUT] *
-* *
-* Description : Fournit l'emplacement correspondant à une position physique. *
-* *
-* Retour : Bilan de l'opération. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static bool g_elf_format_translate_offset_into_vmpa(const GElfFormat *format, phys_t off, vmpa2t *pos)
-{
- bool result; /* Bilan à retourner */
-
- result = translate_offset_into_vmpa_using_elf_sections(format, off, pos);
-
- if (!result)
- result = translate_offset_into_vmpa_using_elf_programs(format, off, pos);
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : format = description de l'exécutable à consulter. *
-* addr = adresse virtuelle à retrouver. *
-* pos = position correspondante. [OUT] *
-* *
-* Description : Fournit l'emplacement correspondant à une adresse virtuelle. *
-* *
-* Retour : Bilan de l'opération. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static bool g_elf_format_translate_address_into_vmpa(const GElfFormat *format, virt_t addr, vmpa2t *pos)
-{
- bool result; /* Bilan à retourner */
-
- result = translate_address_into_vmpa_using_elf_sections(format, addr, pos);
-
- if (!result)
- result = translate_address_into_vmpa_using_elf_programs(format, addr, pos);
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : format = description de l'exécutable à consulter. *
* name = nom de la section recherchée. *
* range = emplacement en mémoire à renseigner. [OUT] *
* *
diff --git a/plugins/elf/program.c b/plugins/elf/program.c
index 7fb63df..f4924f5 100644
--- a/plugins/elf/program.c
+++ b/plugins/elf/program.c
@@ -152,87 +152,3 @@ bool find_elf_program_by_type(const GElfFormat *format, uint32_t type, elf_phdr
return result;
}
-
-
-/******************************************************************************
-* *
-* Paramètres : format = description de l'exécutable à consulter. *
-* off = position physique à retrouver. *
-* pos = position correspondante. [OUT] *
-* *
-* Description : Fournit l'emplacement correspondant à une position physique. *
-* *
-* Retour : Bilan de l'opération. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-bool translate_offset_into_vmpa_using_elf_programs(const GElfFormat *format, phys_t off, vmpa2t *pos)
-{
- bool result; /* Bilan à retourner */
- uint16_t i; /* Boucle de parcours */
- elf_phdr program; /* Programme à analyser */
- virt_t addr; /* Adresse virtuelle calculée */
-
- result = false;
-
- for (i = 0; i < ELF_HDR(format, format->header, e_phnum) && !result; i++)
- {
- find_elf_program_by_index(format, i, &program);
-
- if (ELF_PHDR(format, program, p_offset) <= off
- && off < (ELF_PHDR(format, program, p_offset) + ELF_PHDR(format, program, p_filesz)))
- {
- addr = ELF_PHDR(format, program, p_vaddr) + ELF_PHDR(format, program, p_offset) - off;
- init_vmpa(pos, off, addr);
- result = true;
- }
-
- }
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : format = description de l'exécutable à consulter. *
-* addr = adresse virtuelle à retrouver. *
-* pos = position correspondante. [OUT] *
-* *
-* Description : Fournit l'emplacement correspondant à une adresse virtuelle. *
-* *
-* Retour : Bilan de l'opération. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-bool translate_address_into_vmpa_using_elf_programs(const GElfFormat *format, virt_t addr, vmpa2t *pos)
-{
- bool result; /* Bilan à retourner */
- uint16_t i; /* Boucle de parcours */
- elf_phdr program; /* Programme à analyser */
- phys_t off; /* Position physique calculée */
-
- result = false;
-
- for (i = 0; i < ELF_HDR(format, format->header, e_phnum) && !result; i++)
- {
- find_elf_program_by_index(format, i, &program);
-
- if (ELF_PHDR(format, program, p_vaddr) <= addr
- && addr < (ELF_PHDR(format, program, p_vaddr) + ELF_PHDR(format, program, p_filesz)))
- {
- off = ELF_PHDR(format, program, p_offset) + addr - ELF_PHDR(format, program, p_vaddr);
- init_vmpa(pos, off, addr);
- result = true;
- }
-
- }
-
- return result;
-
-}
diff --git a/plugins/elf/program.h b/plugins/elf/program.h
index 7c73340..34969cb 100644
--- a/plugins/elf/program.h
+++ b/plugins/elf/program.h
@@ -39,12 +39,6 @@ bool find_elf_program_by_index(const GElfFormat *, uint16_t, elf_phdr *);
/* Recherche un programme donné au sein de binaire par type. */
bool find_elf_program_by_type(const GElfFormat *, uint32_t, elf_phdr *);
-/* Fournit l'emplacement correspondant à une position physique. */
-bool translate_offset_into_vmpa_using_elf_programs(const GElfFormat *, phys_t, vmpa2t *);
-
-/* Fournit l'emplacement correspondant à une adresse virtuelle. */
-bool translate_address_into_vmpa_using_elf_programs(const GElfFormat *, virt_t, vmpa2t *);
-
#endif /* _PLUGINS_ELF_PROGRAM_H */
diff --git a/plugins/elf/section.c b/plugins/elf/section.c
index cc47f9d..0e2fd3e 100644
--- a/plugins/elf/section.c
+++ b/plugins/elf/section.c
@@ -342,87 +342,3 @@ const char *extract_name_from_elf_string_section(const GElfFormat *format, const
return result;
}
-
-
-/******************************************************************************
-* *
-* Paramètres : format = description de l'exécutable à consulter. *
-* off = position physique à retrouver. *
-* pos = position correspondante. [OUT] *
-* *
-* Description : Fournit l'emplacement correspondant à une position physique. *
-* *
-* Retour : Bilan de l'opération. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-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;
-
- for (i = 0; i < ELF_HDR(format, format->header, e_shnum) && !result; i++)
- {
- find_elf_section_by_index(format, i, &section);
-
- if (ELF_SHDR(format, section, sh_offset) <= off
- && off < (ELF_SHDR(format, section, sh_offset) + ELF_SHDR(format, section, sh_size)))
- {
- addr = ELF_SHDR(format, section, sh_addr) + off - ELF_SHDR(format, section, sh_offset);
- init_vmpa(pos, off, addr);
- result = true;
- }
-
- }
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : format = description de l'exécutable à consulter. *
-* addr = adresse virtuelle à retrouver. *
-* pos = position correspondante. [OUT] *
-* *
-* Description : Fournit l'emplacement correspondant à une adresse virtuelle. *
-* *
-* Retour : Bilan de l'opération. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-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;
-
- for (i = 0; i < ELF_HDR(format, format->header, e_shnum) && !result; i++)
- {
- 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)))
- {
- off = ELF_SHDR(format, section, sh_offset) + addr - ELF_SHDR(format, section, sh_addr);
- init_vmpa(pos, off, addr);
- result = true;
- }
-
- }
-
- return result;
-
-}
diff --git a/plugins/elf/section.h b/plugins/elf/section.h
index 021caf0..ac74ab1 100644
--- a/plugins/elf/section.h
+++ b/plugins/elf/section.h
@@ -57,12 +57,6 @@ bool find_elf_section_range_by_name(const GElfFormat *, const char *, mrange_t *
/* Identifie une chaîne de caractères dans une section adéquate. */
const char *extract_name_from_elf_string_section(const GElfFormat *, const elf_shdr *, off_t);
-/* Fournit l'emplacement correspondant à une position physique. */
-bool translate_offset_into_vmpa_using_elf_sections(const GElfFormat *, phys_t, vmpa2t *);
-
-/* Fournit l'emplacement correspondant à une adresse virtuelle. */
-bool translate_address_into_vmpa_using_elf_sections(const GElfFormat *, virt_t, vmpa2t *);
-
#endif /* _PLUGINS_ELF_SECTION_H */