ra
: return addresssp
: stack pointerfp
: frame pointera0
: return value or first argumenta1 - a7
: arguments
call
just uses auipc
and jalr
.
78: 00000097 auipc ra,0x0
7c: 000080e7 jalr ra # 78 <main+0x18>
Why the auipc
offset is always 0x0
?
Add -r
to objdump
to see the relocation info.
78: 00000097 auipc ra,0x0
78: R_RISCV_CALL fn
78: R_RISCV_RELAX *ABS*
7c: 000080e7 jalr ra # 78 <main+0x18>
auipc
: add upper immediate to pcjal
: jump and linkjalr
: jump and link register
What's the difference between jal
and jalr
?
They all save the pc + 4
in a register, and jump to a new address.
jal
:pc + offset
jalr
:x[rs1] + offset
That is because the offset is not large enough.