I want to create a memory address alignment fault on my x86 machine. Why do I want to do this? Because I would like to expressly test out my SIGBUS handler.
Here is my test example.
#include <stdio.h>
int main(int argc, char** argv) {
unsigned char array[32];
short *short_ptr;
short_ptr = (short *)&array[1];
*short_ptr = 0xffff; // Store
printf("value of c = %x", *short_ptr);
return 0;
}
I know this will create a misalignment exception on the SPARC architecture. But, I can't for the life of me figure out how to do it on x86.
How can I do it?