4

I have an application on my Ubuntu system, built with CMake, using add_executable predicate. It runs fine by itself, however, readelf shows it as DYN (Shared object file) which is usually applied to shared libraries:

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

Does anyone know why this may happen?

ilya1725
  • 4,496
  • 7
  • 43
  • 68

1 Answers1

-1

On modern distros executables are compiled to position-independent code by default (see e.g. this question) which causes tools (file, etc.) to think that they are shared libs. I suggest you file a bug against respective tools so that they produce more user-friendly output.

Community
  • 1
  • 1
yugr
  • 19,769
  • 3
  • 51
  • 96
  • 1
    "file a bug against respective tools so that they produce more user-friendly output." -- the tools are producing *correct* output. – Employed Russian Jan 21 '17 at 21:18
  • Well, I think that being _useful_ (in this case not breaking tons of scripts which rely on existing behavior) is usually more important than being correct (or at the very least something which deserves serious attention from distro maintainers). Besides, `file` is known to be based on heuristics so I'm not sure how one can define it's correctness in a sane way... – yugr Jan 21 '17 at 21:24