Linkers, Loaders & Executables

What happens when the strip command is applied to an executable?

  1. AThe machine instructions are optimized and run faster
  2. BThe executable is encrypted so others cannot run it
  3. CSymbol tables and debug information are removed; the file shrinks, but debuggers can no longer show function names and the like easily
Show answer and explanation

Answer: C. Symbol tables and debug information are removed; the file shrinks, but debuggers can no longer show function names and the like easily

An executable may contain a symbol table listing function and variable names, and debug information mapping code to source lines. These are not needed to run, so removing them with strip makes the file smaller. Function names and line numbers are then unavailable when investigating bugs, so the information is sometimes kept separately before stripping. Symbols needed for dynamic linking remain.

  • A. The instructions are unchanged, so speed is unchanged.
  • B. It does not encrypt anything.
  • C. Correct. It removes information not needed for execution.
Practice this topic Back to topic

More Linkers, Loaders & Executables questions

  1. How does a linker treat a weak symbol?
  2. What is the main purpose of name mangling, in which a C++ compiler encodes argument types and other information into symbol names?
  3. What is the most suitable use of Linux's dlopen function (the counterpart of Windows LoadLibrary)?
  4. When 100 processes use the same shared library, how is physical memory used?
  5. Disassembling an object file shows that an instruction calling the external function printf has a placeholder target such as 0. When is the correct value filled in?