应用程序显示为 DYN(共享对象文件)

Application shows up as DYN (Shared object file)

我的 Ubuntu 系统上有一个应用程序,它使用 CMake 构建,使用 add_executable 谓词。它本身运行良好,但是,readelf 将其显示为 DYN (Shared object file),通常应用于共享库:

root@3cced4f9860d build# readelf -h ./unittest/unittests            
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 03 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - GNU
  ABI Version:                       0
  Type:                              DYN (Shared object file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x3e3660
  Start of program headers:          64 (bytes into file)
  Start of section headers:          19112592 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         9
  Size of section headers:           64 (bytes)
  Number of section headers:         31
  Section header string table index: 28

有人知道为什么会这样吗?

在现代发行版中,可执行文件默认编译为 position-independent 代码(参见 ),这导致工具(file 等)认为它们是共享库。我建议您针对各自的工具提交错误,以便它们产生更多 user-friendly 输出。