BPF: Add more relocation kindsCurrently, BPF only contains three relocations: R_BPF_NONE for no relocation R_BPF_64_64 for LD_imm64 and normal 64-bit data relocation R_BPF_64_32 for call
BPF: Add more relocation kindsCurrently, BPF only contains three relocations: R_BPF_NONE for no relocation R_BPF_64_64 for LD_imm64 and normal 64-bit data relocation R_BPF_64_32 for call insn and normal 32-bit data relocationAlso .BTF and .BTF.ext sections contain symbols in allocatedprogram and data sections. These two sections reserved 32bitspace to hold the offset relative to the symbol's section.When LLVM JIT is used, the LLVM ExecutionEngine RuntimeDyldmay attempt to resolve relocations for .BTF and .BTF.ext,which we want to prevent. So we used R_BPF_NONE for such relocations.This all works fine until when we try to do linking ofmultiple objects. . R_BPF_64_64 handling of LD_imm64 vs. normal 64-bit data is different, so lld target->relocate() needs more context to do a correct job. . The same for R_BPF_64_32. More context is needed for lld target->relocate() to differentiate call insn vs. normal 32-bit data relocation. . Since relocations in .BTF and .BTF.ext are set to R_BPF_NONE, they will not be relocated properly when multiple .BTF/.BTF.ext sections are merged by lld.This patch intends to address this issue by adding additionalrelocation kinds: R_BPF_64_ABS64 for normal 64-bit data relocation R_BPF_64_ABS32 for normal 32-bit data relocation R_BPF_64_NODYLD32 for .BTF and .BTF.ext style relocations.The old R_BPF_64_{64,32} semantics: R_BPF_64_64 for LD_imm64 relocation R_BPF_64_32 for call insn relocationThe existing R_BPF_64_64/R_BPF_64_32 mapping to numeric valuesis maintained. They are the most common use cases forbpf programs and we want to maintain backward compatibilityas much as possible.ExecutionEngine RuntimeDyld BPF relocations are adjusted as well.R_BPF_64_{ABS64,ABS32} relocations will be resolved properly andother relocations will be ignored.Two tests are added for RuntimeDyld. Not handling R_BPF_64_NODYLD32 inRuntimeDyldELF.cpp will result in "Relocation type not implemented yet!"fatal error.FK_SecRel_4 usages in BPFAsmBackend.cpp and BPFELFObjectWriter.cppare removed as they are not triggered in BPF backend.BPF backend used FK_SecRel_8 for LD_imm64 instruction operands.Differential Revision: https://reviews.llvm.org/D102712
show more ...