From 73d58a38c5847f54aa9458b3612ffd35b7372dc9 Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Tue, 13 Dec 2016 12:40:53 +0100 Subject: Ensured all symbol comments match their symbol address. --- ChangeLog | 19 ++++++++++++ plugins/mobicore/annotations.c | 62 ++++++++++++++++++------------------- plugins/readdex/class.c | 55 ++++++++++----------------------- plugins/readdex/code.c | 50 +++++++++--------------------- plugins/readdex/header.c | 70 ++++++++++++++---------------------------- plugins/readdex/ids.c | 42 ++++++++----------------- plugins/readelf/header.c | 70 ++++++++++++++---------------------------- plugins/readelf/program.c | 46 +++++++++------------------ plugins/readelf/section.c | 49 ++++++++++------------------- src/arch/arm/v7/fetch.c | 2 +- src/format/symbol.c | 14 +++++++++ src/format/symbol.h | 6 ++-- 12 files changed, 190 insertions(+), 295 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1dede8b..d8d3c14 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +16-12-13 Cyrille Bagard + + * plugins/mobicore/annotations.c: + * plugins/readdex/class.c: + * plugins/readdex/code.c: + * plugins/readdex/header.c: + * plugins/readdex/ids.c: + * plugins/readelf/header.c: + * plugins/readelf/program.c: + * plugins/readelf/section.c: + * src/arch/arm/v7/fetch.c: + Update code. + + * src/format/symbol.c: + Ensure all symbol comments match their symbol address. + + * src/format/symbol.h: + Assign the linked instruction address to the new comment. + 16-12-12 Cyrille Bagard * configure.ac: diff --git a/plugins/mobicore/annotations.c b/plugins/mobicore/annotations.c index 0f91ffb..b53298e 100644 --- a/plugins/mobicore/annotations.c +++ b/plugins/mobicore/annotations.c @@ -81,7 +81,7 @@ static bool annotate_mclf_segment_descriptor(GMCLFFormat *format, const char *pr text = strdup(prefix); text = stradd(text, _(": start address")); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); @@ -92,7 +92,7 @@ static bool annotate_mclf_segment_descriptor(GMCLFFormat *format, const char *pr text = strdup(prefix); text = stradd(text, _(": length")); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); @@ -136,13 +136,13 @@ static bool annotate_mclf_intro(GMCLFFormat *format, vmpa2t *pos) SET_IMM_DISPLAY(instr, operand, 2, IOD_CHAR); SET_IMM_DISPLAY(instr, operand, 3, IOD_CHAR); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("MCLF magic number")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("MCLF magic number")); /* version */ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Version")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Version")); return true; @@ -176,7 +176,7 @@ static bool annotate_mclf_header_v1(GMCLFFormat *format, vmpa2t *pos) instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Service flags")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Service flags")); /* mem_type */ @@ -198,7 +198,7 @@ static bool annotate_mclf_header_v1(GMCLFFormat *format, vmpa2t *pos) break; } - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); /* service_type */ @@ -223,13 +223,13 @@ static bool annotate_mclf_header_v1(GMCLFFormat *format, vmpa2t *pos) break; } - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); /* num_instances */ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Number of instances which can be run simultaneously")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Number of instances which can be run simultaneously")); /* uuid */ @@ -237,7 +237,7 @@ static bool annotate_mclf_header_v1(GMCLFFormat *format, vmpa2t *pos) g_raw_instruction_mark_as_padding(G_RAW_INSTRUCTION(instr), true); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Loadable service unique identifier (UUID)")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Loadable service unique identifier (UUID)")); /* driver_id */ @@ -248,49 +248,49 @@ static bool annotate_mclf_header_v1(GMCLFFormat *format, vmpa2t *pos) else text = _("Unused Driver ID"); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Number of threads")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Number of threads")); /* num_threads */ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Number of threads")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Number of threads")); /* text.start */ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Virtual text segment: start address")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Virtual text segment: start address")); /* text.len */ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Virtual text segment: length")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Virtual text segment: length")); /* data.start */ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Virtual data segment: start address")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Virtual data segment: start address")); /* data.len */ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Virtual data segment: length")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Virtual data segment: length")); /* bss_len */ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Length of the BSS segment in bytes")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Length of the BSS segment in bytes")); /* entry */ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Virtual start address of service code")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Virtual start address of service code")); @@ -300,7 +300,7 @@ static bool annotate_mclf_header_v1(GMCLFFormat *format, vmpa2t *pos) instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Version of the interface the driver exports")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Version of the interface the driver exports")); @@ -309,19 +309,19 @@ static bool annotate_mclf_header_v1(GMCLFFormat *format, vmpa2t *pos) instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Silicon Provider ID")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Silicon Provider ID")); /* sip_data */ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 3, pos, format->endian); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Platform specific device identifier")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Platform specific device identifier")); /* permitted_hw_cfg */ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Configuration which is allowed to execute binary")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Configuration which is allowed to execute binary")); return true; @@ -365,37 +365,35 @@ static bool annotate_mclf_text_segment_header(GMCLFFormat *format, vmpa2t *pos) diff = compute_vmpa_diff(&old, pos); - printf("DIFF : %u\n", (unsigned int)diff); - instr = g_raw_instruction_new_array(content, MDS_8_BITS, diff, &old, format->endian); g_raw_instruction_mark_as_padding(G_RAW_INSTRUCTION(instr), true); - ADD_RAW_AS_SYM(format, symbol, &old, instr, comment, _("Padding")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Padding")); /* version */ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Version of the TextHeader structure")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Version of the TextHeader structure")); /* text_header_len */ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Size of this structure")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Size of this structure")); /* required_feat */ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Features that Mobicore must understand when loading")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Features that Mobicore must understand when loading")); /* mc_lib_entry */ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Address for McLib entry")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Address for McLib entry")); /* mc_lib_data */ @@ -408,25 +406,25 @@ static bool annotate_mclf_text_segment_header(GMCLFFormat *format, vmpa2t *pos) instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("McLib base address")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("McLib base address")); /* tl_api_vers */ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("TlApi version used when building trustlet")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("TlApi version used when building trustlet")); /* dr_api_vers */ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("DrApi version used when building trustlet")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("DrApi version used when building trustlet")); /* ta_properties */ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, format->endian); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Address of _TA_Properties in the TA")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Address of _TA_Properties in the TA")); return true; diff --git a/plugins/readdex/class.c b/plugins/readdex/class.c index 9d9d0af..43455b2 100644 --- a/plugins/readdex/class.c +++ b/plugins/readdex/class.c @@ -73,7 +73,6 @@ bool annotate_dex_class_defs(const GDexFormat *format, GtkStatusStack *status) vmpa2t pos; /* Tête de lecture des symboles*/ activity_id_t msg; /* Message de progression */ uint32_t i; /* Boucle de parcours */ - vmpa2t start; /* Localisation des symboles */ GArchInstruction *instr; /* Instruction décodée */ GArchOperand *operand; /* Opérande à venir modifier */ GDbComment *comment; /* Définition de commentaire */ @@ -99,14 +98,13 @@ bool annotate_dex_class_defs(const GDexFormat *format, GtkStatusStack *status) { /* class_idx */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); asprintf(&text, _("Index into the type_ids list for this class")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); @@ -115,92 +113,85 @@ bool annotate_dex_class_defs(const GDexFormat *format, GtkStatusStack *status) /* access_flags */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_HEX); asprintf(&text, _("Access flags for the class")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); /* superclass_idx */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); asprintf(&text, _("Index for the superclass or NO_INDEX if this class has no superclass")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); /* interfaces_off */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_HEX); asprintf(&text, _("Offset to the list of interfaces")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); /* source_file_idx */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); asprintf(&text, _("Index for the name of the file containing the original source or NO_INDEX")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); /* annotations_off */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_HEX); asprintf(&text, _("Offset to the annotations structure for this class")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); /* class_data_off */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_HEX); asprintf(&text, _("Offset to the associated class data for this item")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); /* static_values_off */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_HEX); asprintf(&text, _("Offset to the list of initial values for static fields")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); @@ -247,7 +238,6 @@ static bool annotate_dex_class_data(const GDexFormat *format, const GDexClass *c bool result; /* Bilan à retourner */ GBinContent *content; /* Contenu binaire à lire */ vmpa2t pos; /* Tête de lecture des symboles*/ - vmpa2t start; /* Localisation des symboles */ GArchInstruction *instr; /* Instruction décodée */ GArchOperand *operand; /* Opérande à venir modifier */ GDbComment *comment; /* Définition de commentaire */ @@ -263,14 +253,13 @@ static bool annotate_dex_class_data(const GDexFormat *format, const GDexClass *c /* static_fields_size */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_uleb128(content, &pos); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); asprintf(&text, _("Number of static fields defined in this item")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); @@ -278,40 +267,37 @@ static bool annotate_dex_class_data(const GDexFormat *format, const GDexClass *c /* instance_fields_size */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_uleb128(content, &pos); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); asprintf(&text, _("Number of instance fields defined in this item")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); /* direct_methods_size */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_uleb128(content, &pos); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); asprintf(&text, _("Number of direct methods defined in this item")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); /* virtual_methods_size */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_uleb128(content, &pos); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); asprintf(&text, _("Number of virtual methods defined in this item")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); @@ -362,7 +348,6 @@ static bool annotate_dex_class_data(const GDexFormat *format, const GDexClass *c static bool annotate_dex_encoded_field(const GDexFormat *format, vmpa2t *pos) { GBinContent *content; /* Contenu binaire à lire */ - vmpa2t start; /* Localisation des symboles */ GArchInstruction *instr; /* Instruction décodée */ GArchOperand *operand; /* Opérande à venir modifier */ GDbComment *comment; /* Définition de commentaire */ @@ -373,14 +358,13 @@ static bool annotate_dex_encoded_field(const GDexFormat *format, vmpa2t *pos) /* field_idx_diff */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_uleb128(content, pos); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); asprintf(&text, _("Index into the field_ids list for the identity of this field")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); @@ -388,14 +372,13 @@ static bool annotate_dex_encoded_field(const GDexFormat *format, vmpa2t *pos) /* access_flags */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_uleb128(content, pos); SET_IMM_DISPLAY(instr, operand, 0, IOD_HEX); asprintf(&text, _("Access flags for the field")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); @@ -426,7 +409,6 @@ static bool annotate_dex_encoded_method(const GDexFormat *format, const encoded_ { bool result; /* Bilan à retourner */ GBinContent *content; /* Contenu binaire à lire */ - vmpa2t start; /* Localisation des symboles */ GArchInstruction *instr; /* Instruction décodée */ GArchOperand *operand; /* Opérande à venir modifier */ GDbComment *comment; /* Définition de commentaire */ @@ -437,14 +419,13 @@ static bool annotate_dex_encoded_method(const GDexFormat *format, const encoded_ /* method_idx_diff */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_uleb128(content, pos); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); asprintf(&text, _("Index into the method_ids list for the identity of this method")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); @@ -452,27 +433,25 @@ static bool annotate_dex_encoded_method(const GDexFormat *format, const encoded_ /* access_flags */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_uleb128(content, pos); SET_IMM_DISPLAY(instr, operand, 0, IOD_HEX); asprintf(&text, _("Access flags for the method")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); /* code_off */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_uleb128(content, pos); SET_IMM_DISPLAY(instr, operand, 0, IOD_HEX); asprintf(&text, _("Offset to the code structure for this method")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); diff --git a/plugins/readdex/code.c b/plugins/readdex/code.c index 6c2a36e..62e846f 100644 --- a/plugins/readdex/code.c +++ b/plugins/readdex/code.c @@ -68,7 +68,6 @@ bool annotate_dex_code_item(const GDexFormat *format, uleb128_t offset) GBinContent *content; /* Contenu binaire à lire */ SourceEndian endian; /* Boutisme utilisé */ vmpa2t pos; /* Tête de lecture des symboles*/ - vmpa2t start; /* Localisation des symboles */ GArchInstruction *instr; /* Instruction décodée */ GArchOperand *operand; /* Opérande à venir modifier */ GDbComment *comment; /* Définition de commentaire */ @@ -87,14 +86,13 @@ bool annotate_dex_code_item(const GDexFormat *format, uleb128_t offset) /* registers_size */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_16_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); asprintf(&text, _("Number of registers used by this code")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); @@ -102,40 +100,37 @@ bool annotate_dex_code_item(const GDexFormat *format, uleb128_t offset) /* ins_size */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_16_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); asprintf(&text, _("Number of words of incoming arguments to the method that this code is for")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); /* outs_size */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_16_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); asprintf(&text, _("Number of words of outgoing argument space required by this code for method invocation")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); /* tries_size */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_16_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); asprintf(&text, _("Number of try_items for this instance")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); @@ -143,27 +138,25 @@ bool annotate_dex_code_item(const GDexFormat *format, uleb128_t offset) /* debug_info_off */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_HEX); asprintf(&text, _("Offset to the debug info sequence for this code")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); /* insns_size */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); asprintf(&text, _("Size of the instructions list, in 16-bit code units")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); @@ -177,14 +170,13 @@ bool annotate_dex_code_item(const GDexFormat *format, uleb128_t offset) if (insns_size % 2 != 0) { - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_16_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_HEX); asprintf(&text, _("Pading")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); @@ -227,7 +219,6 @@ static bool annotate_dex_try_item(const GDexFormat *format, vmpa2t *pos) bool result; /* Bilan à retourner */ GBinContent *content; /* Contenu binaire à lire */ SourceEndian endian; /* Boutisme utilisé */ - vmpa2t start; /* Localisation des symboles */ GArchInstruction *instr; /* Instruction décodée */ GArchOperand *operand; /* Opérande à venir modifier */ GDbComment *comment; /* Définition de commentaire */ @@ -242,14 +233,13 @@ static bool annotate_dex_try_item(const GDexFormat *format, vmpa2t *pos) /* start_addr */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_HEX); asprintf(&text, _("Start address of the block of code covered by this entry")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); @@ -257,27 +247,25 @@ static bool annotate_dex_try_item(const GDexFormat *format, vmpa2t *pos) /* insn_count */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_array(content, MDS_16_BITS, 1, pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); asprintf(&text, _("Number of 16-bit code units covered by this entry")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); /* handler_off */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_array(content, MDS_16_BITS, 1, pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_HEX); asprintf(&text, _("Offset to the encoded_catch_handler for this entry")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); @@ -307,7 +295,6 @@ static bool annotate_dex_encoded_catch_handler_list(const GDexFormat *format, vm { bool result; /* Bilan à retourner */ GBinContent *content; /* Contenu binaire à lire */ - vmpa2t start; /* Localisation des symboles */ GArchInstruction *instr; /* Instruction décodée */ GArchOperand *operand; /* Opérande à venir modifier */ GDbComment *comment; /* Définition de commentaire */ @@ -320,14 +307,13 @@ static bool annotate_dex_encoded_catch_handler_list(const GDexFormat *format, vm /* static_fields_size */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_uleb128(content, pos); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); asprintf(&text, _("Size of the list, in entries")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); @@ -368,7 +354,6 @@ static bool annotate_dex_encoded_catch_handler(const GDexFormat *format, vmpa2t { bool result; /* Bilan à retourner */ GBinContent *content; /* Contenu binaire à lire */ - vmpa2t start; /* Localisation des symboles */ GArchInstruction *instr; /* Instruction décodée */ GArchOperand *operand; /* Opérande à venir modifier */ GDbComment *comment; /* Définition de commentaire */ @@ -382,14 +367,13 @@ static bool annotate_dex_encoded_catch_handler(const GDexFormat *format, vmpa2t /* size */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_sleb128(content, pos); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); asprintf(&text, _("Number of static fields defined in this item")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); @@ -413,14 +397,13 @@ static bool annotate_dex_encoded_catch_handler(const GDexFormat *format, vmpa2t if (has_catch_all) { - copy_vmpa(&start, pos); instr = g_raw_instruction_new_uleb128(content, pos); SET_IMM_DISPLAY(instr, operand, 0, IOD_HEX); asprintf(&text, _("Bytecode address of the catch-all handler")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); @@ -451,7 +434,6 @@ static bool annotate_dex_encoded_catch_handler(const GDexFormat *format, vmpa2t static bool annotate_dex_encoded_type_addr_pair(const GDexFormat *format, vmpa2t *pos) { GBinContent *content; /* Contenu binaire à lire */ - vmpa2t start; /* Localisation des symboles */ GArchInstruction *instr; /* Instruction décodée */ GArchOperand *operand; /* Opérande à venir modifier */ GDbComment *comment; /* Définition de commentaire */ @@ -462,27 +444,25 @@ static bool annotate_dex_encoded_type_addr_pair(const GDexFormat *format, vmpa2t /* type_idx */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_uleb128(content, pos); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); asprintf(&text, _("Index for the type of the exception to catch")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); /* addr */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_uleb128(content, pos); SET_IMM_DISPLAY(instr, operand, 0, IOD_HEX); asprintf(&text, _("Bytecode address of the associated exception handler")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); diff --git a/plugins/readdex/header.c b/plugins/readdex/header.c index 6ebca3f..61d0c83 100644 --- a/plugins/readdex/header.c +++ b/plugins/readdex/header.c @@ -48,7 +48,6 @@ bool annotate_dex_header(GDexFormat *format) GBinContent *content; /* Contenu binaire à lire */ SourceEndian endian; /* Boutisme utilisé */ vmpa2t pos; /* Tête de lecture des symboles*/ - vmpa2t start; /* Localisation des symboles */ GArchInstruction *instr; /* Instruction décodée */ GArchOperand *operand; /* Opérande à venir modifier */ GDbComment *comment; /* Définition de commentaire */ @@ -63,7 +62,6 @@ bool annotate_dex_header(GDexFormat *format) /* magic */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_8_BITS, DEX_FILE_MAGIC_LEN, &pos, endian); g_raw_instruction_mark_as_string(G_RAW_INSTRUCTION(instr), true); @@ -80,208 +78,186 @@ bool annotate_dex_header(GDexFormat *format) SET_IMM_DISPLAY(instr, operand, 7, IOD_HEX); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("DEX magic number")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("DEX magic number")); g_binary_symbol_define_as_block_start(symbol, true); /* checksum */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_HEX); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("adler32 checksum used to detect file corruption")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("adler32 checksum used to detect file corruption")); /* signature */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 5, &pos, endian); g_arch_instruction_set_displayed_max_length(instr, 4); SET_IMM_DISPLAY(instr, operand, 0, IOD_HEX); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("SHA-1 signature used to uniquely identify files")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("SHA-1 signature used to uniquely identify files")); /* file_size */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Size of the entire file in bytes")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Size of the entire file in bytes")); /* header_size */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Size of the header in bytes")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Size of the header in bytes")); /* endian_tag */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_HEX); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Endianness tag ; 0x12345678 for little-endian")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Endianness tag ; 0x12345678 for little-endian")); /* link_size */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Size of the link section")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Size of the link section")); /* link_off */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_HEX); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Offset to the link section")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Offset to the link section")); /* map_off */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_HEX); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Offset to the map item")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Offset to the map item")); /* string_ids_size */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Count of strings in the string identifiers list")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Count of strings in the string identifiers list")); /* string_ids_off */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_HEX); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Offset to the string identifiers list")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Offset to the string identifiers list")); /* type_ids_size */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Count of elements in the type identifiers list")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Count of elements in the type identifiers list")); /* type_ids_off */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_HEX); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Offset to the type identifiers list")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Offset to the type identifiers list")); /* proto_ids_size */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Count of elements in the prototype identifiers list")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Count of elements in the prototype identifiers list")); /* proto_ids_off */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_HEX); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Offset to the prototype identifiers list")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Offset to the prototype identifiers list")); /* field_ids_size */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Count of elements in the field identifiers list")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Count of elements in the field identifiers list")); /* field_ids_off */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_HEX); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Offset to the field identifiers list")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Offset to the field identifiers list")); /* method_ids_size */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Count of elements in the method identifiers list")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Count of elements in the method identifiers list")); /* method_ids_off */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_HEX); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Offset to the method identifiers list")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Offset to the method identifiers list")); /* class_defs_size */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Count of elements in the class definitions list")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Count of elements in the class definitions list")); /* class_defs_off */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_HEX); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Offset to the class definitions list")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Offset to the class definitions list")); /* data_size */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Size of data section in bytes")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Size of data section in bytes")); /* data_off */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_HEX); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Offset to the start of the data section")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Offset to the start of the data section")); g_object_unref(G_OBJECT(content)); diff --git a/plugins/readdex/ids.c b/plugins/readdex/ids.c index c6bef48..1b4e623 100644 --- a/plugins/readdex/ids.c +++ b/plugins/readdex/ids.c @@ -57,7 +57,6 @@ bool annotate_dex_string_ids(const GDexFormat *format, GtkStatusStack *status) vmpa2t pos; /* Tête de lecture des symboles*/ activity_id_t msg; /* Message de progression */ uint32_t i; /* Boucle de parcours */ - vmpa2t start; /* Localisation des symboles */ GArchInstruction *instr; /* Instruction décodée */ GArchOperand *operand; /* Opérande à venir modifier */ GDbComment *comment; /* Définition de commentaire */ @@ -65,6 +64,7 @@ bool annotate_dex_string_ids(const GDexFormat *format, GtkStatusStack *status) char *text; /* Texte constant à insérer */ phys_t loc; /* Localisation physique */ vmpa2t item_pos; /* Position d'un élément */ + vmpa2t start; /* Sauvagarde d'une position */ uleb128_t length; /* Taille de la chaîne en cours*/ MemoryDataSize leb_size; /* Taille de la taille */ @@ -83,14 +83,13 @@ bool annotate_dex_string_ids(const GDexFormat *format, GtkStatusStack *status) { /* Saut vers la définition */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_HEX); asprintf(&text, _("Offset for string item #%u/%u"), i, header->string_ids_size - 1); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); @@ -119,13 +118,12 @@ bool annotate_dex_string_ids(const GDexFormat *format, GtkStatusStack *status) SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("String length")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("String length")); /* Description de la chaîne : contenu */ if (length > 0) { - copy_vmpa(&start, &item_pos); instr = g_raw_instruction_new_array(content, MDS_8_BITS, length, &item_pos, endian); g_raw_instruction_mark_as_string(G_RAW_INSTRUCTION(instr), true); @@ -168,7 +166,6 @@ bool annotate_dex_type_ids(const GDexFormat *format, GtkStatusStack *status) vmpa2t pos; /* Tête de lecture des symboles*/ activity_id_t msg; /* Message de progression */ uint32_t i; /* Boucle de parcours */ - vmpa2t start; /* Localisation des symboles */ GArchInstruction *instr; /* Instruction décodée */ GArchOperand *operand; /* Opérande à venir modifier */ GDbComment *comment; /* Définition de commentaire */ @@ -188,14 +185,13 @@ bool annotate_dex_type_ids(const GDexFormat *format, GtkStatusStack *status) for (i = 0; i < header->type_ids_size; i++) { - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); asprintf(&text, _("Index for the descriptor string of this type")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); @@ -236,7 +232,6 @@ bool annotate_dex_proto_ids(const GDexFormat *format, GtkStatusStack *status) vmpa2t pos; /* Tête de lecture des symboles*/ activity_id_t msg; /* Message de progression */ uint32_t i; /* Boucle de parcours */ - vmpa2t start; /* Localisation des symboles */ GArchInstruction *instr; /* Instruction décodée */ GArchOperand *operand; /* Opérande à venir modifier */ GDbComment *comment; /* Définition de commentaire */ @@ -258,14 +253,13 @@ bool annotate_dex_proto_ids(const GDexFormat *format, GtkStatusStack *status) { /* shorty_idx */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); asprintf(&text, _("Index for the short-form descriptor string of this prototype")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); @@ -274,27 +268,25 @@ bool annotate_dex_proto_ids(const GDexFormat *format, GtkStatusStack *status) /* return_type_idx */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); asprintf(&text, _("Index for the return type of this prototype")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); /* parameters_off */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); asprintf(&text, _("Offset to the list of parameter types for this prototype")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); @@ -332,7 +324,6 @@ bool annotate_dex_field_ids(const GDexFormat *format, GtkStatusStack *status) vmpa2t pos; /* Tête de lecture des symboles*/ activity_id_t msg; /* Message de progression */ uint32_t i; /* Boucle de parcours */ - vmpa2t start; /* Localisation des symboles */ GArchInstruction *instr; /* Instruction décodée */ GArchOperand *operand; /* Opérande à venir modifier */ GDbComment *comment; /* Définition de commentaire */ @@ -354,14 +345,13 @@ bool annotate_dex_field_ids(const GDexFormat *format, GtkStatusStack *status) { /* class_idx */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_16_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); asprintf(&text, _("Index for the definer of this field")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); @@ -370,27 +360,25 @@ bool annotate_dex_field_ids(const GDexFormat *format, GtkStatusStack *status) /* type_idx */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_16_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); asprintf(&text, _("Index for the type of this field")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); /* name_idx */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); asprintf(&text, _("Index for the name of this field")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); @@ -428,7 +416,6 @@ bool annotate_dex_method_ids(const GDexFormat *format, GtkStatusStack *status) vmpa2t pos; /* Tête de lecture des symboles*/ uint32_t i; /* Boucle de parcours */ activity_id_t msg; /* Message de progression */ - vmpa2t start; /* Localisation des symboles */ GArchInstruction *instr; /* Instruction décodée */ GArchOperand *operand; /* Opérande à venir modifier */ GDbComment *comment; /* Définition de commentaire */ @@ -450,14 +437,13 @@ bool annotate_dex_method_ids(const GDexFormat *format, GtkStatusStack *status) { /* class_idx */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_16_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); asprintf(&text, _("Index for the definer of this field")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); @@ -466,27 +452,25 @@ bool annotate_dex_method_ids(const GDexFormat *format, GtkStatusStack *status) /* proto_idx */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_16_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); asprintf(&text, _("Index for the prototype of this method")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); /* name_idx */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); asprintf(&text, _("Index for the name of this method")); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); free(text); diff --git a/plugins/readelf/header.c b/plugins/readelf/header.c index 8d9309e..4301cc2 100644 --- a/plugins/readelf/header.c +++ b/plugins/readelf/header.c @@ -48,7 +48,6 @@ bool annotate_elf_header(GElfFormat *format) const elf_header *header; /* En-tête principale */ SourceEndian endian; /* Boutisme utilisé */ vmpa2t pos; /* Tête de lecture des symboles*/ - vmpa2t start; /* Localisation des symboles */ GArchInstruction *instr; /* Instruction décodée */ GArchOperand *operand; /* Opérande à venir modifier */ GDbComment *comment; /* Définition de commentaire */ @@ -65,14 +64,13 @@ bool annotate_elf_header(GElfFormat *format) /* ELFMAG (0) */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_8_BITS, 4, &pos, endian); SET_IMM_DISPLAY(instr, operand, 1, IOD_CHAR); SET_IMM_DISPLAY(instr, operand, 2, IOD_CHAR); SET_IMM_DISPLAY(instr, operand, 3, IOD_CHAR); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("ELF magic number")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("ELF magic number")); /* EI_CLASS (4) */ @@ -92,12 +90,11 @@ bool annotate_elf_header(GElfFormat *format) break; } - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_8_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); /* EI_DATA (5) */ @@ -117,12 +114,11 @@ bool annotate_elf_header(GElfFormat *format) break; } - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_8_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); /* EI_VERSION (6) */ @@ -139,12 +135,11 @@ bool annotate_elf_header(GElfFormat *format) break; } - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_8_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); /* EI_OSABI (7) */ @@ -197,30 +192,27 @@ bool annotate_elf_header(GElfFormat *format) break; } - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_8_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); /* EI_ABIVERSION (8) */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_8_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("ABI version")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("ABI version")); /* Padding */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_8_BITS, 7, &pos, endian); g_raw_instruction_mark_as_padding(G_RAW_INSTRUCTION(instr), true); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Padding")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Padding")); /* Champ "e_type" */ @@ -252,12 +244,11 @@ bool annotate_elf_header(GElfFormat *format) break; } - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_16_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); /* Champ "e_machine" */ @@ -344,44 +335,39 @@ bool annotate_elf_header(GElfFormat *format) default: text = _("Architecture: unknown"); break; } - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_16_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); /* Champ "e_version" */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Object file version")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Object file version")); if (header->hdr32.e_ident[EI_CLASS] == ELFCLASS32) { /* Champ "e_entry" */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Entry point virtual address")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Entry point virtual address")); /* Champ "e_phoff" */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Program header table file offset")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Program header table file offset")); /* Champ "e_shoff" */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Section header table file offset")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Section header table file offset")); } @@ -389,24 +375,21 @@ bool annotate_elf_header(GElfFormat *format) { /* Champ "e_entry" */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_64_BITS, 1, &pos, endian); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Entry point virtual address")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Entry point virtual address")); /* Champ "e_phoff" */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_64_BITS, 1, &pos, endian); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Program header table file offset")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Program header table file offset")); /* Champ "e_shoff" */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_64_BITS, 1, &pos, endian); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Section header table file offset")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Section header table file offset")); } @@ -414,66 +397,59 @@ bool annotate_elf_header(GElfFormat *format) /* Champ "e_flags" */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endian); //SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Processor-specific flags")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Processor-specific flags")); /* Champ "e_ehsize" */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_16_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("ELF header size in bytes")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("ELF header size in bytes")); /* Champ "e_phentsize" */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_16_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Program header table entry size")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Program header table entry size")); /* Champ "e_phnum" */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_16_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Program header table entry count")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Program header table entry count")); /* Champ "e_shentsize" */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_16_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Section header table entry size")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Section header table entry size")); /* Champ "e_shnum" */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_16_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Section header table entry count")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Section header table entry count")); /* Champ "e_shstrndx" */ - copy_vmpa(&start, &pos); instr = g_raw_instruction_new_array(content, MDS_16_BITS, 1, &pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Section header string table index")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Section header string table index")); g_object_unref(G_OBJECT(content)); diff --git a/plugins/readelf/program.c b/plugins/readelf/program.c index fffb495..eb3bfeb 100644 --- a/plugins/readelf/program.c +++ b/plugins/readelf/program.c @@ -57,7 +57,6 @@ static bool annotate_elf_program_header(GElfFormat *format, SourceEndian endian, GBinContent *content; /* Contenu binaire à lire */ ImmOperandDisplay disp; /* Afficahge de valeur */ const char *text; /* Texte constant à insérer */ - vmpa2t start; /* Localisation des symboles */ GArchInstruction *instr; /* Instruction décodée */ GArchOperand *operand; /* Opérande à venir modifier */ GDbComment *comment; /* Définition de commentaire */ @@ -139,49 +138,43 @@ static bool annotate_elf_program_header(GElfFormat *format, SourceEndian endian, break; } - copy_vmpa(&start, pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, endian); SET_IMM_DISPLAY(instr, operand, 0, disp); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); if (format->is_32b) { /* Champ "p_offset" */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, endian); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Segment file offset")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Segment file offset")); /* Champ "p_vaddr" */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, endian); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Segment virtual address")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Segment virtual address")); /* Champ "p_paddr" */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, endian); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Segment physical address")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Segment physical address")); /* Champ "p_filesz" */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, endian); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Segment size in file")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Segment size in file")); /* Champ "p_memsz" */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, endian); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Segment size in memory")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Segment size in memory")); /* Champ "p_flags" */ @@ -215,19 +208,17 @@ static bool annotate_elf_program_header(GElfFormat *format, SourceEndian endian, if (!filled) dtext = stradd(dtext, _("none")); - copy_vmpa(&start, pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, endian); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, dtext); + ADD_RAW_AS_SYM(format, symbol, instr, comment, dtext); free(dtext); /* Champ "p_align" */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, endian); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Segment alignment")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Segment alignment")); } else @@ -264,54 +255,47 @@ static bool annotate_elf_program_header(GElfFormat *format, SourceEndian endian, if (!filled) dtext = stradd(dtext, _("none")); - copy_vmpa(&start, pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, endian); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, dtext); + ADD_RAW_AS_SYM(format, symbol, instr, comment, dtext); free(dtext); /* Champ "p_offset" */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_array(content, MDS_64_BITS, 1, pos, endian); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Segment file offset")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Segment file offset")); /* Champ "p_vaddr" */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_array(content, MDS_64_BITS, 1, pos, endian); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Segment virtual address")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Segment virtual address")); /* Champ "p_paddr" */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_array(content, MDS_64_BITS, 1, pos, endian); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Segment physical address")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Segment physical address")); /* Champ "p_filesz" */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_array(content, MDS_64_BITS, 1, pos, endian); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Segment size in file")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Segment size in file")); /* Champ "p_memsz" */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_array(content, MDS_64_BITS, 1, pos, endian); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Segment size in memory")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Segment size in memory")); /* Champ "p_align" */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_array(content, MDS_64_BITS, 1, pos, endian); - ADD_RAW_AS_SYM(format, symbol, pos, instr, comment, _("Segment alignment")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Segment alignment")); } diff --git a/plugins/readelf/section.c b/plugins/readelf/section.c index 815bac9..ed22069 100644 --- a/plugins/readelf/section.c +++ b/plugins/readelf/section.c @@ -60,7 +60,6 @@ static bool annotate_elf_section_header(GElfFormat *format, SourceEndian endian, const char *secname; /* Nom d'une section analysée */ ImmOperandDisplay disp; /* Afficahge de valeur */ const char *text; /* Texte constant à insérer */ - vmpa2t start; /* Localisation des symboles */ GArchInstruction *instr; /* Instruction décodée */ GArchOperand *operand; /* Opérande à venir modifier */ GDbComment *comment; /* Définition de commentaire */ @@ -87,12 +86,11 @@ static bool annotate_elf_section_header(GElfFormat *format, SourceEndian endian, dtext = stradd(dtext, "'"); } - copy_vmpa(&start, pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, dtext); + ADD_RAW_AS_SYM(format, symbol, instr, comment, dtext); free(dtext); @@ -214,12 +212,11 @@ static bool annotate_elf_section_header(GElfFormat *format, SourceEndian endian, break; } - copy_vmpa(&start, pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, endian); SET_IMM_DISPLAY(instr, operand, 0, disp); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, text); + ADD_RAW_AS_SYM(format, symbol, instr, comment, text); /* Champ "sh_flags"... */ @@ -269,123 +266,109 @@ static bool annotate_elf_section_header(GElfFormat *format, SourceEndian endian, { /* Champ "sh_flags" (suite) */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, endian); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, dtext); + ADD_RAW_AS_SYM(format, symbol, instr, comment, dtext); free(dtext); /* Champ "sh_addr" */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, endian); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Section virtual addr at execution")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Section virtual addr at execution")); /* Champ "sh_offset" */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, endian); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Section file offset")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Section file offset")); /* Champ "sh_size" */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Section size in bytes")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Section size in bytes")); } else { /* Champ "sh_flags" (suite) */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_array(content, MDS_64_BITS, 1, pos, endian); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, dtext); + ADD_RAW_AS_SYM(format, symbol, instr, comment, dtext); free(dtext); /* Champ "sh_addr" */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_array(content, MDS_64_BITS, 1, pos, endian); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Section virtual addr at execution")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Section virtual addr at execution")); /* Champ "sh_offset" */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_array(content, MDS_64_BITS, 1, pos, endian); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Section file offset")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Section file offset")); /* Champ "sh_size" */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_array(content, MDS_64_BITS, 1, pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Section size in bytes")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Section size in bytes")); } /* Champ "sh_link" */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, endian); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Link to another section")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Link to another section")); /* Champ "sh_info" */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, endian); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Additional section information")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Additional section information")); if (format->is_32b) { /* Champ "sh_addralign" */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, endian); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Section alignment")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Section alignment")); /* Champ "sh_entsize" */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Entry size if section holds table")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Entry size if section holds table")); } else { /* Champ "sh_addralign" */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_array(content, MDS_64_BITS, 1, pos, endian); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Section alignment")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Section alignment")); /* Champ "sh_entsize" */ - copy_vmpa(&start, pos); instr = g_raw_instruction_new_array(content, MDS_64_BITS, 1, pos, endian); SET_IMM_DISPLAY(instr, operand, 0, IOD_DEC); - ADD_RAW_AS_SYM(format, symbol, &start, instr, comment, _("Entry size if section holds table")); + ADD_RAW_AS_SYM(format, symbol, instr, comment, _("Entry size if section holds table")); } diff --git a/src/arch/arm/v7/fetch.c b/src/arch/arm/v7/fetch.c index 7296717..3fa6bbe 100644 --- a/src/arch/arm/v7/fetch.c +++ b/src/arch/arm/v7/fetch.c @@ -462,7 +462,7 @@ void help_fetching_with_instruction_ldr_literal_with_orig(GArchInstruction *inst vmpa2_virt_to_string(get_mrange_addr(range), MDS_32_BITS, loc, NULL); snprintf(name, name_len, _("Value used @ %s"), loc); - ADD_RAW_AS_SYM(G_BIN_FORMAT(format), symbol, &sym_addr, sym_instr, comment, name); + ADD_RAW_AS_SYM(G_BIN_FORMAT(format), symbol, sym_instr, comment, name); free(name); diff --git a/src/format/symbol.c b/src/format/symbol.c index fb198d9..48f3dbb 100644 --- a/src/format/symbol.c +++ b/src/format/symbol.c @@ -598,6 +598,20 @@ GArchInstruction *g_binary_symbol_get_instruction(const GBinSymbol *symbol) void g_binary_symbol_set_comment(GBinSymbol *symbol, GDbComment *comment) { +#ifndef NDEBUG + const vmpa2t *saddr; /* Adresse du symbole */ + const vmpa2t *caddr; /* Adresse du commentaire */ +#endif + +#ifndef NDEBUG + + saddr = get_mrange_addr(g_binary_symbol_get_range(symbol)); + caddr = g_db_comment_get_address(comment); + + assert(cmp_vmpa(saddr, caddr) == 0); + +#endif + symbol->comment = comment; } diff --git a/src/format/symbol.h b/src/format/symbol.h index ce452f1..8432d8d 100644 --- a/src/format/symbol.h +++ b/src/format/symbol.h @@ -136,10 +136,12 @@ GDbComment *g_binary_symbol_get_comment(const GBinSymbol *); } \ while (0) -#define ADD_RAW_AS_SYM(_fmt, _sym, _pos, _ins, _cmt, _txt) \ +#define ADD_RAW_AS_SYM(_fmt, _sym, _ins, _cmt, _txt) \ do \ { \ - _cmt = g_db_comment_new_inlined(_pos, BLF_HAS_CODE, _txt, false); \ + const vmpa2t *__addr; \ + __addr = get_mrange_addr(g_arch_instruction_get_range(_ins)); \ + _cmt = g_db_comment_new_inlined(__addr, BLF_HAS_CODE, _txt, false); \ g_db_item_set_volatile(G_DB_ITEM(_cmt), true); \ _sym = g_binary_symbol_new(STP_DATA); \ g_binary_symbol_attach_instruction(_sym, _ins); \ -- cgit v0.11.2-87-g4458