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
- [Recommended] Making our own executable packer 1 (archive)
- What's in a Linux executable?
- Running an executable without exec
- Position-independent code
- ELF relocations
- The simplest shared library
- Loading multiple ELF objects
- Dynamic symbol resolution
- Dynamic linker speed and correctness
- GDB scripting and Indirect functions
- Safer memory-mapped structures
- More ELF relocations
- A no_std Rust binary
- Thread-local storage
See also
Favorite site
- Wikipedia (en) description of ELF
- Wrapping up the Linker - all the way to ELF and fromelf! 2
- ELF File Format 3
- SPARC Assembler Memory Map
- What is ELF? 4
- Executable and Linkable Format (ELF) 5
References
Pages that link here