From ff4fd84840beca40a88db2ca0ce90e6511fb852b Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Tue, 15 Sep 2009 21:18:14 +0000 Subject: 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 --- ChangeLog | 5 +++++ src/format/elf/elf.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/ChangeLog b/ChangeLog index 4dad565..4711c05 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +09-09-15 Cyrille Bagard + + * src/format/elf/elf.c: + Restore the code using the program headers when no section is found. + 09-09-14 Cyrille Bagard * 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; } -- cgit v0.11.2-87-g4458