0

Stephen Kitt wrote in https://unix.stackexchange.com/a/448943/674

ld.so is a shared ELF object, but it doesn’t require an interpreter (it has no .interp entry); this is typical of libraries (shared executables always require an interpreter; otherwise they’re static, not dynamic).

Is an ELF object file a "shared executable" if and only if it has an .interp entry ?

What does "shared executables" mean? Is it the same as "shared libraries"?

Or does "shared executables" mean "partially linked executables"? In CSAPP

linux> gcc -o prog2l main2.c ./libvector.so

This creates an executable object file prog2l in a form that can be linked with libvector.so at run time.

... When the loader loads and runs the executable prog2l, it loads the partially linked executable prog2l, using the techniques discussed in Section 7.9. Next, it notices that prog2l contains a .interp section, which contains the path name of the dynamic linker, which is itself a shared object (e.g., ld-linux.so on Linux systems).

1 Answer 1

2

Is an ELF object file a "shared executable" if and only if it has an .interp entry?

Strictly speaking, no, because it can also be a shared library. But all “shared executables” (by which I meant dynamically-linked) have an interpreter entry, regardless of their ELF type (EXEC or DYN).

What does "shared executables" mean? Is it the same as "shared libraries"?

No, it’s not the same; I should have written “dynamically-linked executables”.

Or does "shared executables" mean "partially linked executables"?

That’s another way of putting it.

2
  • Thanks. (1) "it can also be a shared library", do you mean a shared library which is not a "shared executable" can also have an .interp entry? Isn't no .interp "typical of libraries"? (2) How do you tell if an ELF object file is a “shared executable”? i.e. What necessary and sufficient condition for an ELF object file to be a "shared executable"?
    – Tim
    Sep 28, 2020 at 1:16
  • (1) See libc.so.6. “Typical” doesn’t mean that only libraries have no .interp entry, or that no libraries have one. Statically-linked executables also don’t have an interpreter. (2) An ELF file is a shared executable if (a) it has ELF type EXEC and an .interp entry or (b) it has type DYN and the PIE flag set in DT_FLAGS_1. Sep 28, 2020 at 5:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.