summaryrefslogtreecommitdiff
path: root/src/format/elf
diff options
context:
space:
mode:
Diffstat (limited to 'src/format/elf')
-rw-r--r--src/format/elf/elf.c15
-rw-r--r--src/format/elf/section.c2
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);
}