[all-commits] [llvm/llvm-project] 7272a6: [BPF] Avoid relocation for jumptable entries (#166...

yonghong-song via All-commits all-commits at lists.llvm.org
Tue Nov 4 11:32:33 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 7272a6c8882d99fe1fc73d2c69ddf976948f0e50
      https://github.com/llvm/llvm-project/commit/7272a6c8882d99fe1fc73d2c69ddf976948f0e50
  Author: yonghong-song <yhs at fb.com>
  Date:   2025-11-04 (Tue, 04 Nov 2025)

  Changed paths:
    M llvm/lib/Target/BPF/BPFAsmPrinter.cpp
    M llvm/test/CodeGen/BPF/jump_table_blockaddr.ll
    M llvm/test/CodeGen/BPF/jump_table_global_var.ll
    M llvm/test/CodeGen/BPF/jump_table_switch_stmt.ll

  Log Message:
  -----------
  [BPF] Avoid relocation for jumptable entries (#166301)

Currently, the jump table entry contains labels only. For example, the
following is one example:

  BPF.JT.0.0:
        .quad   LBB0_1
        .quad   LBB0_2
        .size   BPF.JT.0.0, 16

Since the jump table entry contains a label, the relocation is necessary
so linker can resolve the label value. The relocation looks like below:

  Relocation section '.rel.jumptables' at offset 0x160 contains 2 entries:
      Offset             Info             Type               Symbol's Value  Symbol's Name
  0000000000000000  0000000200000002 R_BPF_64_ABS64         0000000000000000 .text
  0000000000000008  0000000200000002 R_BPF_64_ABS64         0000000000000000 .text

You can see that the symbol value is 0 which makes .rel.jumptables not
very useful.

Instead of having the label itself in the jump table entry, use the
difference of label and the section begin symbol. This can avoid the
relocation and the eventual jumptable entries in object file remains the
same as before.

  Hex dump of section '.jumptables':
  0x00000000 68000000 00000000 78000000 00000000 h.......x.......



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list