Reading — step 1 of 5
Read
~1 min readELF Format
ELF: Executable & Linkable Format
ELF (Executable and Linkable Format) is the file format for executables, shared libraries, and object files on Linux/BSD/Solaris/most UNIX-likes.
Three roles:
- Object file (
.o): output of assembler. Has unresolved symbols + relocations. - Executable: ready to run. Resolved.
- Shared library (
.so): position-independent code, loaded into other processes.
Same format, different use.
Why ELF?
- Standardized (System V ABI).
- Flexible: arbitrary number of sections.
- Extensible: vendor-specific data.
- Compact: minimal overhead.
Compare:
- PE (Portable Executable): Windows.
- Mach-O: macOS / iOS.
- a.out: ancient UNIX.
Tools:
readelf -a foo.elf: dump everything.objdump -d foo.elf: disassemble.nm foo.o: list symbols.file foo: identify type.
ELF is what the kernel's execve() reads. The loader walks the ELF, maps segments into memory, applies relocations, and jumps to entry point.
We'll build an ELF parser + loader: read an ELF file, set up memory, jump to start. Same logic as ld-linux.so (the dynamic linker) and the kernel's binfmt_elf.
Reference: System V ABI / Linux Generic ABI specs.
Discussion
Ask a question, share an insight, or help someone who’s stuck.
Sign in to post a comment or reply.
Loading…