I have the following problem: I have an elf file and I want to know whether that elf file can be run as a standalone executable or not. So for shared libraries e.g., .so
files, I want to have False
as a result and for ready-to-run binaries I want True
as an output. I tried to leverage file
to achieve this, but apparently the information given is not enough. Consider
file /usr/bin/sudo
/usr/bin/sudo: setuid ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=3e4fbfd5a73126630bcc22d5dee68c32e2813566, stripped
where I actually expected the output to be ELF 64-bit LSB executable
, like for the gcc
compiler:
file /usr/bin/gcc-5
/usr/bin/gcc-5: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=b3417f0bc306e9b0afe35e778b5e4702f2d22b26, stripped
What am I missing here and are there any other ways to achieve my goal?