Code created during recording the Writing a Linux ELF Binary by Hand video.
We write a 164 bytes long x86-64 ELF binary. A proper hello world executable.
Just a C compiler.
gcc -std=c17 -o main ./main.c
gcc -std=c17 -static -o main ./main.c
nasm -felf64 -o hello_asm.o ./hello_asm.asm
ld -o hello_asm ./hello_asm.o
objdump -d -M intel ./hello_asm
gcc -std=c17 -o elf ./elf.c
./elf
chmod a+x ./bin
./bin
readelf -h ./bin
readelf -l ./bin
hexdump -C ./bin
cat /proc/[pid]/maps
man 5 elf
man 2 write
man 2 exit
Online man page: man 5 elf
To Download the Intel Manuals: Intel Manuals
Linux Kernel's program loader code: https://github.com/torvalds/linux/blob/master/fs/binfmt_elf.c