the return address
When you pause your own work to ask a colleague a question, you keep a finger on the line you were reading so you can resume exactly there. The return address is that finger, for a function call. It is the memory address of the instruction immediately after the call: the spot the processor must jump back to once the called function finishes, so the caller picks up precisely where it paused.
When a call instruction runs, the hardware computes the return address automatically (it is just the address of the call plus the size of one instruction) and stashes it somewhere safe. On RISC-V that somewhere is a register named ra, set by the jal instruction; returning is jumping back to whatever address ra holds. The catch is that ra is a single register. If the called function turns around and calls something else, that second call overwrites ra with a new return address. So a function that makes nested calls must first save its own ra onto the stack, do its work, then restore ra before returning. Leaf functions (those that call no one) can often skip saving it.
The return address matters for correctness, performance, and security. Get it wrong and the program returns to the wrong place and crashes. It also has a dark side: because the return address sits in memory on the stack, a bug that lets an attacker overwrite it can redirect execution to code of their choosing. This is the heart of classic stack-smashing exploits, and it is why modern systems add defenses like stack canaries and shadow stacks to protect that one precious value.
A function that calls another must preserve ra: outer: addi sp, sp, -8 sd ra, 0(sp) # save my return address before I call anyone jal ra, inner # this overwrites ra with a new return address ld ra, 0(sp) # restore my own return address addi sp, sp, 8 ret # now ret goes back to outer's caller, correctly
Because ra is one register, a non-leaf function must save and restore it around inner calls.
Overwriting a saved return address is the mechanism behind buffer-overflow attacks; the return address is a security-critical value, not just a bookkeeping detail.