summaryrefslogtreecommitdiff
path: root/src/format
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2009-09-15 21:18:14 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2009-09-15 21:18:14 (GMT)
commitff4fd84840beca40a88db2ca0ce90e6511fb852b (patch)
tree7b11e01c94565b3fc7771531d1b3283fb982c80d /src/format
parent1c4da24a1d4b96d58fee08e2be21198b22e7eef6 (diff)
Restored the code using the program headers when no section is found.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@115 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/format')
-rw-r--r--src/format/elf/elf.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/format/elf/elf.c b/src/format/elf/elf.c
index e2bf37a..34c7521 100644
--- a/src/format/elf/elf.c
+++ b/src/format/elf/elf.c
@@ -409,6 +409,8 @@ static GBinPart **g_elf_format_get_parts(const GElfFormat *format, size_t *count
uint16_t i; /* Boucle de parcours */
elf_shdr section; /* En-tête de section ELF */
GBinPart *part; /* Partie à intégrer à la liste*/
+ off_t offset; /* Début de part de programme */
+ elf_phdr phdr; /* En-tête de programme ELF */
result = NULL;
*count = 0;
@@ -439,6 +441,35 @@ static GBinPart **g_elf_format_get_parts(const GElfFormat *format, size_t *count
}
+ /* En désespoir de cause, on se rabbat sur les parties de programme directement */
+
+ if (*count == 0)
+ for (i = 0; i < format->header.e_phnum; i++)
+ {
+ offset = ELF_OFF(format, format->header.e_phoff) + format->header.e_phentsize * i;
+
+ if (!read_elf_program_header(format, &offset, &phdr))
+ continue;
+
+ if (ELF_PHDR(format, phdr, p_flags) & PF_X)
+ {
+ part = g_binary_part_new();
+
+ /* TODO : nom */
+
+ g_binary_part_set_values(part,
+ ELF_PHDR(format, phdr, p_offset),
+ ELF_PHDR(format, phdr, p_filesz),
+ ELF_PHDR(format, phdr, p_vaddr));
+
+ result = (GBinPart **)realloc(result, ++(*count) * sizeof(GBinPart *));
+ result[*count - 1] = part;
+
+ }
+
+ }
+
+
return result;
}