Commit 34a29a1e authored by Julian Kranz's avatar Julian Kranz

Jgdrr

- Continued to implement jgdrr
parent ddea0467
......@@ -75,6 +75,17 @@ static jobject java_method_call(void *closure, char *name, int numargs, ...) {
return ret;
}
static jobject java_long_create(void *closure, long int x) {
struct closure *cls = (struct closure*)closure;
jclass class = (*cls->env)->FindClass(cls->env, "java/lang/Long");
jmethodID method_id = (*cls->env)->GetMethodID(cls->env, class, "<init>",
"(J)V");
jobject a = (*cls->env)->NewObject(cls->env, class, method_id, x);
return a;
}
// sem_id
static gdrr_sem_id_t *virt_eq(void *closure) {
printf("=> virt_eq\n");
......@@ -146,116 +157,138 @@ static gdrr_sem_linear_t *sem_lin_scale(void *closure, __word imm,
// sem_op
static gdrr_sem_op_t *sem_lin(void *closure, __word size,
gdrr_sem_linear_t *opnd1) {
printf("=> lin {size=%lu}\n", size);
return NULL;
jobject ret = java_method_call(closure, "sem_lin", 2,
java_long_create(closure, size), (jobject)opnd1);
return (gdrr_sem_op_t*)ret;
}
static gdrr_sem_op_t *sem_mul(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2) {
printf("=> mul {size=%lu}\n", size);
return NULL;
jobject ret = java_method_call(closure, "sem_mul", 3,
java_long_create(closure, size), (jobject)opnd1, (jobject)opnd2);
return (gdrr_sem_op_t*)ret;
}
static gdrr_sem_op_t *sem_div(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2) {
printf("=> div {size=%lu}\n", size);
return NULL;
jobject ret = java_method_call(closure, "sem_div", 3,
java_long_create(closure, size), (jobject)opnd1, (jobject)opnd2);
return (gdrr_sem_op_t*)ret;
}
static gdrr_sem_op_t *sem_divs(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2) {
printf("=> divs {size=%lu}\n", size);
return NULL;
jobject ret = java_method_call(closure, "sem_divs", 3,
java_long_create(closure, size), (jobject)opnd1, (jobject)opnd2);
return (gdrr_sem_op_t*)ret;
}
static gdrr_sem_op_t *sem_mod(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2) {
printf("=> mod {size=%lu}\n", size);
return NULL;
jobject ret = java_method_call(closure, "sem_mod", 3,
java_long_create(closure, size), (jobject)opnd1, (jobject)opnd2);
return (gdrr_sem_op_t*)ret;
}
static gdrr_sem_op_t *sem_shl(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2) {
printf("=> shl {size=%lu}\n", size);
return NULL;
jobject ret = java_method_call(closure, "sem_shl", 3,
java_long_create(closure, size), (jobject)opnd1, (jobject)opnd2);
return (gdrr_sem_op_t*)ret;
}
static gdrr_sem_op_t *sem_shr(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2) {
printf("=> shr {size=%lu}\n", size);
return NULL;
jobject ret = java_method_call(closure, "sem_shr", 3,
java_long_create(closure, size), (jobject)opnd1, (jobject)opnd2);
return (gdrr_sem_op_t*)ret;
}
static gdrr_sem_op_t *sem_shrs(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2) {
printf("=> shrs {size=%lu}\n", size);
return NULL;
jobject ret = java_method_call(closure, "sem_shrs", 3,
java_long_create(closure, size), (jobject)opnd1, (jobject)opnd2);
return (gdrr_sem_op_t*)ret;
}
static gdrr_sem_op_t *sem_and(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2) {
printf("=> and {size=%lu}\n", size);
return NULL;
jobject ret = java_method_call(closure, "sem_and", 3,
java_long_create(closure, size), (jobject)opnd1, (jobject)opnd2);
return (gdrr_sem_op_t*)ret;
}
static gdrr_sem_op_t *sem_or(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2) {
printf("=> or {size=%lu}\n", size);
return NULL;
jobject ret = java_method_call(closure, "sem_or", 3,
java_long_create(closure, size), (jobject)opnd1, (jobject)opnd2);
return (gdrr_sem_op_t*)ret;
}
static gdrr_sem_op_t *sem_xor(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2) {
printf("=> xor {size=%lu}\n", size);
return NULL;
jobject ret = java_method_call(closure, "sem_xor", 3,
java_long_create(closure, size), (jobject)opnd1, (jobject)opnd2);
return (gdrr_sem_op_t*)ret;
}
static gdrr_sem_op_t *sem_sx(void *closure, __word size, __word fromsize,
gdrr_sem_linear_t *opnd1) {
printf("=> sx {size=%lu, fromsize=%lu}\n", size, fromsize);
return NULL;
jobject ret = java_method_call(closure, "sem_sx", 3,
java_long_create(closure, size), java_long_create(closure, fromsize),
(jobject)opnd1);
return (gdrr_sem_op_t*)ret;
}
static gdrr_sem_op_t *sem_zx(void *closure, __word size, __word fromsize,
gdrr_sem_linear_t *opnd1) {
printf("=> zx {size=%lu, fromsize=%lu}\n", size, fromsize);
return NULL;
jobject ret = java_method_call(closure, "sem_zx", 3,
java_long_create(closure, size), java_long_create(closure, fromsize),
(jobject)opnd1);
return (gdrr_sem_op_t*)ret;
}
static gdrr_sem_op_t *sem_cmpeq(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2) {
printf("=> cmpeq {size=%lu}\n", size);
return NULL;
jobject ret = java_method_call(closure, "sem_cmpeq", 3,
java_long_create(closure, size), (jobject)opnd1, (jobject)opnd2);
return (gdrr_sem_op_t*)ret;
}
static gdrr_sem_op_t *sem_cmpneq(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2) {
printf("=> cmpneq {size=%lu}\n", size);
return NULL;
jobject ret = java_method_call(closure, "sem_cmpneq", 3,
java_long_create(closure, size), (jobject)opnd1, (jobject)opnd2);
return (gdrr_sem_op_t*)ret;
}
static gdrr_sem_op_t *sem_cmples(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2) {
printf("=> cmples {size=%lu}\n", size);
return NULL;
jobject ret = java_method_call(closure, "sem_cmples", 3,
java_long_create(closure, size), (jobject)opnd1, (jobject)opnd2);
return (gdrr_sem_op_t*)ret;
}
static gdrr_sem_op_t *sem_cmpleu(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2) {
printf("=> cmpleu {size=%lu}\n", size);
return NULL;
jobject ret = java_method_call(closure, "sem_cmpleu", 3,
java_long_create(closure, size), (jobject)opnd1, (jobject)opnd2);
return (gdrr_sem_op_t*)ret;
}
static gdrr_sem_op_t *sem_cmplts(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2) {
printf("=> cmplts {size=%lu}\n", size);
return NULL;
jobject ret = java_method_call(closure, "sem_cmplts", 3,
java_long_create(closure, size), (jobject)opnd1, (jobject)opnd2);
return (gdrr_sem_op_t*)ret;
}
static gdrr_sem_op_t *sem_cmpltu(void *closure, __word size,
gdrr_sem_linear_t *opnd1, gdrr_sem_linear_t *opnd2) {
printf("=> cmpltu {size=%lu}\n", size);
return NULL;
jobject ret = java_method_call(closure, "sem_cmpltu", 3,
java_long_create(closure, size), (jobject)opnd1, (jobject)opnd2);
return (gdrr_sem_op_t*)ret;
}
static gdrr_sem_op_t *sem_arb(void *closure, __word size) {
printf("=> arb {size=%lu}\n", size);
return NULL;
jobject ret = java_method_call(closure, "sem_arb", 1,
java_long_create(closure, size));
return (gdrr_sem_op_t*)ret;
}
// sem_branch_hint
static gdrr_sem_branch_hint *hint_jump(void *closure) {
printf("==> branch_hint_jump\n");
return NULL;
jobject ret = java_method_call(closure, "hint_jump", 0);
return (gdrr_sem_branch_hint*)ret;
}
static gdrr_sem_branch_hint *hint_call(void *closure) {
printf("==> branch_hint_call\n");
return NULL;
jobject ret = java_method_call(closure, "hint_call", 0);
return (gdrr_sem_branch_hint*)ret;
}
static gdrr_sem_branch_hint *hint_ret(void *closure) {
printf("==> branch_hint_ret\n");
return NULL;
jobject ret = java_method_call(closure, "hint_ret", 0);
return (gdrr_sem_branch_hint*)ret;
}
// sem_stmt
......@@ -313,8 +346,10 @@ static gdrr_sem_stmts_t *list_init(void *closure) {
return NULL;
}
JNIEXPORT jobject JNICALL Java_NativeInterface_decodeAndTranslateNative(
JNIEnv *env, jobject obj, jbyteArray input) {
JNIEXPORT
jobject
JNICALL Java_NativeInterface_decodeAndTranslateNative(JNIEnv *env, jobject obj,
jbyteArray input) {
__char blob[15];
char fmt[1024];
__word sz = 15;
......
public class NativeInterface {
public NativeInterface() {
System.loadLibrary("jgdrr");
}
public RReilStatement[] decodeAndTranslate(byte[] bytes) {
return (RReilStatement[])decodeAndTranslateNative(bytes);
return (RReilStatement[]) decodeAndTranslateNative(bytes);
}
/*
* sem_op
*/
private Object sem_lin(Object size, Object opnd1) {
Long longSize = (Long) size;
System.out.println("(j) sem_lin {size=" + longSize + "}");
return null;
}
private Object sem_mul(Object size, Object opnd1, Object opnd2) {
Long longSize = (Long) size;
System.out.println("(j) sem_mul {size=" + longSize + "}");
return null;
}
private Object sem_div(Object size, Object opnd1, Object opnd2) {
Long longSize = (Long) size;
System.out.println("(j) sem_div {size=" + longSize + "}");
return null;
}
private Object sem_divs(Object size, Object opnd1, Object opnd2) {
Long longSize = (Long) size;
System.out.println("(j) sem_divs {size=" + longSize + "}");
return null;
}
private Object sem_mod(Object size, Object opnd1, Object opnd2) {
Long longSize = (Long) size;
System.out.println("(j) sem_mod {size=" + longSize + "}");
return null;
}
private Object sem_shl(Object size, Object opnd1, Object opnd2) {
Long longSize = (Long) size;
System.out.println("(j) sem_shl {size=" + longSize + "}");
return null;
}
private Object sem_shr(Object size, Object opnd1, Object opnd2) {
Long longSize = (Long) size;
System.out.println("(j) sem_shr {size=" + longSize + "}");
return null;
}
private Object sem_shrs(Object size, Object opnd1, Object opnd2) {
Long longSize = (Long) size;
System.out.println("(j) sem_shrs {size=" + longSize + "}");
return null;
}
private Object sem_and(Object size, Object opnd1, Object opnd2) {
Long longSize = (Long) size;
System.out.println("(j) sem_and {size=" + longSize + "}");
return null;
}
private Object sem_or(Object size, Object opnd1, Object opnd2) {
Long longSize = (Long) size;
System.out.println("(j) sem_or {size=" + longSize + "}");
return null;
}
private Object sem_xor(Object size, Object opnd1, Object opnd2) {
Long longSize = (Long) size;
System.out.println("(j) sem_xor {size=" + longSize + "}");
return null;
}
private Object sem_sx(Object size, Object fromsize, Object opnd1) {
Long longSize = (Long) size;
System.out.println("(j) sem_sx {size=" + longSize + "}");
return null;
}
private Object sem_zx(Object size, Object fromsize, Object opnd1) {
Long longSize = (Long) size;
System.out.println("(j) sem_zx {size=" + longSize + "}");
return null;
}
private Object sem_cmpeq(Object size, Object opnd1, Object opnd2) {
Long longSize = (Long) size;
System.out.println("(j) sem_cmpeq {size=" + longSize + "}");
return null;
}
private Object sem_cmpneq(Object size, Object opnd1, Object opnd2) {
Long longSize = (Long) size;
System.out.println("(j) sem_cmpneq {size=" + longSize + "}");
return null;
}
private Object sem_cmples(Object size, Object opnd1, Object opnd2) {
Long longSize = (Long) size;
System.out.println("(j) sem_cmples {size=" + longSize + "}");
return null;
}
private Object sem_cmpleu(Object size, Object opnd1, Object opnd2) {
Long longSize = (Long) size;
System.out.println("(j) sem_cmpleu {size=" + longSize + "}");
return null;
}
private Object sem_cmplts(Object size, Object opnd1, Object opnd2) {
Long longSize = (Long) size;
System.out.println("(j) sem_cmplts {size=" + longSize + "}");
return null;
}
private Object sem_cmpltu(Object size, Object opnd1, Object opnd2) {
Long longSize = (Long) size;
System.out.println("(j) sem_cmpltu {size=" + longSize + "}");
return null;
}
private Object sem_arb(Object size) {
Long longSize = (Long) size;
System.out.println("(j) sem_arb {size=" + longSize + "}");
return null;
}
/*
* sem_branch_hint
*/
private Object hint_jump() {
System.out.println("(j) hint_jump");
return null;
}
private Object hint_call() {
System.out.println("(j) hint_call");
return null;
}
private Object hint_ret() {
System.out.println("(j) hint_ret");
return null;
}
/*
* sem_stmt
*/
private Object sem_assign(Object lhs, Object rhs) {
System.out.println("(j) sem_assign");
return null;
}
private Object sem_load(Object lhs, Object size, Object address) {
System.out.println("(j) sem_load");
return null;
}
private Object sem_store(Object lhs, Object rhs) {
System.out.println("(j) sem_store");
return null;
}
private Object sem_ite(Object cond, Object then_branch, Object else_branch) {
System.out.println("(j) sem_ite");
return null;
}
private Object sem_while(Object cond, Object body) {
System.out.println("(j) sem_while");
return null;
}
private Object sem_cbranch(Object cond, Object target_true, Object target_false) {
private Object sem_cbranch(Object cond, Object target_true,
Object target_false) {
System.out.println("(j) sem_cbranch");
return null;
}
private Object sem_branch(Object branch_hint, Object target) {
System.out.println("(j) sem_branch");
return null;
}
private native Object decodeAndTranslateNative(byte[] bytes);
}
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