Skip to main content

26 Function Calls

The following pseudoinstructions are available to call subroutines far from the current position:

  • call \<symbol\>: call away subroutine

  • call \<rd\>, \<symbol\>: call away subroutine

  • tail \<symbol\>: tail call away subroutine

  • jump \<symbol\>, \<rt\>: jump to far-away label

The following example shows how these pseudoinstructions are used:

call func1
tail func2
jump func3, t0

Which generates the following assembler output and relocations as seen by objdump:

0000000000000000 \<.text>:
0: 00000097 auipc ra,0x0
0: R_RISCV_CALL func1
4: 000080e7 jalr ra # 0x0
8: 00000317 auipc t1,0x0
8: R_RISCV_CALL func2
c: 00030067 jr t1 # 0x8
10: 00000297 auipc t0,0x0
10: R_RISCV_CALL func3
14: 00028067 jr t0 # 0x10