// hex.c
1 #include <sys/mman.h>
2 #include <string.h>
3
4 int main () {
5 char code[] = {0xB8, 0x3C, 0x0, 0x0, 0x0, 0xBF, 0x2, 0x0, 0x0, 0x0, 0xBA, 0x7D, 0x0, 0x0, 0x0, 0xC3};
6 void *buf;
7 buf = mmap (0,sizeof(code),PROT_READ|PROT_WRITE|PROT_EXEC,MAP_PRIVATE|MAP_ANON,-1,0);
8 memcpy (buf, code, sizeof(code));
9 return 0;
10 }
// gcc -g hex.c -o hex
gdb hex;
b 9;
r;
x /10i buf
mov $0x3c,%eax
mov $0x2,%edi
mov $0x7d,%edx
ret