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

Anton Protopopov via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 21 01:59:48 PDT 2025


aspsk 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`

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


More information about the llvm-commits mailing list