What is the .interp section in an ELF and how do custom loaders work?

Viewed 602

ELF in Linux allows specifying a custom loader in the .interp header. Usually, this is ld. What are examples of non-ld loaders? What is used to load the loader itself? Assuming I specify a non-ld interp, what is the interface it has to the executable it is supposed to load?

1 Answers

ELF in Linux allows specifying a custom loader in the .interp header. Usually, this is ld.

The loader usually depends on the libc being used, and is never ld.

On Solaris, it's usually ld.so.

On Linux it's usually /lib/ld-linux.so.2 (on i*x86 GLIBC systems), /lib64/ld-linux-x86-64.so.2 (on x86_64 GLIBC systems), etc.

What are examples of non-ld loaders?

Musl-based systems use $(syslibdir)/ld-musl-$(ARCH).so.1

What is used to load the loader itself?

The kernel does it. The loader must relocate itself, since there is nothing else which can do that.

Assuming I specify a non-ld interp, what is the interface it has to the executable it is supposed to load?

That interface is defined by whatever libc you are using (which is why the loader and libc always come from the same package).

Related