elf-by-example

Experiment and learn how compilers, linkers and C runtime work cooperatively

View the Project on GitHub sivachandra/elf-by-example

What is a static-pie linked executable?

A static-pie linked executable is a fully statically linked executable which is also a PIE. Since it is fully statically linked, it does not depend on any dynamically loaded libraries. However, since it is a PIE, the ELF file will have both the .dynamic and the .rel[a].dyn sections.

The reason for requiring dynamic relocations (those in .rel[a].dyn) in a static-pie binary are explained in this example.

A statically linked PIE binary differs from a dynamically linked PIE binary in the following ways:

  1. As there are no dynamic libraries to be loaded, they is no need of the program interpreter. Consequently, there is no PT_INTERP segment in a static-pie binary.
  2. The dynamic section will not have DT_NEEDED entries as a static-pie binary does not need any dynamically loaded libraries.