Understanding Program Execution: What Happens Between execve() and main() in Linux
By
amitprasad
Pulled from the oven just right. Trustworthy, fact-dense, deeply satisfying.
Summary
This technical blog post explores the complex process that occurs between when the Linux kernel is asked to execute a program via the execve system call and when the program's main() function actually begins execution. The author shares insights gained from working on a RISC-V-based userspace simulator, detailing the sequence of events including ELF file loading, dynamic linking, and program initialization that happens before main() runs.
Key quotes
· 4 pulledtaught myself a lot more than I wanted to know about what happens in-between when the Kernel is asked to run a program, and when the first line of our program's main function is actually executed
When is the OS kernel actually asked to run any program? The answer, at least on Linux, is the execve system call
Here's a summary of that rabbit hole
This is actually quite straightforward! We pass the name of the executable file, a list
You might also wanna read
Restartable Sequences: A Linux Kernel Feature for Lock-Free Thread-Safe Programming
This article explores restartable sequences (rseq), a Linux kernel feature introduced in version 4.18 (circa 2018) that enables creation of
Zig Days: Collaborative Full-Day Programming Events for the Zig Community
Zig Days are full-day collaborative programming events organized by the Zig community, typically held on Saturdays. Participants meet in the
Spectre Programming Language Documentation: A Contract-Based Approach to Safe Low-Level Systems Programming
Spectre is a contract-based programming language designed for safe low-level systems programming. It enforces correctness through type-level
A Grounded Conceptual Model for Ownership Types in Rust Programming
This article presents a grounded conceptual model for ownership types in Rust, the programming language known for memory safety without garb
Rail: A Self-Hosting Systems Programming Language with Pure-Rail TLS 1.3 Implementation
Rail is a self-hosting systems programming language that compiles itself without any C dependencies. The compiler is written in Rail and pro
Solod: A Go Subset That Compiles to C for Systems Programming
Solod is a strict subset of the Go programming language that compiles to regular C code, designed for systems programming with manual memory
