diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2009-11-18 23:20:16 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2009-11-18 23:20:16 (GMT) |
commit | 783e5e1977c1e4dadf938befa9fce9a311079413 (patch) | |
tree | 995423e1069e31db4fe0517fb9a45432dafceb6d /src/format/elf | |
parent | 26d75963fba34d8e5a5b9a6186604110552f3a38 (diff) |
Saved the current work on binary parts selection.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@137 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/format/elf')
-rw-r--r-- | src/format/elf/elf.c | 15 | ||||
-rw-r--r-- | src/format/elf/section.c | 2 |
2 files changed, 16 insertions, 1 deletions
diff --git a/src/format/elf/elf.c b/src/format/elf/elf.c index 34c7521..f32bce7 100644 --- a/src/format/elf/elf.c +++ b/src/format/elf/elf.c @@ -407,14 +407,19 @@ static GBinPart **g_elf_format_get_parts(const GElfFormat *format, size_t *count { GBinPart **result; /* Tableau à retourner */ uint16_t i; /* Boucle de parcours */ + elf_shdr strings; /* Section des descriptions */ + bool has_strings; /* Section trouvée ? */ elf_shdr section; /* En-tête de section ELF */ GBinPart *part; /* Partie à intégrer à la liste*/ + const char *name; /* Nom trouvé ou NULL */ off_t offset; /* Début de part de programme */ elf_phdr phdr; /* En-tête de programme ELF */ result = NULL; *count = 0; + has_strings = find_elf_section_by_index(format, format->header.e_shstrndx, &strings); + /* Première tentative : les sections */ for (i = 0; i < format->header.e_shnum; i++) @@ -427,7 +432,15 @@ static GBinPart **g_elf_format_get_parts(const GElfFormat *format, size_t *count { part = g_binary_part_new(); - /* TODO : nom, droits/type */ + if (has_strings) + { + name = extract_name_from_elf_string_section(format, &strings, + ELF_SHDR(format, section, sh_name)); + + if (name != NULL) + g_binary_part_set_name(part, name); + + } g_binary_part_set_values(part, ELF_SHDR(format, section, sh_offset), diff --git a/src/format/elf/section.c b/src/format/elf/section.c index e019648..f837dbf 100644 --- a/src/format/elf/section.c +++ b/src/format/elf/section.c @@ -92,6 +92,8 @@ bool find_elf_section_by_name(const GElfFormat *format, const char *name, elf_sh secname = extract_name_from_elf_string_section(format, &strings, ELF_SHDR(format, *section, sh_name)); + /* FIXME : if secname == NULL */ + result = (strcmp(name, secname) == 0); } |