summaryrefslogtreecommitdiff
path: root/src/format/elf/elf.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2015-12-28 23:27:12 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2015-12-28 23:27:12 (GMT)
commitb57e8ef5522dcbe126157fc2c50fcf879aa7d743 (patch)
tree1ecfd9de39073fee3a2c1a4afa9ce5da574b26df /src/format/elf/elf.c
parent276b75e6e9ff99a930bd36045e55b1117bb29579 (diff)
Defined layers to register all kinds of binary portions.
Diffstat (limited to 'src/format/elf/elf.c')
-rw-r--r--src/format/elf/elf.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/format/elf/elf.c b/src/format/elf/elf.c
index 3dc5d64..3491c71 100644
--- a/src/format/elf/elf.c
+++ b/src/format/elf/elf.c
@@ -67,7 +67,7 @@ static void g_elf_format_finalize(GElfFormat *);
static const char *g_elf_format_get_target_machine(const GElfFormat *);
/* Etend la définition des portions au sein d'un binaire. */
-static void g_elf_format_refine_portions(const GElfFormat *, GBinPortion *);
+static void g_elf_format_refine_portions(const GElfFormat *, GPortionLayer *);
/* Fournit l'emplacement correspondant à une position physique. */
static bool g_elf_format_translate_offset_into_vmpa(const GElfFormat *, phys_t, vmpa2t *);
@@ -352,7 +352,7 @@ static const char *g_elf_format_get_target_machine(const GElfFormat *format)
/******************************************************************************
* *
* Paramètres : format = informations chargées à consulter. *
-* raw = portion de binaire brut à raffiner. *
+* main = couche de portions principale à raffiner. *
* *
* Description : Etend la définition des portions au sein d'un binaire. *
* *
@@ -362,8 +362,9 @@ static const char *g_elf_format_get_target_machine(const GElfFormat *format)
* *
******************************************************************************/
-static void g_elf_format_refine_portions(const GElfFormat *format, GBinPortion *raw)
+static void g_elf_format_refine_portions(const GElfFormat *format, GPortionLayer *main)
{
+ GPortionLayer *layer; /* Couche à mettre en place */
uint16_t i; /* Boucle de parcours */
off_t offset; /* Début de part de programme */
elf_phdr phdr; /* En-tête de programme ELF */
@@ -381,7 +382,10 @@ static void g_elf_format_refine_portions(const GElfFormat *format, GBinPortion *
/* Côté segments basiques */
-#if 0
+ layer = g_portion_layer_new(NO_LENGTH_YET, _("Segment"));
+
+ g_portion_layer_attach_sub(main, layer);
+
for (i = 0; i < ELF_HDR(format, format->header, e_phnum); i++)
{
offset = ELF_HDR(format, format->header, e_phoff)
@@ -414,10 +418,9 @@ static void g_elf_format_refine_portions(const GElfFormat *format, GBinPortion *
g_binary_portion_set_rights(new, rights);
- g_binary_portion_include(raw, new);
+ g_portion_layer_include(layer, new);
}
-#endif
/* Inclusion des sections, si possible... */
@@ -425,6 +428,10 @@ static void g_elf_format_refine_portions(const GElfFormat *format, GBinPortion *
ELF_HDR(format, format->header, e_shstrndx),
&strings);
+ layer = g_portion_layer_new(NO_LENGTH_YET, _("Section"));
+
+ g_portion_layer_attach_sub(main, layer);
+
for (i = 0; i < ELF_HDR(format, format->header, e_shnum); i++)
{
if (!find_elf_section_by_index(format, i, &section))
@@ -432,9 +439,6 @@ static void g_elf_format_refine_portions(const GElfFormat *format, GBinPortion *
sh_flags = ELF_SHDR(format, section, sh_flags);
- printf("[section % 2hu] 0x%08x -> %x -> %d\n", i, sh_flags,
- sh_flags & SHF_ALLOC, (sh_flags & SHF_ALLOC) == 0);
-
if ((sh_flags & SHF_ALLOC) == 0)
continue;
@@ -466,7 +470,7 @@ static void g_elf_format_refine_portions(const GElfFormat *format, GBinPortion *
g_binary_portion_set_rights(new, rights);
- g_binary_portion_include(raw, new);
+ g_portion_layer_include(layer, new);
}