diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2008-10-29 20:14:05 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2008-10-29 20:14:05 (GMT) |
commit | 8a30afc05eed869865ba4dc9c107119f7ec00fe4 (patch) | |
tree | 18743934be1c2355c99788e49efb7a7a43e335f1 /src/format/elf/strings.c | |
parent | 2e5893f9261ba59e06fadcc6ddfa9a1253e286b3 (diff) |
Do not relied on section names anymore.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@39 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/format/elf/strings.c')
-rw-r--r-- | src/format/elf/strings.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/format/elf/strings.c b/src/format/elf/strings.c index 3d373a6..049f6d4 100644 --- a/src/format/elf/strings.c +++ b/src/format/elf/strings.c @@ -56,9 +56,38 @@ bool find_all_elf_strings(elf_format *format) off_t str_start; /* Début de section */ off_t str_size; /* Taille de section */ uint64_t str_vaddr; /* Adresse virtuelle associée */ + Elf_Shdr *sections; /* Groupe de sections trouvées */ + size_t count; /* Quantité de données */ + size_t i; /* Boucle de parcours */ + + /* Données en lecture seule */ + + if (find_elf_section_content_by_name(format, ".rodata", &str_start, &str_size, &str_vaddr)) + parse_elf_string_data(format, str_start, str_size, str_vaddr); + + else + { + find_elf_section_by_type(format, SHT_PROGBITS, §ions, &count); - if (find_elf_section(format, ".rodata", &str_start, &str_size, &str_vaddr)) + for (i = 0; i < count; i++) + if (ELF_SHDR(format, §ions[i], sh_flags) == SHF_ALLOC + || (ELF_SHDR(format, §ions[i], sh_flags) & SHF_STRINGS)) + { + get_elf_section_content(format, §ions[i], &str_start, &str_size, &str_vaddr); + parse_elf_string_data(format, str_start, str_size, str_vaddr); + } + + } + + /* Chaîne de caractères déclarées */ + + find_elf_section_by_type(format, SHT_STRTAB, §ions, &count); + + for (i = 0; i < count; i++) + { + get_elf_section_content(format, §ions[i], &str_start, &str_size, &str_vaddr); parse_elf_string_data(format, str_start, str_size, str_vaddr); + } return true; @@ -85,6 +114,8 @@ bool parse_elf_string_data(elf_format *format, const off_t start, const off_t si off_t i; /* Boucle de parcours */ off_t end; /* Position de fin de chaîne */ + if (vaddress == 0) return false; + for (i = start; i < (start + size); i++) if (isprint(EXE_FORMAT(format)->content[i])) { |