summaryrefslogtreecommitdiff
path: root/src/format/elf
diff options
context:
space:
mode:
Diffstat (limited to 'src/format/elf')
-rw-r--r--src/format/elf/helper_arm.c17
-rw-r--r--src/format/elf/helper_x86.c6
-rw-r--r--src/format/elf/strings.c11
-rw-r--r--src/format/elf/symbols.c24
4 files changed, 23 insertions, 35 deletions
diff --git a/src/format/elf/helper_arm.c b/src/format/elf/helper_arm.c
index a08c473..734a2bb 100644
--- a/src/format/elf/helper_arm.c
+++ b/src/format/elf/helper_arm.c
@@ -55,6 +55,7 @@ bool load_elf_arm_relocated_symbols(GElfFormat *format, const elf_shdr *relxxx,
bool result; /* Bilan à retourner */
phys_t rel_start; /* Début de la zone à traiter */
phys_t rel_size; /* Taille de cette même zone */
+ GBinFormat *base; /* Autre version du format */
phys_t iter; /* Boucle de parcours */
elf_rel reloc; /* Infos de relocalisation */
off_t index; /* Indice de la portion visée */
@@ -67,9 +68,9 @@ bool load_elf_arm_relocated_symbols(GElfFormat *format, const elf_shdr *relxxx,
virt_t final_virt; /* Adresse virtuelle retenue */
bool status; /* Bilan d'une opération */
vmpa2t addr; /* Localisation d'une routine */
- mrange_t range; /* Couverture mémoire associée */
GBinRoutine *routine; /* Nouvelle routine trouvée */
GBinSymbol *symbol; /* Nouveau symbole construit */
+ mrange_t range; /* Couverture mémoire associée */
@@ -80,6 +81,7 @@ bool load_elf_arm_relocated_symbols(GElfFormat *format, const elf_shdr *relxxx,
get_elf_section_content(format, relxxx, &rel_start, &rel_size, NULL);
+ base = G_BIN_FORMAT(format);
for (iter = rel_start; iter < (rel_start + rel_size); )
{
@@ -110,17 +112,14 @@ bool load_elf_arm_relocated_symbols(GElfFormat *format, const elf_shdr *relxxx,
status = g_exe_format_translate_address_into_vmpa(G_EXE_FORMAT(format), final_virt, &addr);
if (!status) continue;
- init_mrange(&range, &addr, 0);
-
routine = try_to_demangle_routine(name);
+ symbol = G_BIN_SYMBOL(routine);
- g_binary_routine_set_range(routine, &range);
-
- symbol = g_binary_symbol_new(STP_ROUTINE);
- g_binary_symbol_attach_routine(symbol, routine);
+ init_mrange(&range, &addr, 0);
+ g_binary_symbol_set_range(symbol, &range);
/* Comptabilisation pour le désassemblage brut */
- g_binary_format_register_code_point(G_BIN_FORMAT(format), virt, false);
+ g_binary_format_register_code_point(base, virt, false);
break;
@@ -132,7 +131,7 @@ bool load_elf_arm_relocated_symbols(GElfFormat *format, const elf_shdr *relxxx,
}
if (symbol != NULL)
- g_binary_format_add_symbol(G_BIN_FORMAT(format), symbol);
+ g_binary_format_add_symbol(base, symbol);
}
diff --git a/src/format/elf/helper_x86.c b/src/format/elf/helper_x86.c
index 826ac40..ba37bcb 100644
--- a/src/format/elf/helper_x86.c
+++ b/src/format/elf/helper_x86.c
@@ -140,7 +140,7 @@ bool load_elf_x86_relocated_symbols(GElfFormat *format, const elf_shdr *relxxx,
name = "unknown";
}
- symbol = g_binary_symbol_new(STP_ROUTINE);
+ symbol = g_binary_symbol_new(NULL, STP_ROUTINE);
g_binary_format_add_symbol(G_BIN_FORMAT(format), symbol);
break;
@@ -323,7 +323,7 @@ void translate_exe_elf_relocations(GElfFormat *format, GArchInstruction **instru
/* Symbole uniquement */
- symbol = g_binary_symbol_new(STP_ROUTINE);
+ symbol = g_binary_symbol_new(NULL, STP_ROUTINE);
g_binary_symbol_attach_routine(symbol, routine);
@@ -431,7 +431,7 @@ void translate_dyn_elf_relocations(GElfFormat *format, GArchInstruction **instru
/* Symbole uniquement */
- symbol = g_binary_symbol_new(STP_ROUTINE);
+ symbol = g_binary_symbol_new(NULL, STP_ROUTINE);
g_binary_symbol_attach_routine(symbol, routine);
diff --git a/src/format/elf/strings.c b/src/format/elf/strings.c
index d350200..53d4e92 100644
--- a/src/format/elf/strings.c
+++ b/src/format/elf/strings.c
@@ -159,6 +159,7 @@ static bool parse_elf_string_data(GElfFormat *format, phys_t start, phys_t size,
phys_t i; /* Boucle de parcours */
phys_t end; /* Position de fin de chaîne */
GArchInstruction *instr; /* Instruction décodée */
+ const mrange_t *range; /* Espace occupé par une chaîne*/
GBinSymbol *symbol; /* Symbole à intégrer */
char *label; /* Désignation de la chaîne */
@@ -204,16 +205,16 @@ static bool parse_elf_string_data(GElfFormat *format, phys_t start, phys_t size,
g_preload_info_add_instruction(base->info, instr);
- g_object_ref(G_OBJECT(instr));
- ADD_STR_AS_SYM(format, symbol, instr);
+ range = g_arch_instruction_get_range(instr);
+
+ symbol = g_binary_symbol_new(range, STP_RO_STRING);
+ g_binary_format_add_symbol(base, symbol);
/* Jointure avec la chaîne précédente ? */
if (cut)
{
- init_vmpa(&pos, start + i, address + i);
-
- label = create_string_label(base, &pos, end - i);
+ label = create_string_label(base, get_mrange_addr(range), end - i);
g_binary_symbol_set_alt_label(symbol, label);
diff --git a/src/format/elf/symbols.c b/src/format/elf/symbols.c
index 8451911..62fae58 100644
--- a/src/format/elf/symbols.c
+++ b/src/format/elf/symbols.c
@@ -207,27 +207,19 @@ static void register_elf_entry_point(GElfFormat *format, virt_t vaddr, phys_t le
/* Comptabilisation en tant que symbole */
if (g_binary_format_find_symbol_at(G_BIN_FORMAT(format), &addr, &symbol))
- {
g_object_unref(G_OBJECT(routine));
- routine = g_binary_symbol_get_routine(symbol);
- g_object_ref(G_OBJECT(routine));
-
- _g_binary_symbol_attach_routine(symbol, routine, STP_ENTRY_POINT);
-
- g_object_unref(G_OBJECT(symbol));
-
- }
else
{
base = G_BIN_FORMAT(format);
init_mrange(&range, &addr, len);
- g_binary_routine_set_range(routine, &range);
+ symbol = G_BIN_SYMBOL(routine);
+
+ g_binary_symbol_set_range(symbol, &range);
+ g_binary_symbol_set_target_type(symbol, STP_ENTRY_POINT);
- symbol = g_binary_symbol_new(STP_ENTRY_POINT);
- g_binary_symbol_attach_routine(symbol, routine);
g_binary_format_add_symbol(base, symbol);
/* Comptabilisation pour le désassemblage brut */
@@ -652,13 +644,9 @@ static bool do_elf_internal_symbol_loading(GElfLoading *loading, GElfFormat *for
/* Routine */
routine = try_to_demangle_routine(name);
+ symbol = G_BIN_SYMBOL(routine);
- g_binary_routine_set_range(routine, &range);
-
- /* Symbole uniquement */
-
- symbol = g_binary_symbol_new(STP_ROUTINE);
- g_binary_symbol_attach_routine(symbol, routine);
+ g_binary_symbol_set_range(symbol, &range);
/* Comptabilisation pour le désassemblage brut */