diff options
Diffstat (limited to 'src/binary.c')
-rw-r--r-- | src/binary.c | 99 |
1 files changed, 59 insertions, 40 deletions
diff --git a/src/binary.c b/src/binary.c index 8de0bdb..f9cc906 100644 --- a/src/binary.c +++ b/src/binary.c @@ -351,6 +351,10 @@ void fill_snippet(GtkSnippet *snippet, GtkWidget *panel) asm_processor *proc; asm_instr *instr; + bin_part **parts; + size_t parts_count; + + char **comments; uint64_t *offsets; size_t comments_count; @@ -373,6 +377,8 @@ void fill_snippet(GtkSnippet *snippet, GtkWidget *panel) size_t i; + size_t k; + proc = create_x86_processor(); pos = 0; @@ -388,11 +394,11 @@ void fill_snippet(GtkSnippet *snippet, GtkWidget *panel) if (bin_data == NULL) return; + format = load_elf(bin_data, length); dformat = load_dwarf(bin_data, length, format); - //comments_count = get_dwarf_comments(dformat, &comments, &offsets); comments = NULL; @@ -411,60 +417,83 @@ void fill_snippet(GtkSnippet *snippet, GtkWidget *panel) - find_exe_section(format, ".text", &pos, &len, &base); + parts = get_elf_default_code_parts(format, &parts_count); - /*find_line_info(bin_data, &len);*/ - - /* - printf("Exiting...\n"); - exit(0); - */ - - offset = base; - - for (i = 0; i < comments_count; i++) - if (comments_list[i]->offset >= base) break; + list = NULL; + list_len = 0; gtk_snippet_set_format(snippet, format); gtk_snippet_set_processor(snippet, proc); - gtk_snippet_add_line(snippet, create_code_line_info(offset, NULL, "Simple HelloWorld !")); + for (i = 0; i < parts_count; i++) + { + get_bin_part_values(parts[i], &pos, &len, &base); - start = pos; - pos = 0; + /*find_line_info(bin_data, &len);*/ - list = NULL; - list_len = 0; + /* + printf("Exiting...\n"); + exit(0); + */ - while (pos < len) - { - offset = base + pos; + offset = base; - /* Si on a un commentaire pour cette ligne... */ - if (i < comments_count && comments_list[i]->offset == offset) - { - list = (code_line_info **)realloc(list, ++list_len * sizeof(code_line_info *)); - list[list_len - 1] = comments_list[i++]; - } + for (k = 0; k < comments_count; k++) + if (comments_list[k]->offset >= base) break; - instr = decode_instruction(proc, &bin_data[start], &pos, len, offset); - item = create_code_line_info(offset, instr, NULL); + item = create_code_line_info(offset, NULL, "Simple HelloWorld !"); list = (code_line_info **)realloc(list, ++list_len * sizeof(code_line_info *)); list[list_len - 1] = item; - //gtk_snippet_add_line(snippet, offset, instr, NULL); + start = pos; + pos = 0; + + while (pos < len) + { + offset = base + pos; + + /* Si on a un commentaire pour cette ligne... */ + if (k < comments_count && comments_list[k]->offset == offset) + { + list = (code_line_info **)realloc(list, ++list_len * sizeof(code_line_info *)); + list[list_len - 1] = comments_list[k++]; + } + + + instr = decode_instruction(proc, &bin_data[start], &pos, len, offset); + + + item = create_code_line_info(offset, instr, NULL); + + list = (code_line_info **)realloc(list, ++list_len * sizeof(code_line_info *)); + list[list_len - 1] = item; + + //gtk_snippet_add_line(snippet, offset, instr, NULL); + + + } + + + /**** + ret = munmap(bin_data, length); + ****/ + + /* + gtk_snippet_build_content(snippet); + */ + } for (i = 0; i < list_len; i++) @@ -473,16 +502,6 @@ void fill_snippet(GtkSnippet *snippet, GtkWidget *panel) /* TODO: free() */ } - - /**** - ret = munmap(bin_data, length); - ****/ - - /* - gtk_snippet_build_content(snippet); - */ - - handle_new_exe_on_symbols_panel(panel, format); } |