3

我的 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

有谁知道为什么会发生这种情况?

4

1 回答 1

-1

在现代发行版上,可执行文件默认编译为与位置无关的代码(参见例如这个问题),这导致工具(file等)认为它们是共享库。我建议您针对相应的工具提交错误,以便它们产生更用户友好的输出。

于 2017-01-20T09:30:31.767 回答