blob: 58580ed9e7a8be4c489caabe263f09ebc5c6f4cd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef int fun_type(int x);
int poulet(int x) {
return x*2;
}
int canard(int x) {
return x*3;
}
#define SIZE 1024
int main() {
void *buf=malloc(SIZE);
memcpy(buf, poulet, SIZE);
int rpoulet = (*((fun_type*) buf))(33);
memcpy(buf, canard, SIZE);
int rcanard = (*((fun_type*) buf))(33);
__builtin_k1_iinval();
int rcanard2 = (*((fun_type*) buf))(33);
free(buf);
printf("%d %d %d\n", rpoulet, rcanard, rcanard2);
return 0;
}
|