FREE LESSON · Machine code & execution · 2 OF 8
Calling Conventions and Stack Frames
Calls are negotiated protocols: Calling conventions and stack frames
Separate compilation works because callers and callees agree.
A calling convention assigns argument and return locations, classifies caller- and callee-saved registers, defines stack alignment, and specifies how control returns. A stack frame may hold saved state, local storage, spilled registers, and metadata. The compiler may omit or reshape it when the observable contract still holds.
The call instruction transfers control; the convention makes that transfer interoperable.
A return address is powerful data
A call records where execution should resume, often in a register or on the stack. Corrupting it can redirect control, which is why stack bounds, non-executable memory, address randomization, control-flow protections, and memory-safe languages matter. A software convention becomes a security boundary when data controls execution.
Inspect which data can influence the next instruction; that is the heart of control-flow integrity.
Sources and further reading
- RISC-V instruction-set manual: RISC-V International
- ELF object-file specification: System V ABI · canonical specification