Identify bpf calls in ebpf programs

rbpf (https://github.com/solana-labs/rbpf) allows to register Solana-related functions via functions such as register_syscall_by_hash and register_syscall_by_name. This functionality is called from the file programs/bpf_loader/src/syscalls.rs (https://github.com/solana-labs/rbpf). However, the eBPF bytecode for CALL takes a parameter an integer. For example, this is the output of llvm-objdump on the helloworld example:

      33:	b7 02 00 00 2f 00 00 00	r2 = 47
      34:	85 10 00 00 ff ff ff ff	call -1

My question is: where in the code I can find the mapping from -1 to the corresponding function name that will be passed to register_syscall_by_name? I believe that -1 corresponds to sol_log but I would like to know the mapping for sure.

Hi @caballa and welcome to the forum! :wave:

Iā€™m not aware how the mapping works, but you might find more help on the Solana dev Discord.

Good luck!

1 Like