I was doing some experiment with object file produced by gcc
.
While I know, at least superficially, what is the use of position independent code, I was trying to spot it concretely.
I produced this simple code in a file timestwo.c
:
int timestwo(int x) { return 2 * x; }
which I compiled:
gcc -c timestwo.c
gcc -c -fPIC timestwo.c -o timestwo_pic.o
then the resulting object files timestwo.o
and timestwo_pic.o
are bitwise the same. Also with readelf -a
I cannot spot any difference.
Can you provide a MWE in which i can see the difference between pic
and non-pic
code?