The ELF format

The ELF header

ELF (Executable and Linkable Format) is what nasm -f elf64 and ld produce. A header identifies the file, then program headers tell the loader where to map each segment, and section headers tell the linker where each section lives.

nasm -f elf64 -o hello.o hello.asm readelf -h hello.o

readelf and objdump

readelf shows structure: -h the header, -S the section table, -s the symbol table. objdump -d disassembles the code back to instructions, which is how you check what your assembler actually emitted:

readelf -S hello.o objdump -d hello

Symbols

global makes a symbol visible to the linker; everything else stays local to the object. extern imports a symbol from another object. The symbol table is also how gdb maps addresses back to your labels.

The code on this page was assembled with NASM 3.01 and inspected with GNU readelf and objdump 2.45.1 on Alpine Linux 3.24.3 (x86_64) in a Docker container.

Article author: Arthur Isaev