summaryrefslogtreecommitdiff
path: root/src/format/elf
diff options
context:
space:
mode:
Diffstat (limited to 'src/format/elf')
-rw-r--r--src/format/elf/helper_x86.c43
-rw-r--r--src/format/elf/symbols.c24
2 files changed, 61 insertions, 6 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:
diff --git a/src/format/elf/symbols.c b/src/format/elf/symbols.c
index 94f10e3..3928c27 100644
--- a/src/format/elf/symbols.c
+++ b/src/format/elf/symbols.c
@@ -31,6 +31,7 @@
#include "elf-int.h"
#include "helper_x86.h"
#include "section.h"
+#include "../mangling/demangler.h"
#include "../../panels/log.h"
@@ -217,9 +218,28 @@ static bool load_elf_internal_symbols(GElfFormat *format)
/* Routine */
- routine = g_binary_routine_new();
+ printf("routine :: %s\n", name);
+ fflush(NULL);
+
+ if (1/*strcmp(name, "_Z41__static_initialization_and_destruction_0ii") == 0*/)
+ {
+
+ 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");
+
+ printf(" -->> '%s'\n", g_binary_routine_get_name(routine));
+
+ //exit(0);
+
+ }
- g_binary_routine_set_name(routine, strdup(name));
g_binary_routine_set_address(routine, ELF_SYM(format, sym, st_value));
g_binary_routine_set_size(routine, ELF_SYM(format, sym, st_size));