summaryrefslogtreecommitdiff
path: root/src/format
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2016-12-04 23:09:45 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2016-12-04 23:09:45 (GMT)
commitb3efd0bbc506e701ea9872f50b8b4db974f35954 (patch)
tree11926fd4d0e39321b0da171e8d926868dd618475 /src/format
parent7d6d3acb65586ad9512a38b58c16b9a21cdf98e0 (diff)
Read ELF notes when requested.
Diffstat (limited to 'src/format')
-rw-r--r--src/format/elf/elf-int.c56
-rw-r--r--src/format/elf/elf-int.h3
-rw-r--r--src/format/elf/elf_def.h25
3 files changed, 83 insertions, 1 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, &note->namesz);
+ result &= g_binary_content_read_u32(content, &pos, format->endian, &note->descsz);
+ result &= g_binary_content_read_u32(content, &pos, format->endian, &note->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;
+
+}
diff --git a/src/format/elf/elf-int.h b/src/format/elf/elf-int.h
index 0382e29..7ed2ffd 100644
--- a/src/format/elf/elf-int.h
+++ b/src/format/elf/elf-int.h
@@ -70,6 +70,9 @@ bool read_elf_symbol(const GElfFormat *, phys_t *, elf_sym *);
/* Procède à la lecture d'une relocalisation ELF. */
bool read_elf_relocation(const GElfFormat *, phys_t *, elf_rel *);
+/* Procède à la lecture d'une note ELF. */
+bool read_elf_note(const GElfFormat *, GBinContent *, phys_t *, elf_note *);
+
#endif /* _FORMAT_ELF_ELF_INT_H */
diff --git a/src/format/elf/elf_def.h b/src/format/elf/elf_def.h
index 04e3bcc..e29ec03 100644
--- a/src/format/elf/elf_def.h
+++ b/src/format/elf/elf_def.h
@@ -605,7 +605,30 @@ typedef union _elf_rel
/* Type de relocalisation (ARM) */
-#define R_ARM_JUMP_SLOT 22 /* Create PLT entry */
+#define R_ARM_JUMP_SLOT 22 /* Create PLT entry */
+
+
+
+/* --------------------------- NOTES ARBITRAIRES LAISSEES --------------------------- */
+
+
+/**
+ * Notes contenues dans un fichier ELF.
+ * Se rapporter au chapitre 5, partie "Note Section", des spécifications ABI
+ * du Système V pour d'avantage d'informations.
+ */
+
+typedef struct _elf_note
+{
+ uint32_t namesz; /* Taille du nom éventuel */
+ uint32_t descsz; /* Qté de données éventuelles */
+ uint32_t type; /* Indication supplémentaire */
+
+ const char *name; /* Auteur de la note */
+ const void *desc; /* Données complémentaires */
+
+} elf_note;
+
#endif /* _FORMAT_ELF_ELF_DEF_H */