summaryrefslogtreecommitdiff
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
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
-rw-r--r--ChangeLog5
-rw-r--r--src/format/elf/elf.c31
2 files changed, 36 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 4dad565..4711c05 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+09-09-15 Cyrille Bagard <nocbos@gmail.com>
+
+ * src/format/elf/elf.c:
+ Restore the code using the program headers when no section is found.
+
09-09-14 Cyrille Bagard <nocbos@gmail.com>
* configure.ac:
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;
}