summaryrefslogtreecommitdiff
path: root/src/format/elf/elf.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/elf.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/elf.c')
-rw-r--r--src/format/elf/elf.c93
1 files changed, 73 insertions, 20 deletions
diff --git a/src/format/elf/elf.c b/src/format/elf/elf.c
index f188734..bf5a7a2 100644
--- a/src/format/elf/elf.c
+++ b/src/format/elf/elf.c
@@ -57,17 +57,23 @@ static void g_elf_format_class_init(GElfFormatClass *);
/* Initialise une instance de format d'exécutable ELF. */
static void g_elf_format_init(GElfFormat *);
+/* Supprime toutes les références externes. */
+static void g_elf_format_dispose(GElfFormat *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_elf_format_finalize(GElfFormat *);
+
/* Indique le type d'architecture visée par le format. */
static const char *g_elf_format_get_target_machine(const GElfFormat *);
/* Etend la définition des portions au sein d'un binaire. */
static void g_elf_format_refine_portions(const GElfFormat *, GBinPortion *);
-/* Fournit la position correspondant à une adresse virtuelle. */
-static bool g_elf_format_translate_address_into_offset(const GElfFormat *, vmpa_t, off_t *);
+/* Fournit l'emplacement correspondant à une position physique. */
+static bool g_elf_format_translate_offset_into_vmpa(const GElfFormat *, phys_t, vmpa2t *);
-/* Fournit l'adresse virtuelle correspondant à une position. */
-static bool g_elf_format_translate_offset_into_address(const GElfFormat *, off_t, vmpa_t *);
+/* Fournit l'emplacement correspondant à une position physique. */
+static bool g_elf_format_translate_address_into_vmpa(const GElfFormat *, virt_t, vmpa2t *);
@@ -118,6 +124,18 @@ G_DEFINE_TYPE(GElfFormat, g_elf_format, G_TYPE_EXE_FORMAT);
static void g_elf_format_class_init(GElfFormatClass *klass)
{
+ GObjectClass *object; /* Autre version de la classe */
+ GExeFormatClass *exe; /* Version en exécutable */
+
+ object = G_OBJECT_CLASS(klass);
+
+ object->dispose = (GObjectFinalizeFunc/* ! */)g_elf_format_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_elf_format_finalize;
+
+ exe = G_EXE_FORMAT_CLASS(klass);
+
+ 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;
}
@@ -143,8 +161,43 @@ static void g_elf_format_init(GElfFormat *format)
exe_format->get_machine = (get_target_machine_fc)g_elf_format_get_target_machine;
exe_format->refine_portions = (refine_portions_fc)g_elf_format_refine_portions;
- exe_format->translate_addr = (translate_addr_fc)g_elf_format_translate_address_into_offset;
- exe_format->translate_off = (translate_off_fc)g_elf_format_translate_offset_into_address;
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_elf_format_dispose(GElfFormat *format)
+{
+ G_OBJECT_CLASS(g_elf_format_parent_class)->dispose(G_OBJECT(format));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_elf_format_finalize(GElfFormat *format)
+{
+ G_OBJECT_CLASS(g_elf_format_parent_class)->finalize(G_OBJECT(format));
}
@@ -393,11 +446,11 @@ static void g_elf_format_refine_portions(const GElfFormat *format, GBinPortion *
/******************************************************************************
* *
-* 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. *
* *
@@ -405,14 +458,14 @@ static void g_elf_format_refine_portions(const GElfFormat *format, GBinPortion *
* *
******************************************************************************/
-static bool g_elf_format_translate_address_into_offset(const GElfFormat *format, vmpa_t addr, off_t *pos)
+static bool g_elf_format_translate_offset_into_vmpa(const GElfFormat *format, phys_t off, vmpa2t *pos)
{
bool result; /* Bilan à retourner */
- result = translate_address_into_offset_using_elf_sections(format, addr, pos);
+ result = translate_offset_into_vmpa_using_elf_sections(format, off, pos);
if (!result)
- result = translate_address_into_offset_using_elf_programs(format, addr, pos);
+ result = translate_offset_into_vmpa_using_elf_programs(format, off, pos);
return result;
@@ -421,11 +474,11 @@ static bool g_elf_format_translate_address_into_offset(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. *
* *
@@ -433,14 +486,14 @@ static bool g_elf_format_translate_address_into_offset(const GElfFormat *format,
* *
******************************************************************************/
-static bool g_elf_format_translate_offset_into_address(const GElfFormat *format, off_t pos, vmpa_t *addr)
+static bool g_elf_format_translate_address_into_vmpa(const GElfFormat *format, virt_t addr, vmpa2t *pos)
{
bool result; /* Bilan à retourner */
- result = translate_offset_into_address_using_elf_sections(format, pos, addr);
+ result = translate_address_into_vmpa_using_elf_sections(format, addr, pos);
if (!result)
- /* TODO : prgm... */;
+ result = translate_address_into_vmpa_using_elf_programs(format, addr, pos);
return result;