I am looking for a quick way to check if an ELF binary is a common or independent position.
Unable to verify: The PIE executable is a shared object.
I think this can be done by checking the contained characters / functions.
Symbols can be deleted, and as soon as they appear, you cannot say.
shared objects and executables that they usually differ in related startup code
This is true: PIE is usually associated with Scrt1.o , but usually there is no shared library. But there is nothing that would prevent the shared library from communicating with Scrt1.o , and in the split binary, even finding that the startup code can be somewhat problematic.
If you really need to distinguish between the shared library and the PIE executable that you created (instead of solving the general case of any shared library and any PIE), then check for PT_INTERP ( PT_INTERP readelf -l a.out | grep INTERP ), probably the most an easy way: the PIE executable will have PT_INTERP , but usually not in shared libraries ( libc.so.6 is a notable exception).
source share