OSDN Git Service

[BPF] Disable relocation for .BTF.ext section
authorYonghong Song <yhs@fb.com>
Thu, 20 Dec 2018 17:40:23 +0000 (17:40 +0000)
committerYonghong Song <yhs@fb.com>
Thu, 20 Dec 2018 17:40:23 +0000 (17:40 +0000)
commitf1db33c5c1a9ca6a3ef5fdfd5d088836a15c9bbc
tree9a0364090a5f0a0b8c38b14d0f164e2b315f261b
parent959a4129de63789d1eea64209a733ea96cf8d24b
[BPF] Disable relocation for .BTF.ext section

Build llvm with assertion on, and then build bcc against this llvm.
Run any bcc tool with debug=8 (turning on -g for clang compilation),
you will get the following assertion errors,
  /home/yhs/work/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp:888:
  void llvm::RuntimeDyldELF::resolveBPFRelocation(const llvm::SectionEntry&, uint64_t,
    uint64_t, uint32_t, int64_t): Assertion `Value <= (4294967295U)' failed.

The .BTF.ext ELF section uses Fixup's to get the instruction
offsets. The data width of the Fixup is 4 bytes since we only need
the insn offset within the section.

This caused the above error though since R_BPF_64_32 expects
4-byte value and the Runtime Dyld tried to resolve the actual
insn address which is 8 bytes.

Actually the offset within the section is all what we need.
Therefore, there is no need to perform any kind of relocation
for .BTF.ext section and such relocation will actually cause
incorrect result.

This patch changed BPFELFObjectWriter::getRelocType() such that
for Fixup Kind FK_Data_4, if the relocation Target is a temporary
symbol, let us skip the relocation (ELF::R_BPF_NONE).

Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Yonghong Song <yhs@fb.com>
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@349778 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/BPF/MCTargetDesc/BPFELFObjectWriter.cpp