aboutsummaryrefslogtreecommitdiff
path: root/executor/x86_64/asm.c
diff options
context:
space:
mode:
Diffstat (limited to 'executor/x86_64/asm.c')
-rw-r--r--executor/x86_64/asm.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/executor/x86_64/asm.c b/executor/x86_64/asm.c
index e29130e..c633db8 100644
--- a/executor/x86_64/asm.c
+++ b/executor/x86_64/asm.c
@@ -210,16 +210,21 @@ static void asm_print_code_hex(Asm *self) {
}
#endif
+typedef union {
+ u8 *data;
+ int (*func)(void);
+} RawFuncCallPtr;
+
int asm_execute(Asm *self, u32 offset) {
- void (*func)();
+ RawFuncCallPtr raw_func_ptr;
if(mprotect(self->code, self->allocated_size, PROT_READ | PROT_EXEC) != 0)
return -errno;
/*asm_print_code_hex(self);*/
/* TODO: Verify if this is valid on all platforms. According to ISO C standard it isn't? */
- *(void**)(&func) = (u8*)self->code + offset;
- func();
+ raw_func_ptr.data = (u8*)self->code + offset;
+ raw_func_ptr.func();
return 0;
}