[llvm] [BPF] Support Jump Table (PR #149715)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 21 08:02:37 PDT 2025


yonghong-song wrote:

> All looks to be compiling properly, I should be able to make this work altogether.
> 
> I have two questions & nits below, will split them in two comments.
> 
> Question 1: For switches and for computed goto relocations look a bit different. Switch:
> 
> ```
>        4:       18 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 r2 = 0x0 ll
>                 0000000000000020:  R_BPF_64_64  BPF.JT.0.0
> ```
> 
> computed gotos:
> 
> ```
>       55:       18 02 00 00 28 00 00 00 00 00 00 00 00 00 00 00 r2 = 0x28 ll
>                 00000000000001b8:  R_BPF_64_64  .jumptables
> ...
>       63:       18 01 00 00 38 00 00 00 00 00 00 00 00 00 00 00 r1 = 0x38 ll
>                 00000000000001f8:  R_BPF_64_64  .jumptables
> ```
> 
> The latter two point to properly defined symbols:
> 
> ```
>      3: 0000000000000028    16 OBJECT  LOCAL  DEFAULT     5 __const.simple_test.jt1
>      4: 0000000000000038    16 OBJECT  LOCAL  DEFAULT     5 __const.simple_test.jt2
> ```
> 
> but this is another step to find those? Can relocation point to the symbol directly as with the switch?

This part is generated by the compiler directly and the bpf backend is not involved. I need to do some investigation to find out why and whether we could make a change to relocate to the symbol directly or not.

https://github.com/llvm/llvm-project/pull/149715


More information about the llvm-commits mailing list