Skip to content

Commit

Permalink
Add radiff2 -a and -b flags
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed Mar 19, 2014
1 parent 44a0774 commit a727663
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
22 changes: 20 additions & 2 deletions binr/radiff2/radiff2.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,11 @@ static RCore* opencore(const char *f) {
}

static int show_help(int v) {
printf ("Usage: radiff2 [-cCdrspOv] [-g sym] [-t %%] [file] [file]\n");
printf ("Usage: radiff2 [-abcCdrspOv] [-g sym] [-t %%] [file] [file]\n");
if (v) printf (
// " -l diff lines of text\n"
" -a [arch] specify architecture plugin to use (x86, arm, ..)\n"
" -b [bits] specify register size for arch (16 (thumb), 32, 64, ..)\n"
" -c count of changes\n"
" -C graphdiff code (columns: off-A, match-ratio, off-B)\n"
" -d use delta diffing\n"
Expand Down Expand Up @@ -114,6 +116,8 @@ int main(int argc, char **argv) {
const char *addr = NULL;
RCore *c, *c2;
RDiff *d;
const char *arch = NULL;
int bits = 0;
char *file, *file2;
ut8 *bufa, *bufb;
int o, sza, szb, rad = 0, delta = 0;
Expand All @@ -122,8 +126,14 @@ int main(int argc, char **argv) {
int threshold = -1;
double sim;

while ((o = getopt (argc, argv, "Cpg:Orhcdsvxt:")) != -1) {
while ((o = getopt (argc, argv, "a:b:Cpg:Orhcdsvxt:")) != -1) {
switch (o) {
case 'a':
arch = optarg;
break;
case 'b':
bits = atoi (optarg);
break;
case 'p':
useva = R_FALSE;
break;
Expand Down Expand Up @@ -184,6 +194,14 @@ int main(int argc, char **argv) {
eprintf ("Cannot open '%s'\n", file2);
return 1;
}
if (arch) {
r_config_set (c->config, "asm.arch", arch);
r_config_set (c2->config, "asm.arch", arch);
}
if (bits) {
r_config_set_i (c->config, "asm.bits", bits);
r_config_set_i (c2->config, "asm.bits", bits);
}
r_anal_diff_setup_i (c->anal, diffops, threshold, threshold);
r_anal_diff_setup_i (c2->anal, diffops, threshold, threshold);
r_core_gdiff (c, c2);
Expand Down
4 changes: 2 additions & 2 deletions libr/bin/p/bin_bios.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* radare - LGPL - Copyright 2013 - pancake */
/* radare - LGPL - Copyright 2013-2014 - pancake */

#include <r_types.h>
#include <r_util.h>
Expand Down Expand Up @@ -95,7 +95,7 @@ static RList* entries(RBinFile *arch) {

struct r_bin_plugin_t r_bin_plugin_bios = {
.name = "bios",
.desc = "filesystem bin plugin",
.desc = "BIOS bin plugin",
.license = "LGPL",
.init = NULL,
.fini = NULL,
Expand Down
6 changes: 5 additions & 1 deletion man/radiff2.1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ radiff2 \- unified binary diffing utility
.Pp
.Sh SYNOPSIS
.Nm radiff2
.Op Fl cCOdrspvh
.Op Fl abcCOdrspvh
.Op Fl t Ar 0-100
.Op Fl g Ar sym
.Ar file1
Expand All @@ -14,6 +14,10 @@ radiff2 \- unified binary diffing utility
radiff2 implements many binary diffing algorithms for data and code.
.Pp
.Bl -tag -width Fl
.It Fl a
Specify architecture (x86, arm, ..)
.It Fl b
Select register size bits for given arch
.It Fl c
Count number of differences.
.It Fl C
Expand Down

0 comments on commit a727663

Please sign in to comment.