I wanted to make some basic tests on Linux ASLR, so i wrote the following code :
#include <stdio.h>
void funct(){
int a= 0;
}
void main(){
int b=0;
printf("funct : %p\n", &funct);
printf("var stack : %p\n", &b);
}
When I run this code, the second pointer (which points to a value on the stack) seems randomized as it changes from one execution to another, but not the first pointer.
I tried compiling with -fPIC gcc option, but it doesn't work either.
Also, I already checked that /proc/sys/kernel/randomize_va_space is equal to 2.
Could someone explain what I'm doing wrong ?