summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2017-12-08 20:50:56 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2017-12-08 20:50:56 (GMT)
commit39116dce7d40dab310e929f92fdbfc865b5fac20 (patch)
treea0b8dc11070f8a68de6b6f7bbc84b3d4ccf25afd /src
parentcf11fcf862b98ef57935bcfccd6f2f6ae3f925f6 (diff)
Introduced the symbol visibility.
Diffstat (limited to 'src')
-rw-r--r--src/analysis/disass/output.c27
-rw-r--r--src/analysis/disass/routines.c7
-rw-r--r--src/format/format.c2
-rw-r--r--src/format/symbol-int.h1
-rw-r--r--src/format/symbol.c41
-rw-r--r--src/format/symbol.h18
-rw-r--r--src/gui/panels/symbols.c16
-rw-r--r--src/panels/strings.c2
8 files changed, 100 insertions, 14 deletions
diff --git a/src/analysis/disass/output.c b/src/analysis/disass/output.c
index 8e74d1c..f9656cf 100644
--- a/src/analysis/disass/output.c
+++ b/src/analysis/disass/output.c
@@ -81,6 +81,7 @@ void print_disassembled_instructions(GBufferCache *cache, GCodingLanguage *lang,
GBorderGenerator *border; /* Délimitation de routine */
const vmpa2t *paddr; /* Adresse de portion */
GLineGenerator *generator; /* Générateur de contenu ajouté*/
+ SymbolStatus sym_status; /* Visibilité du symbole obtenu*/
const vmpa2t *saddr; /* Adresse de symbole */
int compared; /* Bilan d'une comparaison */
char *errmsg; /* Description d'une erreur */
@@ -210,13 +211,21 @@ void print_disassembled_instructions(GBufferCache *cache, GCodingLanguage *lang,
else
{
iaddr = get_mrange_addr(g_arch_instruction_get_range(instr));
- saddr = get_mrange_addr(g_binary_symbol_get_range(symbols[sym_index]));
- /* On écarte les symboles qu'on ne sait pas réintroduire */
- for (compared = cmp_vmpa(iaddr, saddr);
- compared > 0;
- compared = cmp_vmpa(iaddr, saddr))
+ for ( ; sym_index < sym_count; sym_index++)
{
+ sym_status = g_binary_symbol_get_status(symbols[sym_index]);
+
+ if (sym_status == SSS_IMPORTED)
+ continue;
+
+ saddr = get_mrange_addr(g_binary_symbol_get_range(symbols[sym_index]));
+
+ compared = cmp_vmpa(iaddr, saddr);
+
+ if (compared <= 0)
+ break;
+
log_variadic_message(LMT_BAD_BINARY,
_("Unable to find a proper location for symbol '%s' @ 0x%08x"),
g_binary_symbol_get_label(symbols[sym_index]), get_phy_addr(saddr));
@@ -230,13 +239,11 @@ void print_disassembled_instructions(GBufferCache *cache, GCodingLanguage *lang,
_missing++;
- if (++sym_index == sym_count)
- goto no_more_symbol_finally;
-
- saddr = get_mrange_addr(g_binary_symbol_get_range(symbols[sym_index]));
-
}
+ if (sym_index == sym_count)
+ goto no_more_symbol_finally;
+
if (compared == 0)
{
/* Coupure pour une nouvelle routine */
diff --git a/src/analysis/disass/routines.c b/src/analysis/disass/routines.c
index 01a6e48..63a32cf 100644
--- a/src/analysis/disass/routines.c
+++ b/src/analysis/disass/routines.c
@@ -233,11 +233,18 @@ static void g_routines_study_process(GRoutinesStudy *study, GtkStatusStack *stat
{
size_t i; /* Boucle de parcours */
GBinSymbol *symbol; /* Commodité d'accès */
+ SymbolStatus sym_status; /* Visibilité du symbole obtenu*/
SymbolType type; /* Type de symbole rencontré */
for (i = study->begin; i < study->end; i++)
{
symbol = study->symbols[i];
+
+ sym_status = g_binary_symbol_get_status(symbol);
+
+ if (sym_status == SSS_IMPORTED)
+ continue;
+
type = g_binary_symbol_get_target_type(symbol);
if (type == STP_ROUTINE || type == STP_ENTRY_POINT)
diff --git a/src/format/format.c b/src/format/format.c
index 8b1bf0a..ec8e5fb 100644
--- a/src/format/format.c
+++ b/src/format/format.c
@@ -407,7 +407,7 @@ bool g_binary_format_add_symbol(GBinFormat *format, GBinSymbol *symbol)
range = g_binary_symbol_get_range(symbol);
addr = get_mrange_addr(range);
- assert(has_phys_addr(addr));
+ assert(has_phys_addr(addr) || g_binary_symbol_get_status(symbol) == SSS_IMPORTED);
#endif
g_rw_lock_writer_lock(&format->syms_lock);
diff --git a/src/format/symbol-int.h b/src/format/symbol-int.h
index 49a0b97..a0460c2 100644
--- a/src/format/symbol-int.h
+++ b/src/format/symbol-int.h
@@ -41,6 +41,7 @@ struct _GBinSymbol
mrange_t range; /* Couverture mémoire */
SymbolType type; /* Type du symbole */
+ SymbolStatus status; /* Visibilité du symbole */
char *alt; /* Nom alternatif */
diff --git a/src/format/symbol.c b/src/format/symbol.c
index 0b300bd..099b764 100644
--- a/src/format/symbol.c
+++ b/src/format/symbol.c
@@ -123,6 +123,8 @@ static void g_binary_symbol_init(GBinSymbol *symbol)
{
g_binary_symbol_set_target_type(symbol, STP_COUNT);
+ g_binary_symbol_set_status(symbol, SSS_INTERNAL);
+
}
@@ -345,6 +347,45 @@ SymbolType g_binary_symbol_get_target_type(const GBinSymbol *symbol)
/******************************************************************************
* *
+* Paramètres : symbol = symbole à venir modifier. *
+* status = état de la visibilité du symbole représenté. *
+* *
+* Description : Définit la visibilité du symbole. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_binary_symbol_set_status(GBinSymbol *symbol, SymbolStatus status)
+{
+ symbol->status = status;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : symbol = symbole à venir consulter. *
+* *
+* Description : Fournit la visibilité du symbole. *
+* *
+* Retour : Etat de la visibilité du symbole représenté. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+SymbolStatus g_binary_symbol_get_status(const GBinSymbol *symbol)
+{
+ return symbol->status;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : symbol = symbole à venir consulter. *
* *
* Description : Fournit une étiquette pour viser un symbole. *
diff --git a/src/format/symbol.h b/src/format/symbol.h
index da51262..8aabfdf 100644
--- a/src/format/symbol.h
+++ b/src/format/symbol.h
@@ -51,6 +51,18 @@ typedef enum _SymbolType
} SymbolType;
+/* Visibilité du symbole */
+typedef enum _SymbolStatus
+{
+ SSS_INTERNAL, /* Visibilité nulle */
+ SSS_EXPORTED, /* Disponibilité extérieure */
+ SSS_IMPORTED, /* Besoin interne */
+
+ SSS_COUNT
+
+} SymbolStatus;
+
+
#define G_TYPE_BIN_SYMBOL g_binary_symbol_get_type()
#define G_BIN_SYMBOL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_binary_symbol_get_type(), GBinSymbol))
#define G_IS_BIN_SYMBOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_binary_symbol_get_type()))
@@ -90,6 +102,12 @@ void g_binary_symbol_set_target_type(GBinSymbol *, SymbolType);
/* Fournit le type du symbole. */
SymbolType g_binary_symbol_get_target_type(const GBinSymbol *);
+/* Définit la visibilité du symbole. */
+void g_binary_symbol_set_status(GBinSymbol *, SymbolStatus);
+
+/* Fournit la visibilité du symbole. */
+SymbolStatus g_binary_symbol_get_status(const GBinSymbol *);
+
/* Fournit une étiquette pour viser un symbole. */
const char *g_binary_symbol_get_label(GBinSymbol *);
diff --git a/src/gui/panels/symbols.c b/src/gui/panels/symbols.c
index 3b01f24..f64f087 100644
--- a/src/gui/panels/symbols.c
+++ b/src/gui/panels/symbols.c
@@ -1064,15 +1064,25 @@ static void do_filtering_on_symbols(GSymbolsPanel *panel)
static bool is_symbol_matching(GSymbolsPanel *panel, const GBinSymbol *symbol, regmatch_t *match)
{
bool result; /* Bilan à retourner */
+ SymbolStatus status; /* Visibilité du symbole obtenu*/
SymbolType type; /* Type associé au symbole */
- type = g_binary_symbol_get_target_type(symbol);
+ status = g_binary_symbol_get_status(symbol);
- if (type != STP_ROUTINE && type != STP_ENTRY_POINT && type != STP_OBJECT)
+ if (status == SSS_IMPORTED)
result = false;
else
- result = is_content_matching(panel->filter, g_binary_symbol_get_label(symbol), match);
+ {
+ type = g_binary_symbol_get_target_type(symbol);
+
+ if (type != STP_ROUTINE && type != STP_ENTRY_POINT && type != STP_OBJECT)
+ result = false;
+
+ else
+ result = is_content_matching(panel->filter, g_binary_symbol_get_label(symbol), match);
+
+ }
return result;
diff --git a/src/panels/strings.c b/src/panels/strings.c
index c7fd393..c60ef0a 100644
--- a/src/panels/strings.c
+++ b/src/panels/strings.c
@@ -135,6 +135,8 @@ void handle_new_exe_on_strings_panel(GtkWidget *panel, const GExeFormat *format)
for (i = 0; i < count; i++)
{
+ if (g_binary_symbol_get_status(symbols[i]) == SSS_IMPORTED) continue;
+
if (g_binary_symbol_get_target_type(symbols[i]) != STP_STRING) continue;
range = g_binary_symbol_get_range(symbols[i]);