Commit 85b2a14d authored by Julian Kranz's avatar Julian Kranz
Browse files

Gdrr CLI

Gdrr

Jgdrr
parent e0932520
......@@ -40,6 +40,11 @@ struct gdrr_sem_linear_callbacks {
gdrr_sem_linear_t *opnd);
};
struct gdrr_sem_sexpr_callbacks {
gdrr_sem_sexpr_t *(*sem_sexpr_lin)(void *closure, gdrr_sem_linear_t *this);
gdrr_sem_sexpr_t *(*sem_sexpr_cmp)(void *closure, gdrr_sem_op_cmp_t *this);
};
struct gdrr_sem_op_cmp_callbacks {
gdrr_sem_op_t *(*sem_cmpeq)(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2);
......
......@@ -21,6 +21,7 @@ struct gdrr_config {
struct gdrr_sem_address_callbacks sem_address;
struct gdrr_sem_var_callbacks sem_var;
struct gdrr_sem_linear_callbacks sem_linear;
struct gdrr_sem_sexpr_callbacks sem_sexpr;
struct gdrr_sem_op_cmp_callbacks sem_op_cmp;
struct gdrr_sem_op_callbacks sem_op;
struct gdrr_sem_stmt_callbacks sem_stmt;
......
......@@ -12,6 +12,7 @@ typedef void gdrr_sem_id_t;
typedef void gdrr_sem_address_t;
typedef void gdrr_sem_var_t;
typedef void gdrr_sem_linear_t;
typedef void gdrr_sem_sexpr_t;
typedef void gdrr_sem_op_cmp_t;
typedef void gdrr_sem_op_t;
typedef void gdrr_sem_branch_hint;
......
......@@ -20,6 +20,8 @@ static gdrr_sem_var_t *gdrr_convert_sem_var(__obj sem_var_obj,
struct gdrr_config *config);
static gdrr_sem_id_t *gdrr_convert_sem_linear(__obj sem_linear_obj,
struct gdrr_config *config);
static gdrr_sem_sexpr_t *gdrr_convert_sem_sexpr(__obj sem_sexpr_obj,
struct gdrr_config *config);
static gdrr_sem_op_cmp_t *gdrr_convert_sem_op_cmp(__obj sem_op_obj,
struct gdrr_config *config);
static gdrr_sem_op_t *gdrr_convert_sem_op(__obj sem_op_obj,
......@@ -148,6 +150,28 @@ static gdrr_sem_id_t *gdrr_convert_sem_linear(__obj sem_linear_obj,
return sem_linear;
}
static gdrr_sem_sexpr_t *gdrr_convert_sem_sexpr(__obj sem_sexpr_obj,
struct gdrr_config *config) {
gdrr_sem_sexpr_t *sem_sexpr = NULL;
__obj this = __DECON(sem_sexpr_obj);
switch(__CASETAGCON(sem_sexpr_obj)) {
case __SEM_SEXPR_LIN: {
sem_sexpr = config->callbacks.sem_sexpr.sem_sexpr_lin(config->closure,
gdrr_convert_sem_linear(this, config));
break;
}
case __SEM_SEXPR_CMP: {
sem_sexpr = config->callbacks.sem_sexpr.sem_sexpr_cmp(config->closure,
gdrr_convert_sem_op_cmp(this, config));
break;
}
}
return sem_sexpr;
}
static gdrr_sem_op_t *gdrr_convert_sem_op_cmp(__obj sem_op_cmp_obj,
struct gdrr_config *config) {
gdrr_sem_op_cmp_t *sem_op_cmp = NULL;
......@@ -420,7 +444,7 @@ static gdrr_sem_stmt_t *gdrr_convert_sem_stmt(__obj sem_stmt_obj,
__obj then_branch = __RECORD_SELECT(rec, ___then_branch);
__obj else_branch = __RECORD_SELECT(rec, ___else_branch);
sem_stmt = config->callbacks.sem_stmt.sem_ite(config->closure,
gdrr_convert_sem_linear(cond, config),
gdrr_convert_sem_sexpr(cond, config),
gdrr_convert_sem_stmts_with_config(then_branch, config),
gdrr_convert_sem_stmts_with_config(else_branch, config));
break;
......@@ -429,7 +453,7 @@ static gdrr_sem_stmt_t *gdrr_convert_sem_stmt(__obj sem_stmt_obj,
__obj cond = __RECORD_SELECT(rec, ___cond);
__obj body = __RECORD_SELECT(rec, ___body);
sem_stmt = config->callbacks.sem_stmt.sem_while(config->closure,
gdrr_convert_sem_linear(cond, config),
gdrr_convert_sem_sexpr(cond, config),
gdrr_convert_sem_stmts_with_config(body, config));
break;
}
......@@ -438,7 +462,7 @@ static gdrr_sem_stmt_t *gdrr_convert_sem_stmt(__obj sem_stmt_obj,
__obj target_true = __RECORD_SELECT(rec, ___target_true);
__obj target_false = __RECORD_SELECT(rec, ___target_false);
sem_stmt = config->callbacks.sem_stmt.sem_cbranch(config->closure,
gdrr_convert_sem_linear(cond, config),
gdrr_convert_sem_sexpr(cond, config),
gdrr_convert_sem_address(target_true, config),
gdrr_convert_sem_address(target_false, config));
break;
......
......@@ -390,48 +390,58 @@ static gdrr_sem_linear_t *sem_lin_scale(void *closure, __word imm,
return (gdrr_sem_linear_t*)ret;
}
// sem_sexpr
static gdrr_sem_sexpr_t *sem_sexpr_lin(void *closure, gdrr_sem_linear_t *this) {
jobject ret = java_method_call(closure, "sem_sexpr_lin", 1, (jobject)this);
return (gdrr_sem_sexpr_t*)ret;
}
static gdrr_sem_sexpr_t *sem_sexpr_cmp(void *closure, gdrr_sem_op_cmp_t *this) {
jobject ret = java_method_call(closure, "sem_sexpr_cmp", 1, (jobject)this);
return (gdrr_sem_sexpr_t*)ret;
}
// sem_op_cmp
static gdrr_sem_op_cmp_t *sem_cmpeq(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2) {
jobject ret = java_method_call(closure, "sem_cmpeq", 3,
java_long_create(closure, (long int)size), (jobject)opnd1,
(jobject)opnd2);
return (gdrr_sem_op_t*)ret;
return (gdrr_sem_op_cmp_t*)ret;
}
static gdrr_sem_op_cmp_t *sem_cmpneq(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2) {
jobject ret = java_method_call(closure, "sem_cmpneq", 3,
java_long_create(closure, (long int)size), (jobject)opnd1,
(jobject)opnd2);
return (gdrr_sem_op_t*)ret;
return (gdrr_sem_op_cmp_t*)ret;
}
static gdrr_sem_op_cmp_t *sem_cmples(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2) {
jobject ret = java_method_call(closure, "sem_cmples", 3,
java_long_create(closure, (long int)size), (jobject)opnd1,
(jobject)opnd2);
return (gdrr_sem_op_t*)ret;
return (gdrr_sem_op_cmp_t*)ret;
}
static gdrr_sem_op_cmp_t *sem_cmpleu(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2) {
jobject ret = java_method_call(closure, "sem_cmpleu", 3,
java_long_create(closure, (long int)size), (jobject)opnd1,
(jobject)opnd2);
return (gdrr_sem_op_t*)ret;
return (gdrr_sem_op_cmp_t*)ret;
}
static gdrr_sem_op_cmp_t *sem_cmplts(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2) {
jobject ret = java_method_call(closure, "sem_cmplts", 3,
java_long_create(closure, (long int)size), (jobject)opnd1,
(jobject)opnd2);
return (gdrr_sem_op_t*)ret;
return (gdrr_sem_op_cmp_t*)ret;
}
static gdrr_sem_op_cmp_t *sem_cmpltu(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2) {
jobject ret = java_method_call(closure, "sem_cmpltu", 3,
java_long_create(closure, (long int)size), (jobject)opnd1,
(jobject)opnd2);
return (gdrr_sem_op_t*)ret;
return (gdrr_sem_op_cmp_t*)ret;
}
// sem_op
......@@ -719,6 +729,9 @@ JNICALL Java_rnati_NativeInterface_decodeAndTranslateNative(JNIEnv *env,
config.callbacks.sem_linear.sem_lin_sub = &sem_lin_sub;
config.callbacks.sem_linear.sem_lin_scale = &sem_lin_scale;
config.callbacks.sem_sexpr.sem_sexpr_lin = &sem_sexpr_lin;
config.callbacks.sem_sexpr.sem_sexpr_cmp = &sem_sexpr_cmp;
config.callbacks.sem_op_cmp.sem_cmpeq = &sem_cmpeq;
config.callbacks.sem_op_cmp.sem_cmpneq = &sem_cmpneq;
config.callbacks.sem_op_cmp.sem_cmples = &sem_cmples;
......
package rreil.operation;
import rreil.linear.LinearExpression;
public abstract class CompareOperation extends BinaryOperation implements ICompareOperation {
public CompareOperation(long size, LinearExpression operand1,
LinearExpression operand2) {
super(size, operand1, operand2);
}
}
package rreil.operation;
public interface ICompareOperation extends IOperation {
}
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment