From 1e7c7de85438749d3faf7b76984b86a9c088fbc1 Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Sun, 15 Oct 2017 23:44:28 +0200
Subject: Refactored ELF related code.

---
 ChangeLog                      |  38 +++
 plugins/elf/Makefile.am        |   4 +-
 plugins/elf/core.c             |   2 +-
 plugins/elf/dynamic.h          |   8 +-
 plugins/elf/elf-int.h          |   8 +-
 plugins/elf/elf.c              | 707 -----------------------------------------
 plugins/elf/elf.h              |  68 ----
 plugins/elf/elf_def.h          |   9 +-
 plugins/elf/elf_def_arm.h      |   6 +-
 plugins/elf/format.c           | 707 +++++++++++++++++++++++++++++++++++++++++
 plugins/elf/format.h           |  68 ++++
 plugins/elf/helper_arm.h       |   6 +-
 plugins/elf/loading.h          |  16 +-
 plugins/elf/program.h          |   8 +-
 plugins/elf/python/Makefile.am |   4 +-
 plugins/elf/python/elf.c       | 198 ------------
 plugins/elf/python/elf.h       |  42 ---
 plugins/elf/python/format.c    | 198 ++++++++++++
 plugins/elf/python/format.h    |  42 +++
 plugins/elf/python/module.c    |   2 +-
 plugins/elf/section.h          |   8 +-
 plugins/elf/strings.h          |   8 +-
 plugins/elf/symbols.h          |   8 +-
 plugins/libcsem/semantic.c     |   2 +-
 plugins/readelf/header.c       |   2 +-
 plugins/readelf/program.h      |   2 +-
 plugins/readelf/reader.c       |   2 +-
 plugins/readelf/section.h      |   2 +-
 plugins/readelf/strtab.h       |   2 +-
 29 files changed, 1102 insertions(+), 1075 deletions(-)
 delete mode 100644 plugins/elf/elf.c
 delete mode 100644 plugins/elf/elf.h
 create mode 100644 plugins/elf/format.c
 create mode 100644 plugins/elf/format.h
 delete mode 100644 plugins/elf/python/elf.c
 delete mode 100644 plugins/elf/python/elf.h
 create mode 100644 plugins/elf/python/format.c
 create mode 100644 plugins/elf/python/format.h

diff --git a/ChangeLog b/ChangeLog
index f5950db..d868934 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,41 @@
+17-10-15  Cyrille Bagard <nocbos@gmail.com>
+
+	* plugins/elf/Makefile.am:
+	* plugins/elf/core.c:
+	* plugins/elf/dynamic.h:
+	* plugins/elf/elf-int.h:
+	* plugins/elf/elf_def.h:
+	* plugins/elf/elf_def_arm.h:
+	Refactor ELF related code.
+
+	* plugins/elf/format.c:
+	* plugins/elf/format.h:
+	Renamed entries.
+
+	* plugins/elf/helper_arm.h:
+	* plugins/elf/loading.h:
+	* plugins/elf/program.h:
+	* plugins/elf/python/Makefile.am:
+	Refactor ELF related code.
+
+	* plugins/elf/python/format.c:
+	* plugins/elf/python/format.h:
+	Renamed entries.
+
+	* plugins/elf/python/module.c:
+	* plugins/elf/section.h:
+	* plugins/elf/strings.h:
+	* plugins/elf/symbols.h:
+	Refactor ELF related code.
+
+	* plugins/libcsem/semantic.c:
+	* plugins/readelf/header.c:
+	* plugins/readelf/program.h:
+	* plugins/readelf/reader.c:
+	* plugins/readelf/section.h:
+	* plugins/readelf/strtab.h:
+	Update code.
+
 17-10-04  Cyrille Bagard <nocbos@gmail.com>
 
 	* plugins/elf/core.c:
diff --git a/plugins/elf/Makefile.am b/plugins/elf/Makefile.am
index d3cfe05..6d7fb58 100644
--- a/plugins/elf/Makefile.am
+++ b/plugins/elf/Makefile.am
@@ -4,9 +4,9 @@ lib_LTLIBRARIES = libelf.la
 libelf_la_SOURCES =						\
 	core.h core.c						\
 	elf-int.h elf-int.c					\
-	elf.h elf.c							\
 	elf_def.h							\
 	elf_def_arm.h						\
+	format.h format.c					\
 	dynamic.h dynamic.c					\
 	helper_arm.h helper_arm.c			\
 	loading.h loading.c					\
@@ -22,7 +22,7 @@ libelf_la_LDFLAGS = 					\
 	$(LIBPYTHON_LIBS) $(LIBPYGOBJECT_LIBS)
 
 
-AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBPYTHON_CFLAGS) $(LIBPYGOBJECT_CFLAGS) $(LIBXML_CFLAGS) -I../../src
+AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBPYTHON_CFLAGS) $(LIBPYGOBJECT_CFLAGS) $(LIBXML_CFLAGS) -I$(top_srcdir)/src
 
 AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS)
 
diff --git a/plugins/elf/core.c b/plugins/elf/core.c
index fde6be1..ebd980e 100644
--- a/plugins/elf/core.c
+++ b/plugins/elf/core.c
@@ -28,7 +28,7 @@
 #include <plugins/plugin-def.h>
 
 
-#include "elf.h"
+#include "format.h"
 #include "python/module.h"
 
 
diff --git a/plugins/elf/dynamic.h b/plugins/elf/dynamic.h
index 7fce1d4..ee5d3d8 100644
--- a/plugins/elf/dynamic.h
+++ b/plugins/elf/dynamic.h
@@ -21,12 +21,12 @@
  */
 
 
-#ifndef _FORMAT_ELF_DYNAMIC_H
-#define _FORMAT_ELF_DYNAMIC_H
+#ifndef _PLUGINS_ELF_DYNAMIC_H
+#define _PLUGINS_ELF_DYNAMIC_H
 
 
-#include "elf.h"
 #include "elf_def.h"
+#include "format.h"
 
 
 
@@ -38,4 +38,4 @@ bool find_elf_dynamic_item_from_pheader(const GElfFormat *, const elf_phdr *, in
 
 
 
-#endif  /* _FORMAT_ELF_DYNAMIC_H */
+#endif  /* _PLUGINS_ELF_DYNAMIC_H */
diff --git a/plugins/elf/elf-int.h b/plugins/elf/elf-int.h
index 34f15cb..3b4b67c 100644
--- a/plugins/elf/elf-int.h
+++ b/plugins/elf/elf-int.h
@@ -21,16 +21,16 @@
  */
 
 
-#ifndef _FORMAT_ELF_ELF_INT_H
-#define _FORMAT_ELF_ELF_INT_H
+#ifndef _PLUGINS_ELF_ELF_INT_H
+#define _PLUGINS_ELF_ELF_INT_H
 
 
 #include <common/endianness.h>
 #include <format/executable-int.h>
 
 
-#include "elf.h"
 #include "elf_def.h"
+#include "format.h"
 
 
 
@@ -77,4 +77,4 @@ bool read_elf_note(const GElfFormat *, GBinContent *, phys_t *, elf_note *);
 
 
 
-#endif  /* _FORMAT_ELF_ELF_INT_H */
+#endif  /* _PLUGINS_ELF_ELF_INT_H */
diff --git a/plugins/elf/elf.c b/plugins/elf/elf.c
deleted file mode 100644
index 04ee031..0000000
--- a/plugins/elf/elf.c
+++ /dev/null
@@ -1,707 +0,0 @@
-
-/* Chrysalide - Outil d'analyse de fichiers binaires
- * elf.c - support du format ELF
- *
- * Copyright (C) 2009-2017 Cyrille Bagard
- *
- *  This file is part of Chrysalide.
- *
- *  Chrysalide is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  Chrysalide is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#include "elf.h"
-
-
-#include <malloc.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <string.h>
-
-
-#include <i18n.h>
-#include <gui/panels/log.h>
-#include <plugins/pglist.h>
-
-
-#include "elf-int.h"
-#include "program.h"
-#include "section.h"
-#include "strings.h"
-#include "symbols.h"
-
-
-
-/* Taille maximale d'une description */
-#define MAX_PORTION_DESC 256
-
-
-/* Initialise la classe des formats d'exécutables ELF. */
-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 *);
-
-/* Informe quant au boutisme utilisé. */
-static SourceEndian g_elf_format_get_endianness(const GElfFormat *);
-
-/* Indique le type d'architecture visée par le format. */
-static const char *g_elf_format_get_target_machine(const GElfFormat *);
-
-/* Fournit l'adresse principale associée à un format Elf. */
-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 *);
-
-
-
-/******************************************************************************
-*                                                                             *
-*  Paramètres  : content = contenu binaire à parcourir.                       *
-*                parent  = éventuel format exécutable déjà chargé.            *
-*                unused  = adresse non utilisée ici.                          *
-*                key     = identifiant de format trouvé ou NULL. [OUT]        *
-*                                                                             *
-*  Description : Indique si le format peut être pris en charge ici.           *
-*                                                                             *
-*  Retour      : Conclusion de haut niveau sur la reconnaissance effectuée.   *
-*                                                                             *
-*  Remarques   : -                                                            *
-*                                                                             *
-******************************************************************************/
-
-FormatMatchStatus elf_is_matching(GBinContent *content, GExeFormat *parent, void *unused, char **key)
-{
-    FormatMatchStatus result;               /* Bilan à renvoyer            */
-    vmpa2t addr;                            /* Tête de lecture initiale    */
-    bool status;                            /* Bilan des accès mémoire     */
-    char magic[4];                          /* Idenfiant standard          */
-
-    if (parent != NULL)
-        return FMS_UNKNOWN;
-
-    init_vmpa(&addr, 0, VMPA_NO_VIRTUAL);
-
-    status = g_binary_content_read_raw(content, &addr, 4, (bin_t *)magic);
-
-    status &= (memcmp(magic, "\x7f\x45\x4c\x46" /* .ELF */, 4) == 0);
-
-    if (status)
-    {
-        result = FMS_MATCHED;
-        *key = strdup("elf");
-    }
-    else
-        result = FMS_UNKNOWN;
-
-    return result;
-
-}
-
-
-/* Indique le type défini pour un format d'exécutable ELF. */
-G_DEFINE_TYPE(GElfFormat, g_elf_format, G_TYPE_EXE_FORMAT);
-
-
-/******************************************************************************
-*                                                                             *
-*  Paramètres  : klass = classe à initialiser.                                *
-*                                                                             *
-*  Description : Initialise la classe des formats d'exécutables ELF.          *
-*                                                                             *
-*  Retour      : -                                                            *
-*                                                                             *
-*  Remarques   : -                                                            *
-*                                                                             *
-******************************************************************************/
-
-static void g_elf_format_class_init(GElfFormatClass *klass)
-{
-    GObjectClass *object;                   /* Autre version de la classe  */
-    GBinFormatClass *fmt;                   /* Version en format basique   */
-    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;
-
-    fmt = G_BIN_FORMAT_CLASS(klass);
-
-    fmt->get_endian = (format_get_endian_fc)g_elf_format_get_endianness;
-
-    exe = G_EXE_FORMAT_CLASS(klass);
-
-    exe->get_machine = (get_target_machine_fc)g_elf_format_get_target_machine;
-    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->get_range_by_name = (get_range_by_name_fc)g_elf_format_get_section_range_by_name;
-
-}
-
-
-/******************************************************************************
-*                                                                             *
-*  Paramètres  : format = instance à initialiser.                             *
-*                                                                             *
-*  Description : Initialise une instance de format d'exécutable ELF.          *
-*                                                                             *
-*  Retour      : -                                                            *
-*                                                                             *
-*  Remarques   : -                                                            *
-*                                                                             *
-******************************************************************************/
-
-static void g_elf_format_init(GElfFormat *format)
-{
-
-}
-
-
-/******************************************************************************
-*                                                                             *
-*  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));
-
-}
-
-
-/******************************************************************************
-*                                                                             *
-*  Paramètres  : content = contenu binaire à parcourir.                       *
-*                parent  = éventuel format exécutable déjà chargé.            *
-                 status  = barre de statut à tenir informée.                  *
-*                                                                             *
-*  Description : Prend en charge un nouveau format ELF.                       *
-*                                                                             *
-*  Retour      : Adresse de la structure mise en place ou NULL en cas d'échec.*
-*                                                                             *
-*  Remarques   : -                                                            *
-*                                                                             *
-******************************************************************************/
-
-GBinFormat *g_elf_format_new(GBinContent *content, GExeFormat *parent, GtkStatusStack *status)
-{
-    GElfFormat *result;                     /* Structure à retourner       */
-    GBinFormat *base;                       /* Version basique du format   */
-    GExeFormat *exe_format;                 /* Autre version du format     */
-
-    result = g_object_new(G_TYPE_ELF_FORMAT, NULL);
-
-    base = G_BIN_FORMAT(result);
-    exe_format = G_EXE_FORMAT(result);
-
-    g_binary_format_set_content(base, content);
-
-    if (!read_elf_header(result, &result->header, &result->is_32b, &result->endian))
-    {
-        /* TODO */
-        return NULL;
-    }
-
-
-    /* Vérification des tailles d'entrée de table */
-
-    if (ELF_HDR(result, result->header, e_phentsize) != ELF_SIZEOF_PHDR(result))
-    {
-        log_variadic_message(LMT_BAD_BINARY, _("Corrupted program header size (%hu); fixed!  --  replacing 0x%04hx by 0x%04hx at offset 0x%x"),
-                             ELF_HDR(result, result->header, e_phentsize),
-                             ELF_HDR(result, result->header, e_phentsize),
-                             ELF_SIZEOF_PHDR(result), ELF_HDR_OFFSET_OF(result, e_phentsize));
-        ELF_HDR_SET(result, result->header, e_phentsize, ELF_SIZEOF_PHDR(result));
-    }
-
-    if (ELF_HDR(result, result->header, e_shentsize) != ELF_SIZEOF_SHDR(result))
-    {
-        log_variadic_message(LMT_BAD_BINARY, _("Corrupted section header size (%hu); fixed!  --  replacing 0x%04hx by 0x%04hx at offset 0x%x"),
-                             ELF_HDR(result, result->header, e_shentsize),
-                             ELF_HDR(result, result->header, e_shentsize),
-                             ELF_SIZEOF_SHDR(result), ELF_HDR_OFFSET_OF(result, e_shentsize));
-        ELF_HDR_SET(result, result->header, e_shentsize, ELF_SIZEOF_SHDR(result));
-    }
-
-    /* FIXME : à améliorer */
-    /*
-    if ((ELF_HDR(result, result->header, e_shnum) * ELF_HDR(result, result->header, e_shentsize)) >= length)
-    {
-        log_variadic_message(LMT_BAD_BINARY, ("Suspicious section table (bigger than the binary !) ; reset!  --  replacing 0x%04hx by 0x%04hx at offset 0x%x"),
-                             ELF_HDR(result, result->header, e_shnum),
-                             0, ELF_HDR_OFFSET_OF(result, e_shnum));
-        ELF_HDR_SET(result, result->header, e_shnum, 0);
-    }
-    */
-
-
-
-    /**
-     * On inscrit les éléments préchargés avant tout !
-     *
-     * Cela permet de partir d'une base vide, et d'ajouter les instructions et
-     * leurs commentaires par paires.
-     *
-     * Ensuite, on inscrit le reste (comme les chaînes de caractères).
-     */
-
-    preload_binary_format(PGA_FORMAT_PRELOAD, base, base->info, status);
-
-
-    if (!load_elf_symbols(result, status))
-    {
-        /* TODO */
-        return NULL;
-    }
-
-
-    if (!find_all_elf_strings(result))
-    {
-        /* TODO */
-        return NULL;
-    }
-
-
-    if (!g_executable_format_complete_loading(exe_format, status))
-        goto gefn_error;
-
-    return base;
-
- gefn_error:
-
-    g_object_unref(G_OBJECT(result));
-
-    return NULL;
-
-}
-
-
-/******************************************************************************
-*                                                                             *
-*  Paramètres  : format = informations chargées à consulter.                  *
-*                                                                             *
-*  Description : Informe quant au boutisme utilisé.                           *
-*                                                                             *
-*  Retour      : Indicateur de boutisme.                                      *
-*                                                                             *
-*  Remarques   : -                                                            *
-*                                                                             *
-******************************************************************************/
-
-static SourceEndian g_elf_format_get_endianness(const GElfFormat *format)
-{
-    return format->endian;
-
-}
-
-
-/******************************************************************************
-*                                                                             *
-*  Paramètres  : format = informations chargées à consulter.                  *
-*                                                                             *
-*  Description : Indique le type d'architecture visée par le format.          *
-*                                                                             *
-*  Retour      : Identifiant de l'architecture ciblée par le format.          *
-*                                                                             *
-*  Remarques   : -                                                            *
-*                                                                             *
-******************************************************************************/
-
-static const char *g_elf_format_get_target_machine(const GElfFormat *format)
-{
-    const char *result;                     /* Identifiant à retourner     */
-
-    switch (ELF_HDR(format, format->header, e_machine))
-    {
-        case EM_386:
-            result = "i386";
-            break;
-
-        case EM_MIPS:
-            result = "mips";
-            break;
-
-        case EM_ARM:
-            result = "armv7";
-            break;
-
-        case EM_NONE:
-        default:
-            result = NULL;
-            break;
-
-    }
-
-    return result;
-
-}
-
-
-/******************************************************************************
-*                                                                             *
-*  Paramètres  : format = description de l'exécutable à consulter.            *
-*                addr   = adresse principale trouvée si possible. [OUT]       *
-*                                                                             *
-*  Description : Fournit l'adresse principale associée à un format Elf.       *
-*                                                                             *
-*  Retour      : Bilan des recherches.                                        *
-*                                                                             *
-*  Remarques   : -                                                            *
-*                                                                             *
-******************************************************************************/
-
-static bool g_elf_format_get_main_address(GElfFormat *format, vmpa2t *addr)
-{
-    bool result;                            /* Bilan à retourner           */
-    GBinSymbol *symbol;                     /* Point d'entrée trouvé       */
-    GBinFormat *base;                       /* Version d'instance parente  */
-    const mrange_t *range;                  /* Emplacement de ce point     */
-
-    result = false;
-    symbol = NULL;
-
-    base = G_BIN_FORMAT(format);
-
-    if (g_binary_format_find_symbol_by_label(base, "main", &symbol))
-        goto done;
-
-    if (g_binary_format_find_symbol_by_label(base, "_start", &symbol))
-        goto done;
-
-    if (g_binary_format_find_symbol_by_label(base, "entry_point", &symbol))
-        goto done;
-
- done:
-
-    if (symbol != NULL)
-    {
-        result = true;
-
-        range = g_binary_symbol_get_range(symbol);
-
-        copy_vmpa(addr, get_mrange_addr(range));
-
-    }
-
-    return result;
-
-}
-
-
-/******************************************************************************
-*                                                                             *
-*  Paramètres  : format = informations chargées à consulter.                  *
-*                                                                             *
-*  Description : Etend la définition des portions au sein d'un binaire.       *
-*                                                                             *
-*  Retour      : -                                                            *
-*                                                                             *
-*  Remarques   : -                                                            *
-*                                                                             *
-******************************************************************************/
-
-static void g_elf_format_refine_portions(GElfFormat *format)
-{
-    GExeFormat *exe_format;                 /* Autre version du format     */
-    uint16_t max;                           /* Décompte d'éléments traités */
-    uint16_t i;                             /* Boucle de parcours          */
-    off_t offset;                           /* Début de part de programme  */
-    vmpa2t origin;                          /* Origine d'une définition    */
-    elf_phdr phdr;                          /* En-tête de programme ELF    */
-    uint32_t p_flags;                       /* Droits associés à une partie*/
-    const char *background;                 /* Fond signigicatif           */
-    GBinPortion *new;                       /* Nouvelle portion définie    */
-    char desc[MAX_PORTION_DESC];            /* Description d'une portion   */
-    vmpa2t addr;                            /* Emplacement dans le binaire */
-    PortionAccessRights rights;             /* Droits d'une portion        */
-    elf_shdr strings;                       /* Section des descriptions    */
-    bool has_strings;                       /* Section trouvée ?           */
-    elf_shdr shdr;                          /* En-tête de section ELF      */
-    uint64_t sh_flags;                      /* Droits associés à une partie*/
-    mrange_t range;                         /* Emplacement d'une section   */
-    const char *name;                       /* Nom trouvé ou NULL          */
-
-    exe_format = G_EXE_FORMAT(format);
-
-    /**
-     * La copie des différents en-têtes cherche à reproduire l'inclusion native
-     * du format :
-     *
-     *  EXIDX          0x001178 0x00009178 0x00009178 0x00008 0x00008 R   0x4
-     *  PHDR           0x000034 0x00008034 0x00008034 0x00120 0x00120 R E 0x4
-     *  INTERP         0x000154 0x00008154 0x00008154 0x00019 0x00019 R   0x1
-     *  LOAD           0x000000 0x00008000 0x00008000 0x01184 0x01184 R E 0x8000
-     *
-     */
-
-    /**
-     * Côté segments basiques.
-     */
-
-    max = ELF_HDR(format, format->header, e_phnum);
-
-    for (i = 0; i < max; i++)
-    {
-        offset = ELF_HDR(format, format->header, e_phoff)
-            + ELF_HDR(format, format->header, e_phentsize) * i;
-
-        init_vmpa(&origin, offset, VMPA_NO_VIRTUAL);
-
-        if (!read_elf_program_header(format, offset, &phdr))
-            continue;
-
-        if (ELF_PHDR(format, phdr, p_type) == PT_NULL)
-            continue;
-
-        p_flags = ELF_PHDR(format, phdr, p_flags);
-
-        if (p_flags & PF_X) background = BPC_CODE;
-        else if (p_flags & PF_W) background = BPC_DATA;
-        else background = BPC_DATA_RO;
-
-        init_vmpa(&addr, ELF_PHDR(format, phdr, p_offset), ELF_PHDR(format, phdr, p_vaddr));
-
-        new = g_binary_portion_new(background, &addr, ELF_PHDR(format, phdr, p_filesz));
-
-        snprintf(desc, MAX_PORTION_DESC, "%s \"%s\"",
-                 _("Segment"),
-                 get_elf_program_type_desc(format, ELF_PHDR(format, phdr, p_type)));
-
-        g_binary_portion_set_desc(new, desc);
-
-        rights = PAC_NONE;
-        if (p_flags & PF_R) rights |= PAC_READ;
-        if (p_flags & PF_W) rights |= PAC_WRITE;
-        if (p_flags & PF_X) rights |= PAC_EXEC;
-
-        g_binary_portion_set_rights(new, rights);
-
-        g_exe_format_include_portion(exe_format, new, &origin);
-
-    }
-
-    /**
-     * Inclusion des sections, si possible...
-     */
-
-    has_strings = find_elf_section_by_index(format,
-                                            ELF_HDR(format, format->header, e_shstrndx),
-                                            &strings);
-
-    max = ELF_HDR(format, format->header, e_shnum);
-
-    for (i = 0; i < max; i++)
-    {
-        if (!find_elf_section_by_index(format, i, &shdr))
-            continue;
-
-        if (ELF_SHDR(format, shdr, sh_offset) == 0)
-            continue;
-
-        sh_flags = ELF_SHDR(format, shdr, sh_flags);
-
-        if (sh_flags & SHF_EXECINSTR) background = BPC_CODE;
-        else if (sh_flags & SHF_WRITE) background = BPC_DATA;
-        else background = BPC_DATA_RO;
-
-        get_elf_section_range(format, &shdr, &range);
-
-        new = g_binary_portion_new(background, get_mrange_addr(&range), get_mrange_length(&range));
-
-        if (has_strings)
-            name = extract_name_from_elf_string_section(format, &strings,
-                                                        ELF_SHDR(format, shdr, sh_name));
-        else name = NULL;
-
-        if (name != NULL)
-            sprintf(desc, "%s \"%s\"", _("Section"), name);
-        else
-            sprintf(desc, "%s ???", _("Section"));
-
-        g_binary_portion_set_desc(new, desc);
-
-        rights = PAC_NONE;
-        if (sh_flags & SHF_ALLOC) rights |= PAC_READ;
-        if (sh_flags & SHF_WRITE) rights |= PAC_WRITE;
-        if (sh_flags & SHF_EXECINSTR) rights |= PAC_EXEC;
-
-        g_binary_portion_set_rights(new, rights);
-
-        offset = ELF_HDR(format, format->header, e_shoff)
-            + ELF_HDR(format, format->header, e_shentsize) * i;
-
-        init_vmpa(&origin, offset, VMPA_NO_VIRTUAL);
-
-        g_exe_format_include_portion(exe_format, new, &origin);
-
-    }
-
-}
-
-
-/******************************************************************************
-*                                                                             *
-*  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]          *
-*                                                                             *
-*  Description : Fournit l'emplacement d'une section donnée.                  *
-*                                                                             *
-*  Retour      : Bilan de l'opération.                                        *
-*                                                                             *
-*  Remarques   : -                                                            *
-*                                                                             *
-******************************************************************************/
-
-static bool g_elf_format_get_section_range_by_name(const GElfFormat *format, const char *name, mrange_t *range)
-{
-    bool result;                            /* Bilan à retourner           */
-    phys_t offset;                          /* Position physique de section*/
-    phys_t size;                            /* Taille de la section trouvée*/
-    virt_t address;                         /* Adresse virtuelle de section*/
-    vmpa2t tmp;                             /* Adresse à initialiser       */
-
-    result = find_elf_section_content_by_name(format, name, &offset, &size, &address);
-
-    if (result)
-    {
-        init_vmpa(&tmp, offset, address);
-        init_mrange(range, &tmp, size);
-    }
-
-    return result;
-
-}
-
-
-/******************************************************************************
-*                                                                             *
-*  Paramètres  : format = informations chargées à consulter.                  *
-*                                                                             *
-*  Description : Présente l'en-tête ELF du format chargé.                     *
-*                                                                             *
-*  Retour      : Pointeur vers la description principale.                     *
-*                                                                             *
-*  Remarques   : -                                                            *
-*                                                                             *
-******************************************************************************/
-
-const elf_header *g_elf_format_get_header(const GElfFormat *format)
-{
-    return &format->header;
-
-}
diff --git a/plugins/elf/elf.h b/plugins/elf/elf.h
deleted file mode 100644
index 7e1895b..0000000
--- a/plugins/elf/elf.h
+++ /dev/null
@@ -1,68 +0,0 @@
-
-/* Chrysalide - Outil d'analyse de fichiers binaires
- * elf.h - prototypes pour le support du format ELF
- *
- * Copyright (C) 2009-2017 Cyrille Bagard
- *
- *  This file is part of Chrysalide.
- *
- *  Chrysalide is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  Chrysalide is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#ifndef _FORMAT_ELF_ELF_H
-#define _FORMAT_ELF_ELF_H
-
-
-#include <glib-object.h>
-#include <stdbool.h>
-#include <sys/types.h>
-
-
-#include <core/formats.h>
-
-
-#include "elf_def.h"
-
-
-
-#define G_TYPE_ELF_FORMAT               g_elf_format_get_type()
-#define G_ELF_FORMAT(obj)               (G_TYPE_CHECK_INSTANCE_CAST((obj), g_elf_format_get_type(), GElfFormat))
-#define G_IS_ELF_FORMAT(obj)            (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_elf_format_get_type()))
-#define G_ELF_FORMAT_GET_IFACE(inst)    (G_TYPE_INSTANCE_GET_INTERFACE((inst), g_elf_format_get_type(), GElfFormatIface))
-#define G_ELF_FORMAT_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ELF_FORMAT, GElfFormatClass))
-
-
-/* Format d'exécutable ELF (instance) */
-typedef struct _GElfFormat GElfFormat;
-
-/* Format d'exécutable ELF (classe) */
-typedef struct _GElfFormatClass GElfFormatClass;
-
-
-/* Indique si le format peut être pris en charge ici. */
-FormatMatchStatus elf_is_matching(GBinContent *, GExeFormat *, void *, char **);
-
-/* Indique le type défini pour un format d'exécutable ELF. */
-GType g_elf_format_get_type(void);
-
-/* Prend en charge un nouveau format ELF. */
-GBinFormat *g_elf_format_new(GBinContent *, GExeFormat *, GtkStatusStack *);
-
-/* Présente l'en-tête ELF du format chargé. */
-const elf_header *g_elf_format_get_header(const GElfFormat *);
-
-
-
-#endif  /* _FORMAT_ELF_ELF_H */
diff --git a/plugins/elf/elf_def.h b/plugins/elf/elf_def.h
index 0d91e00..5ab915a 100644
--- a/plugins/elf/elf_def.h
+++ b/plugins/elf/elf_def.h
@@ -21,8 +21,8 @@
  */
 
 
-#ifndef _FORMAT_ELF_ELF_DEF_H
-#define _FORMAT_ELF_ELF_DEF_H
+#ifndef _PLUGINS_ELF_ELF_DEF_H
+#define _PLUGINS_ELF_ELF_DEF_H
 
 
 #include <stdint.h>
@@ -427,9 +427,6 @@ typedef union _elf_shdr
                                            referenced or allocated (Solaris).*/
 
 
-
-
-
 /* ----------------------------- DONNEES POUR LE LINKER ----------------------------- */
 
 
@@ -631,4 +628,4 @@ typedef struct _elf_note
 
 
 
-#endif  /* _FORMAT_ELF_ELF_DEF_H */
+#endif  /* _PLUGINS_ELF_ELF_DEF_H */
diff --git a/plugins/elf/elf_def_arm.h b/plugins/elf/elf_def_arm.h
index 5b0191e..2b0f3d7 100644
--- a/plugins/elf/elf_def_arm.h
+++ b/plugins/elf/elf_def_arm.h
@@ -21,8 +21,8 @@
  */
 
 
-#ifndef _FORMAT_ELF_ELF_DEF_ARM_H
-#define _FORMAT_ELF_ELF_DEF_ARM_H
+#ifndef _PLUGINS_ELF_ELF_DEF_ARM_H
+#define _PLUGINS_ELF_ELF_DEF_ARM_H
 
 
 #include "elf_def.h"
@@ -42,4 +42,4 @@
 
 
 
-#endif  /* _FORMAT_ELF_ELF_DEF_ARM_H */
+#endif  /* _PLUGINS_ELF_ELF_DEF_ARM_H */
diff --git a/plugins/elf/format.c b/plugins/elf/format.c
new file mode 100644
index 0000000..c12460a
--- /dev/null
+++ b/plugins/elf/format.c
@@ -0,0 +1,707 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * format.c - support du format ELF
+ *
+ * Copyright (C) 2009-2017 Cyrille Bagard
+ *
+ *  This file is part of Chrysalide.
+ *
+ *  Chrysalide is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  Chrysalide is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "format.h"
+
+
+#include <malloc.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <string.h>
+
+
+#include <i18n.h>
+#include <gui/panels/log.h>
+#include <plugins/pglist.h>
+
+
+#include "elf-int.h"
+#include "program.h"
+#include "section.h"
+#include "strings.h"
+#include "symbols.h"
+
+
+
+/* Taille maximale d'une description */
+#define MAX_PORTION_DESC 256
+
+
+/* Initialise la classe des formats d'exécutables ELF. */
+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 *);
+
+/* Informe quant au boutisme utilisé. */
+static SourceEndian g_elf_format_get_endianness(const GElfFormat *);
+
+/* Indique le type d'architecture visée par le format. */
+static const char *g_elf_format_get_target_machine(const GElfFormat *);
+
+/* Fournit l'adresse principale associée à un format Elf. */
+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 *);
+
+
+
+/******************************************************************************
+*                                                                             *
+*  Paramètres  : content = contenu binaire à parcourir.                       *
+*                parent  = éventuel format exécutable déjà chargé.            *
+*                unused  = adresse non utilisée ici.                          *
+*                key     = identifiant de format trouvé ou NULL. [OUT]        *
+*                                                                             *
+*  Description : Indique si le format peut être pris en charge ici.           *
+*                                                                             *
+*  Retour      : Conclusion de haut niveau sur la reconnaissance effectuée.   *
+*                                                                             *
+*  Remarques   : -                                                            *
+*                                                                             *
+******************************************************************************/
+
+FormatMatchStatus elf_is_matching(GBinContent *content, GExeFormat *parent, void *unused, char **key)
+{
+    FormatMatchStatus result;               /* Bilan à renvoyer            */
+    vmpa2t addr;                            /* Tête de lecture initiale    */
+    bool status;                            /* Bilan des accès mémoire     */
+    char magic[4];                          /* Idenfiant standard          */
+
+    if (parent != NULL)
+        return FMS_UNKNOWN;
+
+    init_vmpa(&addr, 0, VMPA_NO_VIRTUAL);
+
+    status = g_binary_content_read_raw(content, &addr, 4, (bin_t *)magic);
+
+    status &= (memcmp(magic, "\x7f\x45\x4c\x46" /* .ELF */, 4) == 0);
+
+    if (status)
+    {
+        result = FMS_MATCHED;
+        *key = strdup("elf");
+    }
+    else
+        result = FMS_UNKNOWN;
+
+    return result;
+
+}
+
+
+/* Indique le type défini pour un format d'exécutable ELF. */
+G_DEFINE_TYPE(GElfFormat, g_elf_format, G_TYPE_EXE_FORMAT);
+
+
+/******************************************************************************
+*                                                                             *
+*  Paramètres  : klass = classe à initialiser.                                *
+*                                                                             *
+*  Description : Initialise la classe des formats d'exécutables ELF.          *
+*                                                                             *
+*  Retour      : -                                                            *
+*                                                                             *
+*  Remarques   : -                                                            *
+*                                                                             *
+******************************************************************************/
+
+static void g_elf_format_class_init(GElfFormatClass *klass)
+{
+    GObjectClass *object;                   /* Autre version de la classe  */
+    GBinFormatClass *fmt;                   /* Version en format basique   */
+    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;
+
+    fmt = G_BIN_FORMAT_CLASS(klass);
+
+    fmt->get_endian = (format_get_endian_fc)g_elf_format_get_endianness;
+
+    exe = G_EXE_FORMAT_CLASS(klass);
+
+    exe->get_machine = (get_target_machine_fc)g_elf_format_get_target_machine;
+    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->get_range_by_name = (get_range_by_name_fc)g_elf_format_get_section_range_by_name;
+
+}
+
+
+/******************************************************************************
+*                                                                             *
+*  Paramètres  : format = instance à initialiser.                             *
+*                                                                             *
+*  Description : Initialise une instance de format d'exécutable ELF.          *
+*                                                                             *
+*  Retour      : -                                                            *
+*                                                                             *
+*  Remarques   : -                                                            *
+*                                                                             *
+******************************************************************************/
+
+static void g_elf_format_init(GElfFormat *format)
+{
+
+}
+
+
+/******************************************************************************
+*                                                                             *
+*  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));
+
+}
+
+
+/******************************************************************************
+*                                                                             *
+*  Paramètres  : content = contenu binaire à parcourir.                       *
+*                parent  = éventuel format exécutable déjà chargé.            *
+                 status  = barre de statut à tenir informée.                  *
+*                                                                             *
+*  Description : Prend en charge un nouveau format ELF.                       *
+*                                                                             *
+*  Retour      : Adresse de la structure mise en place ou NULL en cas d'échec.*
+*                                                                             *
+*  Remarques   : -                                                            *
+*                                                                             *
+******************************************************************************/
+
+GBinFormat *g_elf_format_new(GBinContent *content, GExeFormat *parent, GtkStatusStack *status)
+{
+    GElfFormat *result;                     /* Structure à retourner       */
+    GBinFormat *base;                       /* Version basique du format   */
+    GExeFormat *exe_format;                 /* Autre version du format     */
+
+    result = g_object_new(G_TYPE_ELF_FORMAT, NULL);
+
+    base = G_BIN_FORMAT(result);
+    exe_format = G_EXE_FORMAT(result);
+
+    g_binary_format_set_content(base, content);
+
+    if (!read_elf_header(result, &result->header, &result->is_32b, &result->endian))
+    {
+        /* TODO */
+        return NULL;
+    }
+
+
+    /* Vérification des tailles d'entrée de table */
+
+    if (ELF_HDR(result, result->header, e_phentsize) != ELF_SIZEOF_PHDR(result))
+    {
+        log_variadic_message(LMT_BAD_BINARY, _("Corrupted program header size (%hu); fixed!  --  replacing 0x%04hx by 0x%04hx at offset 0x%x"),
+                             ELF_HDR(result, result->header, e_phentsize),
+                             ELF_HDR(result, result->header, e_phentsize),
+                             ELF_SIZEOF_PHDR(result), ELF_HDR_OFFSET_OF(result, e_phentsize));
+        ELF_HDR_SET(result, result->header, e_phentsize, ELF_SIZEOF_PHDR(result));
+    }
+
+    if (ELF_HDR(result, result->header, e_shentsize) != ELF_SIZEOF_SHDR(result))
+    {
+        log_variadic_message(LMT_BAD_BINARY, _("Corrupted section header size (%hu); fixed!  --  replacing 0x%04hx by 0x%04hx at offset 0x%x"),
+                             ELF_HDR(result, result->header, e_shentsize),
+                             ELF_HDR(result, result->header, e_shentsize),
+                             ELF_SIZEOF_SHDR(result), ELF_HDR_OFFSET_OF(result, e_shentsize));
+        ELF_HDR_SET(result, result->header, e_shentsize, ELF_SIZEOF_SHDR(result));
+    }
+
+    /* FIXME : à améliorer */
+    /*
+    if ((ELF_HDR(result, result->header, e_shnum) * ELF_HDR(result, result->header, e_shentsize)) >= length)
+    {
+        log_variadic_message(LMT_BAD_BINARY, ("Suspicious section table (bigger than the binary !) ; reset!  --  replacing 0x%04hx by 0x%04hx at offset 0x%x"),
+                             ELF_HDR(result, result->header, e_shnum),
+                             0, ELF_HDR_OFFSET_OF(result, e_shnum));
+        ELF_HDR_SET(result, result->header, e_shnum, 0);
+    }
+    */
+
+
+
+    /**
+     * On inscrit les éléments préchargés avant tout !
+     *
+     * Cela permet de partir d'une base vide, et d'ajouter les instructions et
+     * leurs commentaires par paires.
+     *
+     * Ensuite, on inscrit le reste (comme les chaînes de caractères).
+     */
+
+    preload_binary_format(PGA_FORMAT_PRELOAD, base, base->info, status);
+
+
+    if (!load_elf_symbols(result, status))
+    {
+        /* TODO */
+        return NULL;
+    }
+
+
+    if (!find_all_elf_strings(result))
+    {
+        /* TODO */
+        return NULL;
+    }
+
+
+    if (!g_executable_format_complete_loading(exe_format, status))
+        goto gefn_error;
+
+    return base;
+
+ gefn_error:
+
+    g_object_unref(G_OBJECT(result));
+
+    return NULL;
+
+}
+
+
+/******************************************************************************
+*                                                                             *
+*  Paramètres  : format = informations chargées à consulter.                  *
+*                                                                             *
+*  Description : Informe quant au boutisme utilisé.                           *
+*                                                                             *
+*  Retour      : Indicateur de boutisme.                                      *
+*                                                                             *
+*  Remarques   : -                                                            *
+*                                                                             *
+******************************************************************************/
+
+static SourceEndian g_elf_format_get_endianness(const GElfFormat *format)
+{
+    return format->endian;
+
+}
+
+
+/******************************************************************************
+*                                                                             *
+*  Paramètres  : format = informations chargées à consulter.                  *
+*                                                                             *
+*  Description : Indique le type d'architecture visée par le format.          *
+*                                                                             *
+*  Retour      : Identifiant de l'architecture ciblée par le format.          *
+*                                                                             *
+*  Remarques   : -                                                            *
+*                                                                             *
+******************************************************************************/
+
+static const char *g_elf_format_get_target_machine(const GElfFormat *format)
+{
+    const char *result;                     /* Identifiant à retourner     */
+
+    switch (ELF_HDR(format, format->header, e_machine))
+    {
+        case EM_386:
+            result = "i386";
+            break;
+
+        case EM_MIPS:
+            result = "mips";
+            break;
+
+        case EM_ARM:
+            result = "armv7";
+            break;
+
+        case EM_NONE:
+        default:
+            result = NULL;
+            break;
+
+    }
+
+    return result;
+
+}
+
+
+/******************************************************************************
+*                                                                             *
+*  Paramètres  : format = description de l'exécutable à consulter.            *
+*                addr   = adresse principale trouvée si possible. [OUT]       *
+*                                                                             *
+*  Description : Fournit l'adresse principale associée à un format Elf.       *
+*                                                                             *
+*  Retour      : Bilan des recherches.                                        *
+*                                                                             *
+*  Remarques   : -                                                            *
+*                                                                             *
+******************************************************************************/
+
+static bool g_elf_format_get_main_address(GElfFormat *format, vmpa2t *addr)
+{
+    bool result;                            /* Bilan à retourner           */
+    GBinSymbol *symbol;                     /* Point d'entrée trouvé       */
+    GBinFormat *base;                       /* Version d'instance parente  */
+    const mrange_t *range;                  /* Emplacement de ce point     */
+
+    result = false;
+    symbol = NULL;
+
+    base = G_BIN_FORMAT(format);
+
+    if (g_binary_format_find_symbol_by_label(base, "main", &symbol))
+        goto done;
+
+    if (g_binary_format_find_symbol_by_label(base, "_start", &symbol))
+        goto done;
+
+    if (g_binary_format_find_symbol_by_label(base, "entry_point", &symbol))
+        goto done;
+
+ done:
+
+    if (symbol != NULL)
+    {
+        result = true;
+
+        range = g_binary_symbol_get_range(symbol);
+
+        copy_vmpa(addr, get_mrange_addr(range));
+
+    }
+
+    return result;
+
+}
+
+
+/******************************************************************************
+*                                                                             *
+*  Paramètres  : format = informations chargées à consulter.                  *
+*                                                                             *
+*  Description : Etend la définition des portions au sein d'un binaire.       *
+*                                                                             *
+*  Retour      : -                                                            *
+*                                                                             *
+*  Remarques   : -                                                            *
+*                                                                             *
+******************************************************************************/
+
+static void g_elf_format_refine_portions(GElfFormat *format)
+{
+    GExeFormat *exe_format;                 /* Autre version du format     */
+    uint16_t max;                           /* Décompte d'éléments traités */
+    uint16_t i;                             /* Boucle de parcours          */
+    off_t offset;                           /* Début de part de programme  */
+    vmpa2t origin;                          /* Origine d'une définition    */
+    elf_phdr phdr;                          /* En-tête de programme ELF    */
+    uint32_t p_flags;                       /* Droits associés à une partie*/
+    const char *background;                 /* Fond signigicatif           */
+    GBinPortion *new;                       /* Nouvelle portion définie    */
+    char desc[MAX_PORTION_DESC];            /* Description d'une portion   */
+    vmpa2t addr;                            /* Emplacement dans le binaire */
+    PortionAccessRights rights;             /* Droits d'une portion        */
+    elf_shdr strings;                       /* Section des descriptions    */
+    bool has_strings;                       /* Section trouvée ?           */
+    elf_shdr shdr;                          /* En-tête de section ELF      */
+    uint64_t sh_flags;                      /* Droits associés à une partie*/
+    mrange_t range;                         /* Emplacement d'une section   */
+    const char *name;                       /* Nom trouvé ou NULL          */
+
+    exe_format = G_EXE_FORMAT(format);
+
+    /**
+     * La copie des différents en-têtes cherche à reproduire l'inclusion native
+     * du format :
+     *
+     *  EXIDX          0x001178 0x00009178 0x00009178 0x00008 0x00008 R   0x4
+     *  PHDR           0x000034 0x00008034 0x00008034 0x00120 0x00120 R E 0x4
+     *  INTERP         0x000154 0x00008154 0x00008154 0x00019 0x00019 R   0x1
+     *  LOAD           0x000000 0x00008000 0x00008000 0x01184 0x01184 R E 0x8000
+     *
+     */
+
+    /**
+     * Côté segments basiques.
+     */
+
+    max = ELF_HDR(format, format->header, e_phnum);
+
+    for (i = 0; i < max; i++)
+    {
+        offset = ELF_HDR(format, format->header, e_phoff)
+            + ELF_HDR(format, format->header, e_phentsize) * i;
+
+        init_vmpa(&origin, offset, VMPA_NO_VIRTUAL);
+
+        if (!read_elf_program_header(format, offset, &phdr))
+            continue;
+
+        if (ELF_PHDR(format, phdr, p_type) == PT_NULL)
+            continue;
+
+        p_flags = ELF_PHDR(format, phdr, p_flags);
+
+        if (p_flags & PF_X) background = BPC_CODE;
+        else if (p_flags & PF_W) background = BPC_DATA;
+        else background = BPC_DATA_RO;
+
+        init_vmpa(&addr, ELF_PHDR(format, phdr, p_offset), ELF_PHDR(format, phdr, p_vaddr));
+
+        new = g_binary_portion_new(background, &addr, ELF_PHDR(format, phdr, p_filesz));
+
+        snprintf(desc, MAX_PORTION_DESC, "%s \"%s\"",
+                 _("Segment"),
+                 get_elf_program_type_desc(format, ELF_PHDR(format, phdr, p_type)));
+
+        g_binary_portion_set_desc(new, desc);
+
+        rights = PAC_NONE;
+        if (p_flags & PF_R) rights |= PAC_READ;
+        if (p_flags & PF_W) rights |= PAC_WRITE;
+        if (p_flags & PF_X) rights |= PAC_EXEC;
+
+        g_binary_portion_set_rights(new, rights);
+
+        g_exe_format_include_portion(exe_format, new, &origin);
+
+    }
+
+    /**
+     * Inclusion des sections, si possible...
+     */
+
+    has_strings = find_elf_section_by_index(format,
+                                            ELF_HDR(format, format->header, e_shstrndx),
+                                            &strings);
+
+    max = ELF_HDR(format, format->header, e_shnum);
+
+    for (i = 0; i < max; i++)
+    {
+        if (!find_elf_section_by_index(format, i, &shdr))
+            continue;
+
+        if (ELF_SHDR(format, shdr, sh_offset) == 0)
+            continue;
+
+        sh_flags = ELF_SHDR(format, shdr, sh_flags);
+
+        if (sh_flags & SHF_EXECINSTR) background = BPC_CODE;
+        else if (sh_flags & SHF_WRITE) background = BPC_DATA;
+        else background = BPC_DATA_RO;
+
+        get_elf_section_range(format, &shdr, &range);
+
+        new = g_binary_portion_new(background, get_mrange_addr(&range), get_mrange_length(&range));
+
+        if (has_strings)
+            name = extract_name_from_elf_string_section(format, &strings,
+                                                        ELF_SHDR(format, shdr, sh_name));
+        else name = NULL;
+
+        if (name != NULL)
+            sprintf(desc, "%s \"%s\"", _("Section"), name);
+        else
+            sprintf(desc, "%s ???", _("Section"));
+
+        g_binary_portion_set_desc(new, desc);
+
+        rights = PAC_NONE;
+        if (sh_flags & SHF_ALLOC) rights |= PAC_READ;
+        if (sh_flags & SHF_WRITE) rights |= PAC_WRITE;
+        if (sh_flags & SHF_EXECINSTR) rights |= PAC_EXEC;
+
+        g_binary_portion_set_rights(new, rights);
+
+        offset = ELF_HDR(format, format->header, e_shoff)
+            + ELF_HDR(format, format->header, e_shentsize) * i;
+
+        init_vmpa(&origin, offset, VMPA_NO_VIRTUAL);
+
+        g_exe_format_include_portion(exe_format, new, &origin);
+
+    }
+
+}
+
+
+/******************************************************************************
+*                                                                             *
+*  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]          *
+*                                                                             *
+*  Description : Fournit l'emplacement d'une section donnée.                  *
+*                                                                             *
+*  Retour      : Bilan de l'opération.                                        *
+*                                                                             *
+*  Remarques   : -                                                            *
+*                                                                             *
+******************************************************************************/
+
+static bool g_elf_format_get_section_range_by_name(const GElfFormat *format, const char *name, mrange_t *range)
+{
+    bool result;                            /* Bilan à retourner           */
+    phys_t offset;                          /* Position physique de section*/
+    phys_t size;                            /* Taille de la section trouvée*/
+    virt_t address;                         /* Adresse virtuelle de section*/
+    vmpa2t tmp;                             /* Adresse à initialiser       */
+
+    result = find_elf_section_content_by_name(format, name, &offset, &size, &address);
+
+    if (result)
+    {
+        init_vmpa(&tmp, offset, address);
+        init_mrange(range, &tmp, size);
+    }
+
+    return result;
+
+}
+
+
+/******************************************************************************
+*                                                                             *
+*  Paramètres  : format = informations chargées à consulter.                  *
+*                                                                             *
+*  Description : Présente l'en-tête ELF du format chargé.                     *
+*                                                                             *
+*  Retour      : Pointeur vers la description principale.                     *
+*                                                                             *
+*  Remarques   : -                                                            *
+*                                                                             *
+******************************************************************************/
+
+const elf_header *g_elf_format_get_header(const GElfFormat *format)
+{
+    return &format->header;
+
+}
diff --git a/plugins/elf/format.h b/plugins/elf/format.h
new file mode 100644
index 0000000..5184219
--- /dev/null
+++ b/plugins/elf/format.h
@@ -0,0 +1,68 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * format.h - prototypes pour le support du format ELF
+ *
+ * Copyright (C) 2009-2017 Cyrille Bagard
+ *
+ *  This file is part of Chrysalide.
+ *
+ *  Chrysalide is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  Chrysalide is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _PLUGINS_ELF_FORMAT_H
+#define _PLUGINS_ELF_FORMAT_H
+
+
+#include <glib-object.h>
+#include <stdbool.h>
+#include <sys/types.h>
+
+
+#include <core/formats.h>
+
+
+#include "elf_def.h"
+
+
+
+#define G_TYPE_ELF_FORMAT               g_elf_format_get_type()
+#define G_ELF_FORMAT(obj)               (G_TYPE_CHECK_INSTANCE_CAST((obj), g_elf_format_get_type(), GElfFormat))
+#define G_IS_ELF_FORMAT(obj)            (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_elf_format_get_type()))
+#define G_ELF_FORMAT_GET_IFACE(inst)    (G_TYPE_INSTANCE_GET_INTERFACE((inst), g_elf_format_get_type(), GElfFormatIface))
+#define G_ELF_FORMAT_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ELF_FORMAT, GElfFormatClass))
+
+
+/* Format d'exécutable ELF (instance) */
+typedef struct _GElfFormat GElfFormat;
+
+/* Format d'exécutable ELF (classe) */
+typedef struct _GElfFormatClass GElfFormatClass;
+
+
+/* Indique si le format peut être pris en charge ici. */
+FormatMatchStatus elf_is_matching(GBinContent *, GExeFormat *, void *, char **);
+
+/* Indique le type défini pour un format d'exécutable ELF. */
+GType g_elf_format_get_type(void);
+
+/* Prend en charge un nouveau format ELF. */
+GBinFormat *g_elf_format_new(GBinContent *, GExeFormat *, GtkStatusStack *);
+
+/* Présente l'en-tête ELF du format chargé. */
+const elf_header *g_elf_format_get_header(const GElfFormat *);
+
+
+
+#endif  /* _PLUGINS_ELF_FORMAT_H */
diff --git a/plugins/elf/helper_arm.h b/plugins/elf/helper_arm.h
index e971ed6..d4be96c 100644
--- a/plugins/elf/helper_arm.h
+++ b/plugins/elf/helper_arm.h
@@ -21,8 +21,8 @@
  */
 
 
-#ifndef _FORMAT_ELF_HELPER_ARM_H
-#define _FORMAT_ELF_HELPER_ARM_H
+#ifndef _PLUGINS_ELF_HELPER_ARM_H
+#define _PLUGINS_ELF_HELPER_ARM_H
 
 
 #include "section.h"
@@ -37,4 +37,4 @@ bool load_elf_arm_relocated_symbols(GElfFormat *, const elf_shdr *, const elf_sh
 
 
 
-#endif  /* _FORMAT_ELF_HELPER_ARM_H */
+#endif  /* _PLUGINS_ELF_HELPER_ARM_H */
diff --git a/plugins/elf/loading.h b/plugins/elf/loading.h
index ff5d7bb..03ac184 100644
--- a/plugins/elf/loading.h
+++ b/plugins/elf/loading.h
@@ -21,22 +21,14 @@
  */
 
 
-#ifndef _FORMAT_ELF_LOADING_H
-#define _FORMAT_ELF_LOADING_H
+#ifndef _PLUGINS_ELF_LOADING_H
+#define _PLUGINS_ELF_LOADING_H
 
 
 #include <gtkext/gtkstatusstack.h>
 
 
-#include "elf.h"
-
-
-
-
-//#include "../routine.h"
-//#include "../../arch/processor.h"
-//#include "../../format/executable.h"
-//#include "../../gtkext/gtkstatusstack.h"
+#include "format.h"
 
 
 
@@ -70,4 +62,4 @@ void g_elf_loading_get_internal_info(GElfLoading *, const elf_shdr **, bool *, c
 
 
 
-#endif  /* _FORMAT_ELF_LOADING_H */
+#endif  /* _PLUGINS_ELF_LOADING_H */
diff --git a/plugins/elf/program.h b/plugins/elf/program.h
index bf05d2a..91de4ec 100644
--- a/plugins/elf/program.h
+++ b/plugins/elf/program.h
@@ -21,12 +21,12 @@
  */
 
 
-#ifndef _FORMAT_ELF_PROGRAM_H
-#define _FORMAT_ELF_PROGRAM_H
+#ifndef _PLUGINS_ELF_PROGRAM_H
+#define _PLUGINS_ELF_PROGRAM_H
 
 
-#include "elf.h"
 #include "elf_def.h"
+#include "format.h"
 
 
 
@@ -44,4 +44,4 @@ bool translate_address_into_vmpa_using_elf_programs(const GElfFormat *, virt_t,
 
 
 
-#endif  /* _FORMAT_ELF_PROGRAM_H */
+#endif  /* _PLUGINS_ELF_PROGRAM_H */
diff --git a/plugins/elf/python/Makefile.am b/plugins/elf/python/Makefile.am
index 4de3e3c..c39d170 100644
--- a/plugins/elf/python/Makefile.am
+++ b/plugins/elf/python/Makefile.am
@@ -2,7 +2,7 @@
 noinst_LTLIBRARIES = libelfpython.la
 
 libelfpython_la_SOURCES =				\
-	elf.h elf.c							\
+	format.h format.c					\
 	module.h module.c
 
 
@@ -10,6 +10,6 @@ libelfpython_la_LDFLAGS =
 
 
 AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) $(LIBPYTHON_CFLAGS) $(LIBPYGOBJECT_CFLAGS) \
-	-I../../../src -I../../..
+	-I$(top_srcdir)/src
 
 AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS)
diff --git a/plugins/elf/python/elf.c b/plugins/elf/python/elf.c
deleted file mode 100644
index 1f5ddb2..0000000
--- a/plugins/elf/python/elf.c
+++ /dev/null
@@ -1,198 +0,0 @@
-
-/* Chrysalide - Outil d'analyse de fichiers binaires
- * elf.c - équivalent Python du fichier "format/elf/elf.c"
- *
- * Copyright (C) 2013-2017 Cyrille Bagard
- *
- *  This file is part of Chrysalide.
- *
- *  Chrysalide is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  Chrysalide is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-
-#include "elf.h"
-
-
-#include <pygobject.h>
-
-
-#include <i18n.h>
-#include <format/executable.h>
-#include <analysis/content.h>
-#include <plugins/pychrysa/helpers.h>
-#include <plugins/pychrysa/analysis/content.h>
-#include <plugins/pychrysa/format/executable.h>
-
-
-#include "../elf.h"
-
-
-
-/* Crée un nouvel objet Python de type 'ElfFormat'. */
-static PyObject *py_elf_format_new(PyTypeObject *, PyObject *, PyObject *);
-
-
-
-/******************************************************************************
-*                                                                             *
-*  Paramètres  : type = type de l'objet à instancier.                         *
-*                args = arguments fournis à l'appel.                          *
-*                kwds = arguments de type key=val fournis.                    *
-*                                                                             *
-*  Description : Crée un nouvel objet Python de type 'ElfFormat'.             *
-*                                                                             *
-*  Retour      : Instance Python mise en place.                               *
-*                                                                             *
-*  Remarques   : -                                                            *
-*                                                                             *
-******************************************************************************/
-
-static PyObject *py_elf_format_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    PyObject *result;                       /* Instance à retourner        */
-    PyObject *content_obj;                  /* Objet pour le contenu       */
-    PyObject *parent_obj;                   /* Objet pour le parent        */
-    PyObject *status_obj;                   /* Objet pour la progression   */
-    int ret;                                /* Bilan de lecture des args.  */
-    GBinContent *content;                   /* Instance GLib du contenu    */
-    GExeFormat *parent;                     /* Instance GLib du parent     */
-    GtkStatusStack *status;                 /* Instance GTK de suivi       */
-    GBinFormat *format;                     /* Création GLib à transmettre */
-
-    ret = PyArg_ParseTuple(args, "O!OO", get_python_binary_content_type(), &content_obj, &parent_obj, &status_obj);
-    if (!ret) return NULL;
-
-    content = G_BIN_CONTENT(pygobject_get(content_obj));
-
-    if (parent_obj == Py_None)
-        parent = NULL;
-
-    else
-    {
-        ret = PyObject_IsInstance(parent_obj, (PyObject *)get_python_executable_format_type());
-        if (!ret)
-        {
-            PyErr_SetString(PyExc_TypeError, _("The second argument must be a container format or None."));
-            return NULL;
-        }
-
-        parent = G_EXE_FORMAT(pygobject_get(parent_obj));
-
-    }
-
-    if (status_obj == Py_None)
-        status = NULL;
-
-    else
-    {
-        ret = PyObject_IsInstance(status_obj, (PyObject *)get_python_binary_content_type());
-        if (!ret)
-        {
-            PyErr_SetString(PyExc_TypeError, _("The third argument must be a status bar object or None."));
-            return NULL;
-        }
-
-        status = GTK_STATUS_STACK(pygobject_get(status_obj));
-
-    }
-
-    format = g_elf_format_new(content, parent, status);
-    if (format == NULL)
-    {
-        PyErr_SetString(PyExc_RuntimeError, _("Unable to load the ELF format."));
-        return NULL;
-    }
-
-    result = pygobject_new(G_OBJECT(format));
-
-    g_object_unref(format);
-
-    return (PyObject *)result;
-
-}
-
-
-/******************************************************************************
-*                                                                             *
-*  Paramètres  : -                                                            *
-*                                                                             *
-*  Description : Fournit un accès à une définition de type à diffuser.        *
-*                                                                             *
-*  Retour      : Définition d'objet pour Python.                              *
-*                                                                             *
-*  Remarques   : -                                                            *
-*                                                                             *
-******************************************************************************/
-
-PyTypeObject *get_python_elf_format_type(void)
-{
-    static PyMethodDef py_elf_format_methods[] = {
-        { NULL }
-    };
-
-    static PyGetSetDef py_elf_format_getseters[] = {
-        { NULL }
-    };
-
-    static PyTypeObject py_elf_format_type = {
-
-        PyVarObject_HEAD_INIT(NULL, 0)
-
-        .tp_name        = "pychrysalide.format.elf.ElfFormat",
-        .tp_basicsize   = sizeof(PyGObject),
-
-        .tp_flags       = Py_TPFLAGS_DEFAULT,
-
-        .tp_doc         = "PyChrysalide Elf format",
-
-        .tp_methods     = py_elf_format_methods,
-        .tp_getset      = py_elf_format_getseters,
-        .tp_new         = (newfunc)py_elf_format_new
-
-    };
-
-    return &py_elf_format_type;
-
-}
-
-
-/******************************************************************************
-*                                                                             *
-*  Paramètres  : module = module dont la définition est à compléter.          *
-*                                                                             *
-*  Description : Prend en charge l'objet 'pychrysalide.format.elf.ElfFormat'. *
-*                                                                             *
-*  Retour      : Bilan de l'opération.                                        *
-*                                                                             *
-*  Remarques   : -                                                            *
-*                                                                             *
-******************************************************************************/
-
-bool register_python_elf_format(PyObject *module)
-{
-    PyTypeObject *py_elf_format_type;       /* Type Python 'ElfFormat'     */
-    PyObject *dict;                         /* Dictionnaire du module      */
-
-    py_elf_format_type = get_python_elf_format_type();
-
-    dict = PyModule_GetDict(module);
-
-    if (!register_class_for_pygobject(dict, G_TYPE_ELF_FORMAT,
-                                      py_elf_format_type, get_python_executable_format_type()))
-        return false;
-
-    return true;
-
-}
diff --git a/plugins/elf/python/elf.h b/plugins/elf/python/elf.h
deleted file mode 100644
index cf6a706..0000000
--- a/plugins/elf/python/elf.h
+++ /dev/null
@@ -1,42 +0,0 @@
-
-/* Chrysalide - Outil d'analyse de fichiers binaires
- * elf.h - prototypes pour l'équivalent Python du fichier "format/elf/elf.h"
- *
- * Copyright (C) 2013-2017 Cyrille Bagard
- *
- *  This file is part of Chrysalide.
- *
- *  Chrysalide is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  Chrysalide is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-
-#ifndef _PLUGINS_PYCHRYSA_FORMAT_ELF_ELF_H
-#define _PLUGINS_PYCHRYSA_FORMAT_ELF_ELF_H
-
-
-#include <Python.h>
-#include <stdbool.h>
-
-
-
-/* Fournit un accès à une définition de type à diffuser. */
-PyTypeObject *get_python_elf_format_type(void);
-
-/* Prend en charge l'objet 'pychrysalide.format.elf.ElfFormat'. */
-bool register_python_elf_format(PyObject *);
-
-
-
-#endif  /* _PLUGINS_PYCHRYSA_FORMAT_ELF_ELF_H */
diff --git a/plugins/elf/python/format.c b/plugins/elf/python/format.c
new file mode 100644
index 0000000..84aa68c
--- /dev/null
+++ b/plugins/elf/python/format.c
@@ -0,0 +1,198 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * format.c - équivalent Python du fichier "plugins/elf/format.c"
+ *
+ * Copyright (C) 2013-2017 Cyrille Bagard
+ *
+ *  This file is part of Chrysalide.
+ *
+ *  Chrysalide is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  Chrysalide is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+
+#include "format.h"
+
+
+#include <pygobject.h>
+
+
+#include <i18n.h>
+#include <format/executable.h>
+#include <analysis/content.h>
+#include <plugins/pychrysa/helpers.h>
+#include <plugins/pychrysa/analysis/content.h>
+#include <plugins/pychrysa/format/executable.h>
+
+
+#include "../format.h"
+
+
+
+/* Crée un nouvel objet Python de type 'ElfFormat'. */
+static PyObject *py_elf_format_new(PyTypeObject *, PyObject *, PyObject *);
+
+
+
+/******************************************************************************
+*                                                                             *
+*  Paramètres  : type = type de l'objet à instancier.                         *
+*                args = arguments fournis à l'appel.                          *
+*                kwds = arguments de type key=val fournis.                    *
+*                                                                             *
+*  Description : Crée un nouvel objet Python de type 'ElfFormat'.             *
+*                                                                             *
+*  Retour      : Instance Python mise en place.                               *
+*                                                                             *
+*  Remarques   : -                                                            *
+*                                                                             *
+******************************************************************************/
+
+static PyObject *py_elf_format_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+    PyObject *result;                       /* Instance à retourner        */
+    PyObject *content_obj;                  /* Objet pour le contenu       */
+    PyObject *parent_obj;                   /* Objet pour le parent        */
+    PyObject *status_obj;                   /* Objet pour la progression   */
+    int ret;                                /* Bilan de lecture des args.  */
+    GBinContent *content;                   /* Instance GLib du contenu    */
+    GExeFormat *parent;                     /* Instance GLib du parent     */
+    GtkStatusStack *status;                 /* Instance GTK de suivi       */
+    GBinFormat *format;                     /* Création GLib à transmettre */
+
+    ret = PyArg_ParseTuple(args, "O!OO", get_python_binary_content_type(), &content_obj, &parent_obj, &status_obj);
+    if (!ret) return NULL;
+
+    content = G_BIN_CONTENT(pygobject_get(content_obj));
+
+    if (parent_obj == Py_None)
+        parent = NULL;
+
+    else
+    {
+        ret = PyObject_IsInstance(parent_obj, (PyObject *)get_python_executable_format_type());
+        if (!ret)
+        {
+            PyErr_SetString(PyExc_TypeError, _("The second argument must be a container format or None."));
+            return NULL;
+        }
+
+        parent = G_EXE_FORMAT(pygobject_get(parent_obj));
+
+    }
+
+    if (status_obj == Py_None)
+        status = NULL;
+
+    else
+    {
+        ret = PyObject_IsInstance(status_obj, (PyObject *)get_python_binary_content_type());
+        if (!ret)
+        {
+            PyErr_SetString(PyExc_TypeError, _("The third argument must be a status bar object or None."));
+            return NULL;
+        }
+
+        status = GTK_STATUS_STACK(pygobject_get(status_obj));
+
+    }
+
+    format = g_elf_format_new(content, parent, status);
+    if (format == NULL)
+    {
+        PyErr_SetString(PyExc_RuntimeError, _("Unable to load the ELF format."));
+        return NULL;
+    }
+
+    result = pygobject_new(G_OBJECT(format));
+
+    g_object_unref(format);
+
+    return (PyObject *)result;
+
+}
+
+
+/******************************************************************************
+*                                                                             *
+*  Paramètres  : -                                                            *
+*                                                                             *
+*  Description : Fournit un accès à une définition de type à diffuser.        *
+*                                                                             *
+*  Retour      : Définition d'objet pour Python.                              *
+*                                                                             *
+*  Remarques   : -                                                            *
+*                                                                             *
+******************************************************************************/
+
+PyTypeObject *get_python_elf_format_type(void)
+{
+    static PyMethodDef py_elf_format_methods[] = {
+        { NULL }
+    };
+
+    static PyGetSetDef py_elf_format_getseters[] = {
+        { NULL }
+    };
+
+    static PyTypeObject py_elf_format_type = {
+
+        PyVarObject_HEAD_INIT(NULL, 0)
+
+        .tp_name        = "pychrysalide.format.elf.ElfFormat",
+        .tp_basicsize   = sizeof(PyGObject),
+
+        .tp_flags       = Py_TPFLAGS_DEFAULT,
+
+        .tp_doc         = "PyChrysalide Elf format",
+
+        .tp_methods     = py_elf_format_methods,
+        .tp_getset      = py_elf_format_getseters,
+        .tp_new         = (newfunc)py_elf_format_new
+
+    };
+
+    return &py_elf_format_type;
+
+}
+
+
+/******************************************************************************
+*                                                                             *
+*  Paramètres  : module = module dont la définition est à compléter.          *
+*                                                                             *
+*  Description : Prend en charge l'objet 'pychrysalide.format.elf.ElfFormat'. *
+*                                                                             *
+*  Retour      : Bilan de l'opération.                                        *
+*                                                                             *
+*  Remarques   : -                                                            *
+*                                                                             *
+******************************************************************************/
+
+bool register_python_elf_format(PyObject *module)
+{
+    PyTypeObject *py_elf_format_type;       /* Type Python 'ElfFormat'     */
+    PyObject *dict;                         /* Dictionnaire du module      */
+
+    py_elf_format_type = get_python_elf_format_type();
+
+    dict = PyModule_GetDict(module);
+
+    if (!register_class_for_pygobject(dict, G_TYPE_ELF_FORMAT,
+                                      py_elf_format_type, get_python_executable_format_type()))
+        return false;
+
+    return true;
+
+}
diff --git a/plugins/elf/python/format.h b/plugins/elf/python/format.h
new file mode 100644
index 0000000..10e7a13
--- /dev/null
+++ b/plugins/elf/python/format.h
@@ -0,0 +1,42 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * format.h - prototypes pour l'équivalent Python du fichier "plugins/elf/format.h"
+ *
+ * Copyright (C) 2013-2017 Cyrille Bagard
+ *
+ *  This file is part of Chrysalide.
+ *
+ *  Chrysalide is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  Chrysalide is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+
+#ifndef _PLUGINS_ELF_PYTHON_FORMAT_H
+#define _PLUGINS_ELF_PYTHON_FORMAT_H
+
+
+#include <Python.h>
+#include <stdbool.h>
+
+
+
+/* Fournit un accès à une définition de type à diffuser. */
+PyTypeObject *get_python_elf_format_type(void);
+
+/* Prend en charge l'objet 'pychrysalide.format.elf.ElfFormat'. */
+bool register_python_elf_format(PyObject *);
+
+
+
+#endif  /* _PLUGINS_ELF_PYTHON_FORMAT_H */
diff --git a/plugins/elf/python/module.c b/plugins/elf/python/module.c
index faf0458..72d6dfc 100644
--- a/plugins/elf/python/module.c
+++ b/plugins/elf/python/module.c
@@ -31,7 +31,7 @@
 #include <plugins/pychrysa/access.h>
 
 
-#include "elf.h"
+#include "format.h"
 
 
 
diff --git a/plugins/elf/section.h b/plugins/elf/section.h
index f3be0f4..4ee2695 100644
--- a/plugins/elf/section.h
+++ b/plugins/elf/section.h
@@ -21,12 +21,12 @@
  */
 
 
-#ifndef _FORMAT_ELF_SECTION_H
-#define _FORMAT_ELF_SECTION_H
+#ifndef _PLUGINS_ELF_SECTION_H
+#define _PLUGINS_ELF_SECTION_H
 
 
-#include "elf.h"
 #include "elf_def.h"
+#include "format.h"
 
 
 
@@ -65,4 +65,4 @@ bool translate_address_into_vmpa_using_elf_sections(const GElfFormat *, virt_t,
 
 
 
-#endif  /* _FORMAT_ELF_SECTION_H */
+#endif  /* _PLUGINS_ELF_SECTION_H */
diff --git a/plugins/elf/strings.h b/plugins/elf/strings.h
index bea52da..456bd0a 100644
--- a/plugins/elf/strings.h
+++ b/plugins/elf/strings.h
@@ -21,11 +21,11 @@
  */
 
 
-#ifndef _FORMAT_ELF_STRINGS_H
-#define _FORMAT_ELF_STRINGS_H
+#ifndef _PLUGINS_ELF_STRINGS_H
+#define _PLUGINS_ELF_STRINGS_H
 
 
-#include "elf.h"
+#include "format.h"
 
 
 
@@ -34,4 +34,4 @@ bool find_all_elf_strings(GElfFormat *);
 
 
 
-#endif  /* _FORMAT_ELF_STRINGS_H */
+#endif  /* _PLUGINS_ELF_STRINGS_H */
diff --git a/plugins/elf/symbols.h b/plugins/elf/symbols.h
index f0bfa0d..c5e150b 100644
--- a/plugins/elf/symbols.h
+++ b/plugins/elf/symbols.h
@@ -21,11 +21,11 @@
  */
 
 
-#ifndef _FORMAT_ELF_SYMBOLS_H
-#define _FORMAT_ELF_SYMBOLS_H
+#ifndef _PLUGINS_ELF_SYMBOLS_H
+#define _PLUGINS_ELF_SYMBOLS_H
 
 
-#include "elf.h"
+#include "format.h"
 
 
 #include <glibext/delayed.h>
@@ -50,4 +50,4 @@ const char *get_elf_symbol_name(GElfFormat *, const elf_shdr *, const elf_shdr *
 
 
 
-#endif  /* _FORMAT_ELF_SYMBOLS_H */
+#endif  /* _PLUGINS_ELF_SYMBOLS_H */
diff --git a/plugins/libcsem/semantic.c b/plugins/libcsem/semantic.c
index 8fdc549..efac9ad 100644
--- a/plugins/libcsem/semantic.c
+++ b/plugins/libcsem/semantic.c
@@ -24,7 +24,7 @@
 #include "semantic.h"
 
 
-#include <plugins/elf/elf.h>
+#include <plugins/elf/format.h>
 #include <plugins/plugin-def.h>
 
 
diff --git a/plugins/readelf/header.c b/plugins/readelf/header.c
index 8b124a4..71ce749 100644
--- a/plugins/readelf/header.c
+++ b/plugins/readelf/header.c
@@ -24,7 +24,7 @@
 #include "header.h"
 
 
-#include <plugins/elf/elf.h>
+#include <plugins/elf/format.h>
 #include <plugins/fmtp/parser.h>
 
 
diff --git a/plugins/readelf/program.h b/plugins/readelf/program.h
index 4c4cde4..14b814d 100644
--- a/plugins/readelf/program.h
+++ b/plugins/readelf/program.h
@@ -26,7 +26,7 @@
 
 
 #include <format/preload.h>
-#include <plugins/elf/elf.h>
+#include <plugins/elf/format.h>
 
 
 
diff --git a/plugins/readelf/reader.c b/plugins/readelf/reader.c
index 4d766da..1a9158e 100644
--- a/plugins/readelf/reader.c
+++ b/plugins/readelf/reader.c
@@ -24,7 +24,7 @@
 #include "reader.h"
 
 
-#include <plugins/elf/elf.h>
+#include <plugins/elf/format.h>
 #include <plugins/plugin-def.h>
 
 
diff --git a/plugins/readelf/section.h b/plugins/readelf/section.h
index 33be014..c50cd3a 100644
--- a/plugins/readelf/section.h
+++ b/plugins/readelf/section.h
@@ -26,7 +26,7 @@
 
 
 #include <format/preload.h>
-#include <plugins/elf/elf.h>
+#include <plugins/elf/format.h>
 
 
 
diff --git a/plugins/readelf/strtab.h b/plugins/readelf/strtab.h
index 9adcd46..e5a0a05 100644
--- a/plugins/readelf/strtab.h
+++ b/plugins/readelf/strtab.h
@@ -26,7 +26,7 @@
 
 
 #include <format/preload.h>
-#include <plugins/elf/elf.h>
+#include <plugins/elf/format.h>
 
 
 
-- 
cgit v0.11.2-87-g4458