Linkers, Loaders & Executables

Which pairs major operating systems with the executable formats they use correctly?

  1. ALinux uses PE, Windows uses Mach-O and macOS uses ELF
  2. BLinux uses ELF, Windows uses PE and macOS uses Mach-O
  3. CEvery OS uses ELF
Show answer and explanation

Answer: B. Linux uses ELF, Windows uses PE and macOS uses Mach-O

Each OS defines its executable format: Linux, BSD and many embedded devices use ELF, Windows uses PE (Portable Executable) for .exe and .dll files, and macOS and iOS use Mach-O. The underlying ideas (code and data areas, symbols, relocations, dynamic-linking information) are similar, but because the formats differ, an executable does not run unchanged on a different OS even for the same CPU.

  • A. The pairs are scrambled.
  • B. Correct. Each OS has its own format.
  • C. Windows and macOS use different formats.
Practice this topic Back to topic

More Linkers, Loaders & Executables questions

  1. When recursion goes so deep that it exceeds the stack limit, what generally happens on Linux and similar systems?
  2. In C, what is true of the starting values of a local variable and a global variable declared without initializers?
  3. After repeated malloc and free, a large block may become impossible to allocate even though total free memory is sufficient. What is this phenomenon called?
  4. When building a shared library, what is the advantage of exporting only the public functions and giving internal functions "hidden" symbol visibility?
  5. How does C++ run the constructors of global objects before main?