Skip to content
Search

Executable and Linkable Format

lastmod 2021-06-23created 2015-04-0417 edits

ELF (Executable and Linkable Format) is a standard file format for executables, object files, shared libraries, and core dumps. In 1999 it was chosen by the 86open project as the standard binary file format for x86-based Unix and Unix-like systems.

Executable image

Elf-executable_image.jpg

How to using rpath

#include <stdio.h>
#include <elf.h>
#include <link.h>

int main()
{
  const ElfW(Dyn) *dyn = _DYNAMIC;
  const ElfW(Dyn) *rpath = NULL;
  const char *strtab = NULL;
  for (; dyn->d_tag != DT_NULL; ++dyn) {
    if (dyn->d_tag == DT_RPATH) {
      rpath = dyn;
    } else if (dyn->d_tag == DT_STRTAB) {
      strtab = (const char *)dyn->d_un.d_val;
    }
  }

  if (strtab != NULL && rpath != NULL) {
    printf("RPATH: %s\n", strtab + rpath->d_un.d_val);
  }
  return 0;
}

Tutorials

Making our own executable packer

  1. What's in a Linux executable?
  2. Running an executable without exec
  3. Position-independent code
  4. ELF relocations
  5. The simplest shared library
  6. Loading multiple ELF objects
  7. Dynamic symbol resolution
  8. Dynamic linker speed and correctness
  9. GDB scripting and Indirect functions
  10. Safer memory-mapped structures
  11. More ELF relocations
  12. A no_std Rust binary
  13. Thread-local storage

See also

Favorite site

References


  1. Fasterthanli.me-20201112.zip ↩

  2. Egloos.zum.com-Linker_ELF_and_fromelf.pdf ↩

  3. Embedded_Systems_Lab-ELF_File_Format_0.pdf ↩

  4. What_is_ELF.pdf ↩

  5. Acronyms_relevant_to_Executable_and_Linkable_Format.pdf ↩

author Zer0 sitemap