How to call machine code stored in char array?
问题 I'm trying to call native machine-language code. Here's what I have so far (it gets a bus error): char prog[] = {'\xc3'}; // x86 ret instruction int main() { typedef double (*dfunc)(); dfunc d = (dfunc)(&prog[0]); (*d)(); return 0; } It does correctly call the function and it gets to the ret instruction. But when it tries to execute the ret instruction, it has a SIGBUS error. Is it because I'm executing code on a page that is not cleared for execution or something like that? So what am I