I made a piece of code which consists in a dynamic library (lib.c), and a main executable (main.c). In both files I define a global variable named:
lib.c
main.c
By default, when building an executable references to variables are done internally, with a fixed offset and no relocation.
However, you're passing -fPIC and access to global data are converted to access via GOT and GOT relocations are added.
-fPIC