Better ARM analysis, Fix blockread in V[0-9]
This commit is contained in:
parent
b9177a1bd9
commit
6806c11792
8 changed files with 103 additions and 64 deletions
|
|
@ -1,4 +1,4 @@
|
|||
/* radare - LGPL - Copyright 2007-2012 - pancake */
|
||||
/* radare - LGPL - Copyright 2007-2013 - pancake */
|
||||
|
||||
#include <string.h>
|
||||
#include <r_types.h>
|
||||
|
|
@ -277,10 +277,22 @@ static int arm_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len)
|
|||
}
|
||||
}
|
||||
|
||||
if (IS_EXITPOINT (code[i])) {
|
||||
if (
|
||||
( ((code[i]&0xff)>=0x10 && (code[i]&0xff)<0x20)
|
||||
) && ((code[i]&0xffffff00) == 0xe12fff00)
|
||||
||
|
||||
IS_EXITPOINT (code[i])) {
|
||||
//if (IS_EXITPOINT (code[i])) {
|
||||
b=data;
|
||||
branch_dst_addr = disarm_branch_offset (addr, b[0] | (b[1]<<8) | (b[2]<<16)); //code[i]&0x00FFFFFF);
|
||||
op->ref = 0;
|
||||
if (
|
||||
( ((code[i]&0xff)>=0x10 && (code[i]&0xff)<0x20)
|
||||
) && ((code[i]&0xffffff00) == 0xe12fff00)
|
||||
) {
|
||||
op->type = R_ANAL_OP_TYPE_UJMP;
|
||||
op->eob = 1;
|
||||
} else
|
||||
if (IS_BRANCHL (code[i])) {
|
||||
if (IS_BRANCH (code[i])) {
|
||||
op->type = R_ANAL_OP_TYPE_CALL;
|
||||
|
|
@ -294,7 +306,6 @@ static int arm_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len)
|
|||
} else if (IS_BRANCH (code[i])) {
|
||||
if (IS_CONDAL (code[i])) {
|
||||
op->type = R_ANAL_OP_TYPE_JMP;
|
||||
//op->type = R_ANAL_OP_TYPE_NOP;
|
||||
op->jump = branch_dst_addr;
|
||||
op->fail = UT64_MAX;
|
||||
op->eob = 1;
|
||||
|
|
@ -306,8 +317,10 @@ static int arm_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len)
|
|||
}
|
||||
} else {
|
||||
//unknown jump o return
|
||||
op->type = R_ANAL_OP_TYPE_UJMP;
|
||||
op->eob = 1;
|
||||
//op->type = R_ANAL_OP_TYPE_UJMP;
|
||||
//op->type = R_ANAL_OP_TYPE_NOP;
|
||||
// op->eob = 1;
|
||||
op->eob = 0;
|
||||
}
|
||||
}
|
||||
//op->jump = arminsn->jmp;
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ static int is_data_section(RBinArch *a, RBinSection *s) {
|
|||
RBinObject *o = a->o;
|
||||
if (strstr (o->info->bclass, "MACH0") && strstr (s->name, "_cstring")) // OSX
|
||||
return 1;
|
||||
if (strstr (o->info->bclass, "ELF") && strstr (s->name, "data")) // LINUX
|
||||
if (strstr (o->info->bclass, "ELF") && strstr (s->name, "data") && !strstr (s->name, "rel")) // LINUX
|
||||
return 1;
|
||||
#define X 1
|
||||
#define ROW (4|2)
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ static int Elf_(r_bin_elf_init_shdr)(struct Elf_(r_bin_elf_obj_t) *bin) {
|
|||
#endif
|
||||
bin->ehdr.e_shnum);
|
||||
if (len == -1) {
|
||||
eprintf ("Error: read (shdr)\n");
|
||||
eprintf ("Error: read (shdr) at 0x%"PFMT64x"\n", (ut64) bin->ehdr.e_shoff);
|
||||
R_FREE (bin->shdr);
|
||||
return R_FALSE;
|
||||
}
|
||||
|
|
@ -94,11 +94,11 @@ static int Elf_(r_bin_elf_init_strtab)(struct Elf_(r_bin_elf_obj_t) *bin) {
|
|||
int sz;
|
||||
if (bin->strtab || !bin->shdr) return R_FALSE;
|
||||
bin->shstrtab_section =
|
||||
bin->strtab_section = &bin->shdr[bin->ehdr.e_shstrndx];
|
||||
bin->strtab_section = &bin->shdr[bin->ehdr.e_shstrndx];
|
||||
if (bin->strtab_section == NULL)
|
||||
return R_FALSE;
|
||||
bin->shstrtab_size =
|
||||
bin->strtab_size = bin->strtab_section->sh_size;
|
||||
bin->strtab_size = bin->strtab_section->sh_size;
|
||||
sz = sizeof (struct r_bin_elf_section_t) + bin->strtab_section->sh_size;
|
||||
if ((bin->strtab = (char *)malloc (sz)) == NULL) {
|
||||
perror ("malloc");
|
||||
|
|
@ -107,9 +107,11 @@ static int Elf_(r_bin_elf_init_strtab)(struct Elf_(r_bin_elf_obj_t) *bin) {
|
|||
}
|
||||
memset (bin->strtab, 0, sz);
|
||||
bin->shstrtab = bin->strtab;
|
||||
//bin->strtab_section->sh_offset = 0;
|
||||
if (r_buf_read_at (bin->b, bin->strtab_section->sh_offset, (ut8*)bin->strtab,
|
||||
bin->strtab_section->sh_size) == -1) {
|
||||
eprintf ("Error: read (strtab)\n");
|
||||
eprintf ("Error: read (strtab) at 0x%"PFMT64x"\n",
|
||||
(ut64) bin->strtab_section->sh_offset);
|
||||
R_FREE (bin->strtab);
|
||||
bin->shstrtab = NULL;
|
||||
return R_FALSE;
|
||||
|
|
@ -185,7 +187,7 @@ static int Elf_(r_bin_elf_init)(struct Elf_(r_bin_elf_obj_t) *bin) {
|
|||
}
|
||||
Elf_(r_bin_elf_init_phdr) (bin);
|
||||
//if (!Elf_(r_bin_elf_init_phdr) (bin))
|
||||
//eprintf ("Warning: Cannot initialize program headers\n");
|
||||
// eprintf ("Warning: Cannot initialize program headers\n");
|
||||
if (!Elf_(r_bin_elf_init_shdr) (bin))
|
||||
eprintf ("Warning: Cannot initialize section headers\n");
|
||||
if (!Elf_(r_bin_elf_init_strtab) (bin))
|
||||
|
|
@ -549,9 +551,9 @@ char* Elf_(r_bin_elf_get_elf_class)(struct Elf_(r_bin_elf_obj_t) *bin) {
|
|||
|
||||
int Elf_(r_bin_elf_get_bits)(struct Elf_(r_bin_elf_obj_t) *bin) {
|
||||
switch (bin->ehdr.e_ident[EI_CLASS]) {
|
||||
case ELFCLASSNONE: return 0;
|
||||
case ELFCLASS32: return 32;
|
||||
case ELFCLASS64: return 64;
|
||||
case ELFCLASSNONE:
|
||||
default: return 32; // defaults
|
||||
}
|
||||
}
|
||||
|
|
@ -863,7 +865,7 @@ struct r_bin_elf_symbol_t* Elf_(r_bin_elf_get_symbols)(struct Elf_(r_bin_elf_obj
|
|||
ut64 sym_offset = 0, data_offset = 0, toffset;
|
||||
int shdr_size, tsize, nsym, ret_ctr, i, j, k, len;
|
||||
|
||||
if (!bin->shdr || bin->ehdr.e_shnum == 0)
|
||||
if (!bin->shdr || bin->ehdr.e_shnum == 0 || bin->ehdr.e_shnum == 0xffff)
|
||||
return NULL;
|
||||
if (bin->ehdr.e_type == ET_REL) {
|
||||
// XXX: we must obey shndx here
|
||||
|
|
@ -873,11 +875,9 @@ struct r_bin_elf_symbol_t* Elf_(r_bin_elf_get_symbols)(struct Elf_(r_bin_elf_obj
|
|||
data_offset = 0;
|
||||
}
|
||||
shdr_size = bin->ehdr.e_shnum * sizeof (Elf_(Shdr));
|
||||
for (i = 0; i < bin->ehdr.e_shnum; i++)
|
||||
if ((type == R_BIN_ELF_IMPORTS &&
|
||||
bin->shdr[i].sh_type == (bin->ehdr.e_type == ET_REL ? SHT_SYMTAB : SHT_DYNSYM)) ||
|
||||
(type == R_BIN_ELF_SYMBOLS &&
|
||||
bin->shdr[i].sh_type == (Elf_(r_bin_elf_get_stripped) (bin) ? SHT_DYNSYM : SHT_SYMTAB))) {
|
||||
for (i = 0; i < bin->ehdr.e_shnum; i++) {
|
||||
if ((type == R_BIN_ELF_IMPORTS && bin->shdr[i].sh_type == (bin->ehdr.e_type == ET_REL ? SHT_SYMTAB : SHT_DYNSYM)) ||
|
||||
(type == R_BIN_ELF_SYMBOLS && bin->shdr[i].sh_type == (Elf_(r_bin_elf_get_stripped) (bin) ? SHT_DYNSYM : SHT_SYMTAB))) {
|
||||
if (bin->shdr[i].sh_link > shdr_size) {
|
||||
/* oops. fix out of range pointers */
|
||||
continue;
|
||||
|
|
@ -989,6 +989,7 @@ struct r_bin_elf_symbol_t* Elf_(r_bin_elf_get_symbols)(struct Elf_(r_bin_elf_obj
|
|||
ret[ret_ctr].last = 1; // ugly dirty hack :D
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* radare - LGPL - Copyright 2009-2012 - nibble */
|
||||
/* radare - LGPL - Copyright 2009-2013 - nibble */
|
||||
|
||||
#include <r_types.h>
|
||||
#include <r_util.h>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* radare - LGPL - Copyright 2009-2013 - nibble, pancake, xvilka */
|
||||
/* radare - LGPL - Copyright 2013 - xvilka */
|
||||
|
||||
#include <r_types.h>
|
||||
#include <r_util.h>
|
||||
|
|
|
|||
|
|
@ -215,6 +215,7 @@ R_API int r_core_visual_cmd(RCore *core, int ch) {
|
|||
if (ch>='0'&& ch<='9') {
|
||||
r_io_sundo_push (core->io, core->offset);
|
||||
r_core_seek (core, core->asmqjmps[ch-'0'], 1);
|
||||
r_core_block_read (core, 1);
|
||||
} else
|
||||
switch (ch) {
|
||||
case 9: // tab
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 7.1 KiB After Width: | Height: | Size: 7.1 KiB |
|
|
@ -7,54 +7,78 @@
|
|||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.1"
|
||||
width="500"
|
||||
height="300"
|
||||
id="svg3004"
|
||||
xml:space="preserve"><metadata
|
||||
xml:space="preserve"
|
||||
inkscape:version="0.48.1 r9760"
|
||||
sodipodi:docname="r2pow.svg"><sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="640"
|
||||
inkscape:window-height="480"
|
||||
id="namedview16"
|
||||
showgrid="false"
|
||||
inkscape:zoom="0.95"
|
||||
inkscape:cx="250"
|
||||
inkscape:cy="150"
|
||||
inkscape:window-x="64"
|
||||
inkscape:window-y="237"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="svg3004" /><metadata
|
||||
id="metadata3010"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><defs
|
||||
id="defs3008"><clipPath
|
||||
id="clipPath3018"><path
|
||||
d="m 0,841.89 1190.55,0 L 1190.55,0 0,0 0,841.89 z"
|
||||
id="path3020" /></clipPath></defs><g
|
||||
transform="matrix(1.25,0,0,-1.25,0,299.99995)"
|
||||
id="g3012"><rect
|
||||
width="282.75601"
|
||||
height="134.64572"
|
||||
ry="9.6606798"
|
||||
x="19.842533"
|
||||
y="-203.38586"
|
||||
transform="scale(1,-1)"
|
||||
id="rect2988"
|
||||
style="fill:#000000;fill-opacity:1;stroke:none" /><rect
|
||||
width="269.29141"
|
||||
height="94.251999"
|
||||
ry="5.0904036"
|
||||
x="26.22048"
|
||||
y="-167.95279"
|
||||
transform="scale(1,-1)"
|
||||
id="rect3788"
|
||||
style="fill:#ffffff;fill-opacity:1;stroke:none" /><g
|
||||
transform="matrix(0.67776418,0,0,0.67776418,-361.9352,-432.25669)"
|
||||
id="g4037"><path
|
||||
d="m 717.48563,860.61081 0,-95.251 11.881,0 0,-5.379 -82.928,0 0,5.379 15.912,0 0,51.547 c 0,9.188 0.673,17.258 -2.463,25.998 -0.673,2.241 -7.394,15.015 -10.758,9.413 0.898,-3.363 1.346,-7.172 1.346,-10.536 0,-15.013 -10.311,-24.65 -25.102,-24.65 -15.464,0 -26.221,10.757 -26.221,26.221 0,16.136 14.12,24.875 28.911,24.875 15.909,0 28.683,-8.514 36.085,-22.186 l 0.444,0 0,22.637 c 21.513,-0.673 43.254,-2.69 64.774,-2.69 l 0,-5.378 -11.881,0 z"
|
||||
id="path3492-8"
|
||||
style="fill:#231f20;fill-opacity:1;fill-rule:nonzero;stroke:none" /><path
|
||||
d="m 717.30203,814.96091 109.965,54.98 0,-109.96 -109.965,54.98 z"
|
||||
id="path3496-8"
|
||||
style="fill:#231f20;fill-opacity:1;fill-rule:nonzero;stroke:none" /><path
|
||||
d="m 827.26683,814.96091 109.959,54.98 0,-109.96 -109.959,54.98 z"
|
||||
id="path3500-9"
|
||||
style="fill:#231f20;fill-opacity:1;fill-rule:nonzero;stroke:none" /></g><text
|
||||
x="23.341743"
|
||||
y="-174.67403"
|
||||
transform="scale(1,-1)"
|
||||
id="text3790"
|
||||
xml:space="preserve"
|
||||
style="font-size:32px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;font-family:BlairMdITC TT;-inkscape-font-specification:BlairMdITC TT Bold"><tspan
|
||||
x="23.341743"
|
||||
y="-174.67403"
|
||||
id="tspan3792">Powered by</tspan></text>
|
||||
</g></svg>
|
||||
id="clipPath3018"><path
|
||||
d="m 0,841.89 1190.55,0 L 1190.55,0 0,0 0,841.89 z"
|
||||
id="path3020" /></clipPath>
|
||||
</defs><rect
|
||||
style="fill:#000000;fill-opacity:1;stroke:none"
|
||||
id="rect2988"
|
||||
y="45.76762"
|
||||
x="24.803165"
|
||||
ry="12.07585"
|
||||
height="168.30716"
|
||||
width="353.44501" /><rect
|
||||
style="fill:#ffffff;fill-opacity:1;stroke:none"
|
||||
id="rect3788"
|
||||
y="90.05896"
|
||||
x="32.7756"
|
||||
ry="6.3630047"
|
||||
height="117.815"
|
||||
width="336.61426" /><g
|
||||
id="g4037"
|
||||
transform="matrix(0.84720522,0,0,-0.84720522,-452.419,840.32081)"
|
||||
style="fill:#000000"><path
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
id="path3492-8"
|
||||
d="m 717.48563,860.61081 0,-95.251 11.881,0 0,-5.379 -82.928,0 0,5.379 15.912,0 0,51.547 c 0,9.188 0.673,17.258 -2.463,25.998 -0.673,2.241 -7.394,15.015 -10.758,9.413 0.898,-3.363 1.346,-7.172 1.346,-10.536 0,-15.013 -10.311,-24.65 -25.102,-24.65 -15.464,0 -26.221,10.757 -26.221,26.221 0,16.136 14.12,24.875 28.911,24.875 15.909,0 28.683,-8.514 36.085,-22.186 l 0.444,0 0,22.637 c 21.513,-0.673 43.254,-2.69 64.774,-2.69 l 0,-5.378 -11.881,0 z" /><path
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
id="path3496-8"
|
||||
d="m 717.30203,814.96091 109.965,54.98 0,-109.96 -109.965,54.98 z" /><path
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
id="path3500-9"
|
||||
d="m 827.26683,814.96091 109.959,54.98 0,-109.96 -109.959,54.98 z" /></g><text
|
||||
sodipodi:linespacing="125%"
|
||||
style="font-size:40px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;font-family:BlairMdITC TT;-inkscape-font-specification:BlairMdITC TT Bold"
|
||||
xml:space="preserve"
|
||||
id="text3790"
|
||||
y="81.657417"
|
||||
x="29.177179"><tspan
|
||||
id="tspan3792"
|
||||
y="81.657417"
|
||||
x="29.177179">Powered by</tspan></text>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 3.5 KiB |
Loading…
Reference in a new issue