diff options
Diffstat (limited to 'src/format/elf/elf-int.c')
-rw-r--r-- | src/format/elf/elf-int.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/format/elf/elf-int.c b/src/format/elf/elf-int.c index e3333c4..97a3ffa 100644 --- a/src/format/elf/elf-int.c +++ b/src/format/elf/elf-int.c @@ -373,3 +373,59 @@ bool read_elf_relocation(const GElfFormat *format, phys_t *phys, elf_rel *reloc) return result; } + + +/****************************************************************************** +* * +* Paramètres : format = informations chargées à consulter. * +* content = contenu binaire mis à disposition ou NULL. * +* pos = position de début de lecture. [OUT] * +* note = structure lue à retourner. [OUT] * +* * +* Description : Procède à la lecture d'une note ELF. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool read_elf_note(const GElfFormat *format, GBinContent *content, phys_t *phys, elf_note *note) +{ + bool result; /* Bilan à retourner */ + vmpa2t pos; /* Position de lecture */ + + if (content == NULL) + content = G_BIN_FORMAT(format)->content; + + init_vmpa(&pos, *phys, VMPA_NO_VIRTUAL); + + result = g_binary_content_read_u32(content, &pos, format->endian, ¬e->namesz); + result &= g_binary_content_read_u32(content, &pos, format->endian, ¬e->descsz); + result &= g_binary_content_read_u32(content, &pos, format->endian, ¬e->type); + + if (result && note->namesz > 0) + { + align_vmpa(&pos, 4); + + note->name = (const char *)g_binary_content_get_raw_access(content, &pos, note->namesz); + + result &= (note->name != NULL); + + } + else note->name = NULL; + + if (result && note->descsz > 0) + { + align_vmpa(&pos, 4); + + note->desc = (const void *)g_binary_content_get_raw_access(content, &pos, note->descsz); + + result &= (note->desc != NULL); + + } + else note->desc = NULL; + + return result; + +} |