1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-18 10:32:48 +02:00
llvm-mirror/lib/ExecutionEngine/RuntimeDyld
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
..
Targets [RuntimeDyld][COFF] Report fatal error on error, rather than emiting diagnostic. 2020-10-06 15:16:29 -07:00
CMakeLists.txt llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
JITSymbol.cpp [ORC] Honor linker private global prefix on symbol names. 2020-06-15 10:28:36 -07:00
RTDyldMemoryManager.cpp [CMake][ExecutionEngine] add HAVE_(DE)REGISTER_FRAME as a config.h macros 2020-11-10 13:09:44 -05:00
RuntimeDyld.cpp [RuntimeDyld] Add allowStubs/allowZeroSyms 2021-05-18 11:35:27 -07:00
RuntimeDyldChecker.cpp [JITLink] Switch from StringRef to ArrayRef<char>, add some generic x86-64 utils 2021-03-30 21:07:24 -07:00
RuntimeDyldCheckerImpl.h
RuntimeDyldCOFF.cpp [Object] Change ObjectFile::getSymbolValue() return type to Expected<uint64_t> 2020-05-02 14:04:44 +08:00
RuntimeDyldCOFF.h [RuntimeDyld][COFF] Build stubs for COFF dllimport symbols. 2020-03-10 16:08:40 -07:00
RuntimeDyldELF.cpp BPF: Add more relocation kinds 2021-05-25 08:19:13 -07:00
RuntimeDyldELF.h RuntimeDyldELF.h - make the object namespace explicit for ELFObjectFileBase. NFC. 2020-04-23 13:52:49 +01:00
RuntimeDyldImpl.h [RuntimeDyld] Fixed buffer overflows with absolute symbols 2021-04-26 19:24:03 +02:00
RuntimeDyldMachO.cpp AArch64: support arm64_32, an ILP32 slice for watchOS. 2019-09-12 10:22:23 +00:00
RuntimeDyldMachO.h