A real elf file dynamically linked to glibc have a interpreter.
ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=.... , for GNU/Linux 3.2.0, with debug_info, not stripped
A statically linked PIE elf will also show as "dynamically linked", but don't have interpreter.
ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=..., for GNU/Linux 3.2.0, with debug_info, not stripped
You can test this beheiver using gcc or clang:
> gcc test.c && file a.out
a.out: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=..., for GNU/Linux 3.2.0, not stripped
> gcc -static test.c && file a.out
a.out: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, BuildID[sha1]=..., for GNU/Linux 3.2.0, not stripped
> gcc -static-pie test.c && file a.out
a.out: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=..., for GNU/Linux 3.2.0, not stripped
You can also test the file using readelf:
> readelf -d a.out
Dynamic section at offset 0xb5d58 contains 23 entries:
Tag Type Name/Value
0x000000000000000c (INIT) 0x9000
0x000000000000000d (FINI) 0x899f8
0x0000000000000019 (INIT_ARRAY) 0xb3ee0
0x000000000000001b (INIT_ARRAYSZ) 16 (bytes)
0x000000000000001a (FINI_ARRAY) 0xb3ef0
0x000000000000001c (FINI_ARRAYSZ) 16 (bytes)
0x0000000000000004 (HASH) 0x2b8
0x000000006ffffef5 (GNU_HASH) 0x2c8
0x0000000000000005 (STRTAB) 0x300
0x0000000000000006 (SYMTAB) 0x2e8
0x000000000000000a (STRSZ) 1 (bytes)
0x000000000000000b (SYMENT) 24 (bytes)
0x0000000000000015 (DEBUG) 0x0
0x0000000000000003 (PLTGOT) 0xb7000
0x0000000000000002 (PLTRELSZ) 576 (bytes)
0x0000000000000014 (PLTREL) RELA
0x0000000000000017 (JMPREL) 0x7e08
0x0000000000000007 (RELA) 0x308
0x0000000000000008 (RELASZ) 31488 (bytes)
0x0000000000000009 (RELAENT) 24 (bytes)
0x000000006ffffffb (FLAGS_1) Flags: PIE
0x000000006ffffff9 (RELACOUNT) 1312
0x0000000000000000 (NULL) 0x0
A statically linked PIE elf file don't have NEEDED entry.
See also: x86_64-unknown-linux-musl binaries have a DYNAMIC segment · Issue #80000 · rust-lang/rust · GitHub