about summary refs log tree commit diff stats
path: root/miasm2/jitter/Jittcc.c
diff options
context:
space:
mode:
authorFabrice Desclaux <fabrice.desclaux@cea.fr>2014-09-05 11:30:05 +0200
committerFabrice Desclaux <fabrice.desclaux@cea.fr>2014-09-05 11:30:05 +0200
commit6e09df71a333bf87cd68c2d08ad068a3e501462d (patch)
tree7d76e0626e61ef5a9f15c62358337674fb0095aa /miasm2/jitter/Jittcc.c
parente8d0fcf8d28d82a8f33138d044f335634ac3a30c (diff)
downloadmiasm-6e09df71a333bf87cd68c2d08ad068a3e501462d.tar.gz
miasm-6e09df71a333bf87cd68c2d08ad068a3e501462d.zip
Modify irbloc destination mecanism. Rework API in consequence.
Fat patch here: some API have changed.

Each irbloc now affects a special "IRDst" register which is used to
describe the destination irbloc. It allows simple description of
architectures using delay slots. Architectures semantic and tcc/python
jitter are modified in consequence. LLVM jitter is disabled for now,
but should be patch soon.
Diffstat (limited to 'miasm2/jitter/Jittcc.c')
-rw-r--r--miasm2/jitter/Jittcc.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/miasm2/jitter/Jittcc.c b/miasm2/jitter/Jittcc.c
index 710a6175..8c5b2046 100644
--- a/miasm2/jitter/Jittcc.c
+++ b/miasm2/jitter/Jittcc.c
@@ -121,17 +121,37 @@ PyObject* tcc_set_emul_lib_path(PyObject* self, PyObject* args)
 }
 
 
+typedef struct {
+	uint8_t is_local;
+	uint64_t address;
+} block_id;
+
+
 PyObject* tcc_exec_bloc(PyObject* self, PyObject* args)
 {
-	PyObject* (*func)(void*, void*);
+	//PyObject* (*func)(void*, void*);
+	block_id (*func)(void*, void*);
 	uint64_t vm;
 	uint64_t cpu;
 	PyObject* ret;
+	block_id BlockDst;
 
 	if (!PyArg_ParseTuple(args, "KKK", &func, &cpu, &vm))
 		return NULL;
-	ret = func((void*)cpu, (void*)vm);
-	return ret;
+	BlockDst = func((void*)cpu, (void*)vm);
+
+	ret = PyTuple_New(2);
+	if (ret == NULL) {
+		fprintf(stderr, "Erreur alloc!\n");
+		exit(1);
+	}
+
+	if (BlockDst.is_local == 1) {
+		fprintf(stderr, "return on local label!\n");
+		exit(1);
+	}
+
+	return PyLong_FromUnsignedLongLong(BlockDst.address);
 }
 
 PyObject* tcc_compil(PyObject* self, PyObject* args)