summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-08-02 22:25:15 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-08-02 22:25:15 (GMT)
commit8c84aa2e41305fd388b7dac49f29ae17ee0554fb (patch)
tree52830a7d896e2d9272e7c71677c72ce9d62cf26c /plugins
parent30fc2ba22b469e38bc40e47f517988e418c178f3 (diff)
Introduced symbols dedicated to strings.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/dex/pool.c12
-rw-r--r--plugins/elf/strings.c13
-rw-r--r--plugins/pychrysalide/format/symbol.c3
-rw-r--r--plugins/readelf/strtab.c16
4 files changed, 12 insertions, 32 deletions
diff --git a/plugins/dex/pool.c b/plugins/dex/pool.c
index 75841df..d95f519 100644
--- a/plugins/dex/pool.c
+++ b/plugins/dex/pool.c
@@ -31,6 +31,7 @@
#include <i18n.h>
#include <core/global.h>
#include <core/nproc.h>
+#include <format/strsym.h>
#include <mangling/demangler.h>
@@ -205,9 +206,8 @@ GBinSymbol *get_string_symbol_from_dex_pool(GDexFormat *format, uint32_t index)
uint32_t count; /* Nombre d'éléments présents */
mrange_t range; /* Emplacement de la chaîne */
const char *string; /* Chaîne de caractères liée */
- GBinSymbol *new; /* Nouveau symbol créé */
GBinFormat *base; /* Autre version du format */
- char *label; /* Désignation de la chaîne */
+ GBinSymbol *new; /* Nouveau symbol créé */
bool inserted; /* Bilan d'une insertion */
result = NULL;
@@ -222,15 +222,11 @@ GBinSymbol *get_string_symbol_from_dex_pool(GDexFormat *format, uint32_t index)
string = get_string_from_dex_pool(format, index, &range);
if (string == NULL) goto gssfdp_error;
- new = g_binary_symbol_new(&range, STP_RO_STRING);
-
base = G_BIN_FORMAT(format);
- label = create_string_label(base, get_mrange_addr(&range), get_mrange_length(&range));
-
- g_binary_symbol_set_alt_label(new, label);
+ new = g_string_symbol_new_read_only(base, &range, SET_MUTF_8);
- free(label);
+ g_string_symbol_build_label(G_STR_SYMBOL(new), base);
g_object_ref(G_OBJECT(new));
inserted = g_binary_format_add_symbol(base, new);
diff --git a/plugins/elf/strings.c b/plugins/elf/strings.c
index a14b389..4d6b5c8 100644
--- a/plugins/elf/strings.c
+++ b/plugins/elf/strings.c
@@ -36,6 +36,7 @@
#include <arch/raw.h>
#include <core/global.h>
#include <core/nproc.h>
+#include <format/strsym.h>
#include "elf-int.h"
@@ -285,7 +286,6 @@ static bool do_elf_string_loading(GElfLoading *loading, GElfFormat *format, phys
const mrange_t *range; /* Espace occupé par une chaîne*/
GBinSymbol *symbol; /* Symbole à intégrer */
bool cut; /* Coupure par étiquette ? */
- char *label; /* Désignation de la chaîne */
result = false;
@@ -355,7 +355,7 @@ static bool do_elf_string_loading(GElfLoading *loading, GElfFormat *format, phys
{
range = g_arch_instruction_get_range(instr);
- symbol = g_binary_symbol_new(range, STP_RO_STRING);
+ symbol = g_string_symbol_new_read_only(base, range, SET_GUESS);
g_binary_format_add_symbol(base, symbol);
/* Jointure avec la chaîne précédente ? */
@@ -366,14 +366,7 @@ static bool do_elf_string_loading(GElfLoading *loading, GElfFormat *format, phys
cut = (data[*iter - offset - 1] == '\0');
if (cut)
- {
- label = create_string_label(base, get_mrange_addr(range), end - *iter);
-
- g_binary_symbol_set_alt_label(symbol, label);
-
- free(label);
-
- }
+ g_string_symbol_build_label(G_STR_SYMBOL(symbol), base);
}
diff --git a/plugins/pychrysalide/format/symbol.c b/plugins/pychrysalide/format/symbol.c
index 7dcb0eb..d6298d4 100644
--- a/plugins/pychrysalide/format/symbol.c
+++ b/plugins/pychrysalide/format/symbol.c
@@ -342,13 +342,14 @@ static bool py_binary_symbol_define_constants(PyTypeObject *obj_type)
result &= PyDict_AddIntMacro(obj_type, STP_CODE_LABEL);
result &= PyDict_AddIntMacro(obj_type, STP_OBJECT);
result &= PyDict_AddIntMacro(obj_type, STP_ENTRY_POINT);
- result &= PyDict_AddIntMacro(obj_type, STP_STRING);
result &= PyDict_AddIntMacro(obj_type, STP_RO_STRING);
+ result &= PyDict_AddIntMacro(obj_type, STP_DYN_STRING);
result &= PyDict_AddIntMacro(obj_type, STP_COUNT);
result &= PyDict_AddIntMacro(obj_type, SSS_INTERNAL);
result &= PyDict_AddIntMacro(obj_type, SSS_EXPORTED);
result &= PyDict_AddIntMacro(obj_type, SSS_IMPORTED);
+ result &= PyDict_AddIntMacro(obj_type, SSS_DYNAMIC);
return result;
diff --git a/plugins/readelf/strtab.c b/plugins/readelf/strtab.c
index e8d0f45..3cbe353 100644
--- a/plugins/readelf/strtab.c
+++ b/plugins/readelf/strtab.c
@@ -29,6 +29,7 @@
#include <arch/raw.h>
+#include <format/strsym.h>
#include <plugins/elf/section.h>
@@ -67,7 +68,6 @@ static void parse_elf_string_table(GElfFormat *format, GPreloadInfo *info, const
bool inserted; /* Bilan d'une insertion */
const mrange_t *irange; /* Espace occupé par une chaîne*/
GBinSymbol *symbol; /* Symbole à intégrer */
- char *label; /* Désignation de la chaîne */
length = get_mrange_length(range);
@@ -112,23 +112,13 @@ static void parse_elf_string_table(GElfFormat *format, GPreloadInfo *info, const
{
irange = g_arch_instruction_get_range(instr);
- symbol = g_binary_symbol_new(irange, STP_RO_STRING);
+ symbol = g_string_symbol_new_read_only(base, irange, SET_GUESS);
g_binary_format_add_symbol(base, symbol);
/* Jointure avec la chaîne précédente ? */
if (cut)
- {
- copy_vmpa(&pos, get_mrange_addr(range));
- advance_vmpa(&pos, i);
-
- label = create_string_label(base, get_mrange_addr(irange), end - i);
-
- g_binary_symbol_set_alt_label(symbol, label);
-
- free(label);
-
- }
+ g_string_symbol_build_label(G_STR_SYMBOL(symbol), base);
}