diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2016-12-04 23:09:45 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2016-12-04 23:09:45 (GMT) |
commit | b3efd0bbc506e701ea9872f50b8b4db974f35954 (patch) | |
tree | 11926fd4d0e39321b0da171e8d926868dd618475 /src/format/elf/elf-int.c | |
parent | 7d6d3acb65586ad9512a38b58c16b9a21cdf98e0 (diff) |
Read ELF notes when requested.
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; + +} |