1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 04:32:44 +01:00
llvm-mirror/lib/Target/BPF
Yonghong Song 1d0a1ee04d BPF: Add more relocation kinds
Currently, 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 relocation

Also .BTF and .BTF.ext sections contain symbols in allocated
program and data sections. These two sections reserved 32bit
space to hold the offset relative to the symbol's section.
When LLVM JIT is used, the LLVM ExecutionEngine RuntimeDyld
may 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 of
multiple 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 additional
relocation 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 relocation

The existing R_BPF_64_64/R_BPF_64_32 mapping to numeric values
is maintained. They are the most common use cases for
bpf programs and we want to maintain backward compatibility
as much as possible.

ExecutionEngine RuntimeDyld BPF relocations are adjusted as well.
R_BPF_64_{ABS64,ABS32} relocations will be resolved properly and
other relocations will be ignored.
Two tests are added for RuntimeDyld. Not handling R_BPF_64_NODYLD32 in
RuntimeDyldELF.cpp will result in "Relocation type not implemented yet!"
fatal error.

FK_SecRel_4 usages in BPFAsmBackend.cpp and BPFELFObjectWriter.cpp
are 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
2021-05-25 08:19:13 -07:00
..
AsmParser
Disassembler
MCTargetDesc BPF: Add more relocation kinds 2021-05-25 08:19:13 -07:00
TargetInfo
BPF.h
BPF.td
BPFAbstractMemberAccess.cpp BPF: fix FIELD_EXISTS relocation with array subscripts 2021-05-06 22:37:02 -07:00
BPFAdjustOpt.cpp Update BPFAdjustOpt.cpp to accept select form of or as well 2021-02-20 18:29:58 +09:00
BPFAsmPrinter.cpp
BPFCallingConv.td
BPFCheckAndAdjustIR.cpp
BPFCORE.h
BPFFrameLowering.cpp
BPFFrameLowering.h
BPFInstrFormats.td
BPFInstrInfo.cpp
BPFInstrInfo.h
BPFInstrInfo.td
BPFISelDAGToDAG.cpp
BPFISelLowering.cpp [BPF] add support for 32 bit registers in inline asm 2021-05-16 11:01:47 -07:00
BPFISelLowering.h [BPF] add support for 32 bit registers in inline asm 2021-05-16 11:01:47 -07:00
BPFMCInstLower.cpp
BPFMCInstLower.h
BPFMIChecking.cpp
BPFMIPeephole.cpp BPF: Fix a bug in peephole TRUNC elimination optimization 2021-03-02 13:03:42 -08:00
BPFMISimplifyPatchable.cpp
BPFPreserveDIType.cpp BPF: permit type modifiers for __builtin_btf_type_id() relocation 2021-03-04 16:27:23 -08:00
BPFRegisterInfo.cpp
BPFRegisterInfo.h
BPFRegisterInfo.td
BPFSelectionDAGInfo.cpp
BPFSelectionDAGInfo.h
BPFSubtarget.cpp
BPFSubtarget.h
BPFTargetMachine.cpp [NewPM] Hide pass manager debug logging behind -debug-pass-manager-verbose 2021-05-07 21:51:47 -07:00
BPFTargetMachine.h [NewPM] Hide pass manager debug logging behind -debug-pass-manager-verbose 2021-05-07 21:51:47 -07:00
BPFTargetTransformInfo.h [TTI] NFC: Change getCmpSelInstrCost to return InstructionCost 2021-04-13 14:21:01 +01:00
BTF.def [BPF] Add support for floats and doubles 2021-03-05 15:10:11 +01:00
BTF.h
BTFDebug.cpp BPF: generate BTF info for LD_imm64 loaded function pointer 2021-04-26 17:23:36 -07:00
BTFDebug.h BPF: generate BTF info for LD_imm64 loaded function pointer 2021-04-26 17:23:36 -07:00
CMakeLists.txt BPF: Add LLVMTransformUtils in CMakefile LINK_COMPONENTS 2021-02-25 15:43:25 -08:00