summaryrefslogtreecommitdiff
path: root/src/format/elf/elf-int.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2014-08-19 20:25:20 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2014-08-19 20:25:20 (GMT)
commit2425953ed7330c8f92ec7d04a5f248db1ed98a9d (patch)
treef389f040f6bcc9f88d837e0e2f37cbd49758f610 /src/format/elf/elf-int.c
parenta0a7b6c1e05c78ae433f353d15e3366107b67d03 (diff)
Added a demo symbol when loading an ELF header.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@390 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/format/elf/elf-int.c')
-rw-r--r--src/format/elf/elf-int.c56
1 files changed, 53 insertions, 3 deletions
diff --git a/src/format/elf/elf-int.c b/src/format/elf/elf-int.c
index 353ae05..17aeaf2 100644
--- a/src/format/elf/elf-int.c
+++ b/src/format/elf/elf-int.c
@@ -27,11 +27,13 @@
#include <string.h>
+#include "../../arch/raw.h"
+
+
/******************************************************************************
* *
-* Paramètres : content = contenu binaire à parcourir. *
-* length = taille du contenu en question. *
+* Paramètres : format = informations chargées à consulter. *
* header = en-tête à déterminer. [OUT] *
* is_32b = indique si le format est en 32 ou 64 bits. [OUT] *
* endian = boutisme reconnu dans le format. [OUT] *
@@ -44,10 +46,27 @@
* *
******************************************************************************/
-bool read_elf_header(const bin_t *content, off_t length, elf_header *header, bool *is_32b, SourceEndian *endian)
+bool read_elf_header(GElfFormat *format, elf_header *header, bool *is_32b, SourceEndian *endian)
{
bool result; /* Bilan à retourner */
+ const bin_t *content; /* Contenu binaire à lire */
+ off_t length; /* Taille totale du contenu */
off_t pos; /* Position de lecture */
+ GArchInstruction *instr; /* Instruction décodée */
+
+
+ vmpa2t *pos2;
+
+
+ GBinSymbol *symbol;
+
+ size_t i; /* Boucle de parcours */
+ GArchOperand *operand; /* Opérande à venir modifier */
+
+
+
+ content = G_BIN_FORMAT(format)->content;
+ length = G_BIN_FORMAT(format)->length;
result = (length >= EI_NIDENT);
@@ -89,6 +108,37 @@ bool read_elf_header(const bin_t *content, off_t length, elf_header *header, boo
break;
}
+
+ pos2 = make_vmpa(0, 0x123);
+
+
+
+ instr = g_raw_instruction_new_array(content, MDS_8_BITS, 4, pos2, 4, *endian);
+
+
+ for (i = 1; i < 4; i++)
+ {
+ operand = g_arch_instruction_get_operand(instr, i);
+ g_imm_operand_set_display(G_IMM_OPERAND(operand), IOD_CHAR);
+ }
+
+
+
+
+ symbol = g_binary_symbol_new(STP_OBJECT, "toto", 0);
+
+ printf("TOTO\n");
+
+ g_binary_symbol_attach_instruction(symbol, instr);
+ g_binary_format_add_symbol(format, symbol);
+
+
+
+
+
+
+
+
if (*is_32b)
{
result &= read_u16(&header->hdr32.e_type, content, &pos, length, *endian);