The ELF format
| The ELF header | |
| readelf and objdump | |
| Symbols |
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.
Next: Time and date syscalls
Article author: Arthur Isaev