How can I tell, with something like objdump, if an object file has been built with -fPIC?

Crazy Chenz picture Crazy Chenz · Aug 27, 2009 · Viewed 30.5k times · Source

How can I tell, with something like objdump, if an object file has been built with -fPIC?

Answer

Employed Russian picture Employed Russian · Aug 29, 2009

The answer depends on the platform. On most platforms, if output from

readelf --relocs foo.o | egrep '(GOT|PLT|JU?MP_SLOT)'

is empty, then either foo.o was not compiled with -fPIC, or foo.o doesn't contain any code where -fPIC matters.