summaryrefslogtreecommitdiff
path: root/src/format/elf/helper_x86.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2009-12-01 23:13:37 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2009-12-01 23:13:37 (GMT)
commitc6409e2c6a390a7cca40da8572c93a5268e90a27 (patch)
treea2163e55f17d2b6299e59a7539d01b8ae0020380 /src/format/elf/helper_x86.c
parentfc363c31cc0a24e026bac74b5f62f33f44bf0143 (diff)
Improved the Itanium demangling.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@139 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/format/elf/helper_x86.c')
-rw-r--r--src/format/elf/helper_x86.c43
1 files changed, 39 insertions, 4 deletions
diff --git a/src/format/elf/helper_x86.c b/src/format/elf/helper_x86.c
index 7113a18..02d4785 100644
--- a/src/format/elf/helper_x86.c
+++ b/src/format/elf/helper_x86.c
@@ -31,6 +31,7 @@
#include "elf-int.h"
#include "../symbol.h"
+#include "../mangling/demangler.h"
#include "../../arch/immediate.h"
#include "../../arch/processor.h"
#include "../../arch/x86/instruction.h"
@@ -290,9 +291,27 @@ void translate_exe_elf_relocations(GElfFormat *format, GArchInstruction **instru
/* Routine */
- routine = g_binary_routine_new();
+ //printf("++ routine :: %s\n", "_ZN1N1TIiiE2mfES0_IddE"/*g_binary_symbol_to_string(symbols[j])*/);
+ printf("++ routine :: %s\n", g_binary_symbol_to_string(symbols[j]));
+ fflush(NULL);
+
+ routine = try_to_demangle_routine(get_demangler_by_type(DGT_ITANIUM), "_ZN1N1TIiiE2mfES0_IddE");
+ routine = try_to_demangle_routine(get_demangler_by_type(DGT_ITANIUM), g_binary_symbol_to_string(symbols[j]));
+
+ if (routine == NULL)
+ {
+ routine = g_binary_routine_new();
+ g_binary_routine_set_name(routine, strdup(g_binary_symbol_to_string(symbols[j])));
+ printf("++failed\n");
+ }
+ else printf("++success\n");
+
+ printf(" -->> '%s'\n", g_binary_routine_get_name(routine));
+
+ //if (strcmp(g_binary_symbol_to_string(symbols[j]), "_ZNSt8ios_base4InitC1Ev") == 0)
+ //if (strcmp(g_binary_symbol_to_string(symbols[j]), "_ZNSolsEPFRSoS_E") == 0)
+ // exit(0);
- g_binary_routine_set_name(routine, new_name);
g_binary_routine_set_address(routine, address);
g_binary_format_add_routine(G_BIN_FORMAT(format), routine);
@@ -300,6 +319,9 @@ void translate_exe_elf_relocations(GElfFormat *format, GArchInstruction **instru
/* Symbole uniquement */
symbol = g_binary_symbol_new(STP_FUNCTION, new_name, address);
+
+ g_binary_symbol_attach_routine(symbol, routine);
+
g_binary_format_add_symbol(G_BIN_FORMAT(format), symbol);
break;
@@ -396,9 +418,19 @@ void translate_dyn_elf_relocations(GElfFormat *format, GArchInstruction **instru
/* Routine */
- routine = g_binary_routine_new();
+ printf("++ routine :: %s\n", name);
+ fflush(NULL);
+
+ routine = try_to_demangle_routine(get_demangler_by_type(DGT_ITANIUM), name);
+
+ if (routine == NULL)
+ {
+ routine = g_binary_routine_new();
+ g_binary_routine_set_name(routine, strdup(name));
+ printf("++failed\n");
+ }
+ else printf("++success\n");
- g_binary_routine_set_name(routine, new_name);
g_binary_routine_set_address(routine, address);
g_binary_format_add_routine(G_BIN_FORMAT(format), routine);
@@ -406,6 +438,9 @@ void translate_dyn_elf_relocations(GElfFormat *format, GArchInstruction **instru
/* Symbole uniquement */
symbol = g_binary_symbol_new(STP_FUNCTION, new_name, address);
+
+ g_binary_symbol_attach_routine(symbol, routine);
+
g_binary_format_add_symbol(G_BIN_FORMAT(format), symbol);
next_op: