summaryrefslogtreecommitdiff
path: root/src/format
diff options
context:
space:
mode:
Diffstat (limited to 'src/format')
-rw-r--r--src/format/dex/method.c10
-rw-r--r--src/format/elf/helper_x86.c4
-rw-r--r--src/format/elf/symbols.c6
-rw-r--r--src/format/format.c2
-rw-r--r--src/format/symbol.c48
-rw-r--r--src/format/symbol.h7
6 files changed, 22 insertions, 55 deletions
diff --git a/src/format/dex/method.c b/src/format/dex/method.c
index d7900f8..22e7039 100644
--- a/src/format/dex/method.c
+++ b/src/format/dex/method.c
@@ -131,6 +131,10 @@ GDexMethod *g_dex_method_new(const GDexFormat *format, const encoded_method *see
GBinRoutine *routine;
+ vmpa2t addr;
+ mrange_t range;
+
+
offset = seed->code_off;
if (!read_dex_code_item(format, &offset, &item))
@@ -168,9 +172,11 @@ GDexMethod *g_dex_method_new(const GDexFormat *format, const encoded_method *see
//printf(" method off :: 0x%08x\n", result->offset);
+ init_vmpa(&addr, result->offset, VMPA_NO_VIRTUAL);
+ init_mrange(&range, &addr, item.insns_size * sizeof(uint16_t));
+
- g_binary_routine_set_address(routine, result->offset);
- g_binary_routine_set_size(routine, item.insns_size * sizeof(uint16_t));
+ g_binary_routine_set_range(routine, &range);
result->routine = routine;
diff --git a/src/format/elf/helper_x86.c b/src/format/elf/helper_x86.c
index d921592..af733a2 100644
--- a/src/format/elf/helper_x86.c
+++ b/src/format/elf/helper_x86.c
@@ -293,7 +293,7 @@ void translate_exe_elf_relocations(GElfFormat *format, GArchInstruction **instru
routine = try_to_demangle_routine(g_binary_symbol_to_string(symbols[j]));
- g_binary_routine_set_address(routine, address);
+ ///g_binary_routine_set_address(routine, address);
///// reactiver g_binary_format_add_routine(G_BIN_FORMAT(format), routine);
@@ -401,7 +401,7 @@ void translate_dyn_elf_relocations(GElfFormat *format, GArchInstruction **instru
routine = try_to_demangle_routine(name);
- g_binary_routine_set_address(routine, address);
+ ////g_binary_routine_set_address(routine, address);
///// reactiver g_binary_format_add_routine(G_BIN_FORMAT(format), routine);
diff --git a/src/format/elf/symbols.c b/src/format/elf/symbols.c
index 06d7cab..15c3a6b 100644
--- a/src/format/elf/symbols.c
+++ b/src/format/elf/symbols.c
@@ -1296,6 +1296,7 @@ static bool load_elf_internal_symbols(GElfFormat *format)
off_t iter; /* Boucle de parcours */
elf_sym sym; /* Symbole aux infos visées */
vmpa2t addr; /* Localisation d'une routine */
+ mrange_t range; /* Couverture mémoire associée */
const char *name; /* Nom du symbole trouvé */
char alt_name[5 + VMPA_MAX_LEN]; /* Nom abstrait de substitution*/
GBinRoutine *routine; /* Nouvelle routine trouvée */
@@ -1320,6 +1321,8 @@ static bool load_elf_internal_symbols(GElfFormat *format)
init_vmpa(&addr, ELF_SYM(format, sym, st_value), VMPA_NO_VIRTUAL);
+ init_mrange(&range, &addr, ELF_SYM(format, sym, st_size));
+
/* Première ébauche de nom */
@@ -1373,8 +1376,7 @@ static bool load_elf_internal_symbols(GElfFormat *format)
routine = try_to_demangle_routine(name);
- g_binary_routine_set_address(routine, &addr);
- g_binary_routine_set_size(routine, ELF_SYM(format, sym, st_size));
+ g_binary_routine_set_range(routine, &range);
/* Symbole uniquement */
diff --git a/src/format/format.c b/src/format/format.c
index 4b5dfb5..4fec391 100644
--- a/src/format/format.c
+++ b/src/format/format.c
@@ -374,7 +374,7 @@ bool g_binary_format_resolve_symbol(const GBinFormat *format, const char **label
for (i = 0; i < format->symbols_count && !result; i++)
{
addr = g_binary_symbol_get_address(format->symbols[i]);
- size = g_binary_symbol_get_size(format->symbols[i]);
+ size = 0;//////g_binary_symbol_get_size(format->symbols[i]);
if (addr <= *address && *address < (addr + size))
{
diff --git a/src/format/symbol.c b/src/format/symbol.c
index 5b80555..0875e1f 100644
--- a/src/format/symbol.c
+++ b/src/format/symbol.c
@@ -192,32 +192,29 @@ vmpa_t g_binary_symbol_get_address(const GBinSymbol *symbol)
/******************************************************************************
* *
* Paramètres : symbol = symbole à venir consulter. *
-* length = taille de l'instruction ou NULL. [OUT] *
* *
* Description : Fournit l'emplacement où se situe un symbole. *
* *
-* Retour : Adresse virtuelle ou physique associée. *
+* Retour : Zone mémoire couverte par le symbole. *
* *
* Remarques : - *
* *
******************************************************************************/
-const vmpa2t *g_binary_symbol_get_location(const GBinSymbol *symbol, off_t *length)
+const mrange_t *g_binary_symbol_get_range(const GBinSymbol *symbol)
{
- const vmpa2t *result; /* Localisation à retourner */
+ const mrange_t *result; /* Plage à retourner */
result = NULL;
switch (symbol->type)
{
case STP_DATA:
- result = g_arch_instruction_get_location2(symbol->extra.instr, length);
+ result = g_arch_instruction_get_range(symbol->extra.instr);
break;
case STP_ROUTINE:
- result = g_binary_routine_get_address(symbol->extra.routine);
- if (length != NULL)
- *length = g_binary_routine_get_size(symbol->extra.routine);
+ result = g_binary_routine_get_range(symbol->extra.routine);
break;
default:
@@ -234,41 +231,6 @@ const vmpa2t *g_binary_symbol_get_location(const GBinSymbol *symbol, off_t *leng
/******************************************************************************
* *
* Paramètres : symbol = symbole à venir consulter. *
-* *
-* Description : Fournit la taille officielle d'un symbole. *
-* *
-* Retour : Taille de symbole. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-off_t g_binary_symbol_get_size(const GBinSymbol *symbol)
-{
- off_t result; /* Taille à renvoyer */
-
- switch (symbol->type)
- {
- case STP_OBJECT:
- result = 1; /* FIXME */
- break;
- case STP_FUNCTION:
- /* FIXME */if (symbol->extra.routine == NULL) result = 1; else
- result = g_binary_routine_get_size(symbol->extra.routine);
- break;
- case STP_STRING:
- result = strlen(g_binary_symbol_to_string(symbol));
- break;
- }
-
- return result;;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : symbol = symbole à venir consulter. *
* alt = désignation humaine alternative à favoriser. *
* *
* Description : Définit un autre nom pour le symbole. *
diff --git a/src/format/symbol.h b/src/format/symbol.h
index 8d27f97..91268f1 100644
--- a/src/format/symbol.h
+++ b/src/format/symbol.h
@@ -72,13 +72,10 @@ SymbolType g_binary_symbol_get_target_type(const GBinSymbol *);
const char *g_binary_symbol_to_string(const GBinSymbol *);
/* Fournit l'adresse associée à un symbole. */
-vmpa_t g_binary_symbol_get_address(const GBinSymbol *);
+vmpa_t g_binary_symbol_get_address(const GBinSymbol *); ///////////////////
/* Fournit l'emplacement où se situe un symbole. */
-const vmpa2t *g_binary_symbol_get_location(const GBinSymbol *, off_t *);
-
-/* Fournit la taille officielle d'un symbole. */
-off_t g_binary_symbol_get_size(const GBinSymbol *);
+const mrange_t *g_binary_symbol_get_range(const GBinSymbol *);
/* Définit un autre nom pour le symbole. */
void g_binary_symbol_set_alt_name(GBinSymbol *, char *);