14 Feb 1990
Executing and ELF
Steps of the execution
- The shell makes an
execvcsystem call to run an executable binary, and the kernel responds withsys_execvewhich calls thedo_execvefunction. - It opens the executable binary and does some preparation. It calls
search_binary_handler. That will callload_elf_binaryin our case. - It allocates memory segments for the program headers and zeroes out the BSS section by calling the
padzerofunction. load_elf_binaryalso checks for the INTERP segment. According to AMD64 SysV ABI, the only valid interpreter is/lib/ld64.so.1.- If there's a loader, it'll call
load_elf_interpfunction to load the interpreter as well. - Finally it calls
start_threadand passes control to either the binary or the interpreter.
