From 1399ca35405f64fe5be71c8aa4723c759873b992 Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Sun, 14 Jun 2009 21:04:54 +0000
Subject: Stored the size of the routines (x86 only).

git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@77 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
---
 ChangeLog                |  9 +++++++++
 src/analysis/prototype.c | 40 ++++++++++++++++++++++++++++++++++++++++
 src/analysis/prototype.h |  7 +++++++
 src/format/elf/e_elf.c   |  1 +
 src/format/elf/elf-int.h |  1 +
 src/format/elf/symbol.c  |  1 +
 6 files changed, 59 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 5b0507a..faf6ecb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 09-06-14  Cyrille Bagard <nocbos@gmail.com>
 
+	* src/analysis/prototype.c:
+	* src/analysis/prototype.h:
+	* src/format/elf/e_elf.c:
+	* src/format/elf/elf-int.h:
+	* src/format/elf/symbol.c:
+	Store the size of the routines (x86 only).
+
+09-06-14  Cyrille Bagard <nocbos@gmail.com>
+
 	* src/analysis/binary.c:
 	Update the call to g_rendering_line_find_by_(offset|address).
 
diff --git a/src/analysis/prototype.c b/src/analysis/prototype.c
index 78854f9..d68a485 100644
--- a/src/analysis/prototype.c
+++ b/src/analysis/prototype.c
@@ -38,6 +38,7 @@ struct _GBinRoutine
     GObject parent;                         /* A laisser en premier        */
 
     vmpa_t addr;                            /* Position physique/mémoire   */
+    off_t size;                             /* Taille du code associé      */
 
     RoutineType type;                       /* Type de routine             */
 
@@ -202,6 +203,45 @@ vmpa_t g_binary_routine_get_address(const GBinRoutine *routine)
 /******************************************************************************
 *                                                                             *
 *  Paramètres  : routine = routine à mettre à jour.                           *
+*                addr    = taille du code associé.                            *
+*                                                                             *
+*  Description : Définit la taille du code d'une routine.                     *
+*                                                                             *
+*  Retour      : -                                                            *
+*                                                                             *
+*  Remarques   : -                                                            *
+*                                                                             *
+******************************************************************************/
+
+void g_binary_routine_set_size(GBinRoutine *routine, off_t size)
+{
+    routine->size = size;
+
+}
+
+
+/******************************************************************************
+*                                                                             *
+*  Paramètres  : routine = routine à mettre à jour.                           *
+*                                                                             *
+*  Description : Fournit la taille du code associé à une routine.             *
+*                                                                             *
+*  Retour      : Taille du code associée.                                     *
+*                                                                             *
+*  Remarques   : -                                                            *
+*                                                                             *
+******************************************************************************/
+
+off_t g_binary_routine_get_size(const GBinRoutine *routine)
+{
+    return routine->size;
+
+}
+
+
+/******************************************************************************
+*                                                                             *
+*  Paramètres  : routine = routine à mettre à jour.                           *
 *                type    = type de routine spécifié.                          *
 *                                                                             *
 *  Description : Définit le type d'une routine.                               *
diff --git a/src/analysis/prototype.h b/src/analysis/prototype.h
index 299cce6..fe6d0a4 100644
--- a/src/analysis/prototype.h
+++ b/src/analysis/prototype.h
@@ -27,6 +27,7 @@
 
 #include <glib-object.h>
 #include <stdint.h>
+#include <sys/types.h>
 
 
 #include "variable.h"
@@ -69,6 +70,12 @@ void g_binary_routine_set_address(GBinRoutine *, vmpa_t);
 /* Fournit la position physique / en mémoire d'une routine. */
 vmpa_t g_binary_routine_get_address(const GBinRoutine *);
 
+/* Définit la taille du code d'une routine. */
+void g_binary_routine_set_size(GBinRoutine *, off_t);
+
+/* Fournit la taille du code associé à une routine. */
+off_t g_binary_routine_get_size(const GBinRoutine *);
+
 /* Définit le type d'une routine. */
 void g_binary_routine_set_type(GBinRoutine *, RoutineType);
 
diff --git a/src/format/elf/e_elf.c b/src/format/elf/e_elf.c
index 1de4ac0..e974b51 100644
--- a/src/format/elf/e_elf.c
+++ b/src/format/elf/e_elf.c
@@ -601,6 +601,7 @@ GBinRoutine **get_all_elf_routines(const elf_format *format, size_t *count)
         result[i] = g_binary_routine_new();
 
         g_binary_routine_set_address(result[i], format->symbols[i].address);
+        g_binary_routine_set_size(result[i], format->symbols[i].size);
         g_binary_routine_set_name(result[i], strdup(format->symbols[i].name));
 
     }
diff --git a/src/format/elf/elf-int.h b/src/format/elf/elf-int.h
index dd8909d..65fc922 100644
--- a/src/format/elf/elf-int.h
+++ b/src/format/elf/elf-int.h
@@ -48,6 +48,7 @@ typedef struct _elf_symbol
 {
     const char *name;                       /* Désignation du symbole      */
     uint64_t address;                       /* Adresse du symbole          */
+    off_t size;                             /* Taille du code associé      */
 
 } elf_symbol;
 
diff --git a/src/format/elf/symbol.c b/src/format/elf/symbol.c
index eaf11a4..35dd50f 100644
--- a/src/format/elf/symbol.c
+++ b/src/format/elf/symbol.c
@@ -297,6 +297,7 @@ bool load_elf_symbol_table_32(elf_format *format, const off_t *sym_start, const
 
             format->symbols[format->sym_count - 1].name = &EXE_FORMAT(format)->content[*str_start + symbol.st_name];
             format->symbols[format->sym_count - 1].address = symbol.st_value;
+            format->symbols[format->sym_count - 1].address = symbol.st_size;
 
         }
 
-- 
cgit v0.11.2-87-g4458