llvm-project
7272a6c8 - [BPF] Avoid relocation for jumptable entries (#166301)

Commit
2 days ago
[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.......
Author
Parents
Loading