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

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


yonghong-song wrote:

> Currently, jump tables contain 8 bytes per entry, is this intentional? (the offsets will never be greater than 4 bytes):
> 
> ```
> Hex dump of section '.jumptables':
> 0x00000000 48000000 00000000 c8000000 00000000 H...............
> 0x00000010 88000000 00000000 a8000000 00000000 ................
> etc.
> ```
> 
> One related bug: the size of BPF.JT.0.0 computed as it points to 4-byte entries, and the `__const.simple_test.jt*` computed as they point to 8-byte entries:
> 
> ```
> Symbol table '.symtab' contains 20 entries:
>    Num:    Value          Size Type    Bind   Vis       Ndx Name
>      0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT   UND
>      1: 0000000000000000     0 FILE    LOCAL  DEFAULT   ABS aspsk_play.c
>      2: 0000000000000000     0 SECTION LOCAL  DEFAULT     3 syscall
>      3: 0000000000000028    16 OBJECT  LOCAL  DEFAULT     5 __const.simple_test.jt1
>      4: 0000000000000038    16 OBJECT  LOCAL  DEFAULT     5 __const.simple_test.jt2
> ...
>     16: 0000000000000000    20 NOTYPE  GLOBAL DEFAULT     5 BPF.JT.0.0
> ```
> 
> ^ here the first two have size 2 (as in your example above), the BPF.JT.0.0 actually has size 5 (a switch from my test). However, symbol size of it is `20 = 5*4`, while for `__const.simple_test.jt1` it is `16 = 2*8`

Thanks. I will fix the bug. Regarding why we have 8 byte jump table entry. I guess this is probably due to the address is calculated from the start of the section.

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


More information about the llvm-commits mailing list