diff --git a/0001-Merging-r340455.patch b/0001-Merging-r340455.patch new file mode 100644 index 0000000..09485ba --- /dev/null +++ b/0001-Merging-r340455.patch @@ -0,0 +1,82 @@ +From 34940cd4ee42f59e0035e2778b307c8dc4e1b5ac Mon Sep 17 00:00:00 2001 +From: Hans Wennborg +Date: Thu, 30 Aug 2018 08:42:29 +0000 +Subject: [PATCH] Merging r340455: + ------------------------------------------------------------------------ + r340455 | yhs | 2018-08-22 23:21:03 +0200 (Wed, 22 Aug 2018) | 38 lines + +bpf: fix an assertion in BPFAsmBackend applyFixup() + +Fix bug https://bugs.llvm.org/show_bug.cgi?id=38643 + +In BPFAsmBackend applyFixup(), there is an assertion for FixedValue to be 0. +This may not be true, esp. for optimiation level 0. +For example, in the above bug, for the following two +static variables: + @bpf_map_lookup_elem = internal global i8* (i8*, i8*)* + inttoptr (i64 1 to i8* (i8*, i8*)*), align 8 + @bpf_map_update_elem = internal global i32 (i8*, i8*, i8*, i64)* + inttoptr (i64 2 to i32 (i8*, i8*, i8*, i64)*), align 8 + +The static variable @bpf_map_update_elem will have a symbol +offset of 8 and a FK_SecRel_8 with FixupValue 8 will cause +the assertion if llvm is built with -DLLVM_ENABLE_ASSERTIONS=ON. + +The above relocations will not exist if the program is compiled +with optimization level -O1 and above as the compiler optimizes +those static variables away. In the below error message, -O2 +is suggested as this is the common practice. + +Note that FixedValue = 0 in applyFixup() does exist and is valid, +e.g., for the global variable my_map in the above bug. The bpf +loader will process them properly for map_id's before loading +the program into the kernel. + +The static variables, which are not optimized away by compiler, +may have FK_SecRel_8 relocation with non-zero FixedValue. + +The patch removed the offending assertion and will issue +a hard error as below if the FixedValue in applyFixup() +is not 0. + $ llc -march=bpf -filetype=obj fixup.ll + LLVM ERROR: Unsupported relocation: try to compile with -O2 or above, + or check your static variable usage + +Signed-off-by: Yonghong Song +------------------------------------------------------------------------ + +git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_70@341038 91177308-0d34-0410-b5e6-96231b3b80d8 +--- + lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +diff --git a/lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp b/lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp +index 6593d9d..4566cbc 100644 +--- a/lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp ++++ b/lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp +@@ -10,6 +10,8 @@ + #include "MCTargetDesc/BPFMCTargetDesc.h" + #include "llvm/ADT/StringRef.h" + #include "llvm/MC/MCAsmBackend.h" ++#include "llvm/MC/MCAssembler.h" ++#include "llvm/MC/MCContext.h" + #include "llvm/MC/MCFixup.h" + #include "llvm/MC/MCObjectWriter.h" + #include +@@ -68,7 +70,12 @@ void BPFAsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, + MutableArrayRef Data, uint64_t Value, + bool IsResolved) const { + if (Fixup.getKind() == FK_SecRel_4 || Fixup.getKind() == FK_SecRel_8) { +- assert(Value == 0); ++ if (Value) { ++ MCContext &Ctx = Asm.getContext(); ++ Ctx.reportError(Fixup.getLoc(), ++ "Unsupported relocation: try to compile with -O2 or above, " ++ "or check your static variable usage"); ++ } + } else if (Fixup.getKind() == FK_Data_4 || Fixup.getKind() == FK_Data_8) { + unsigned Size = Fixup.getKind() == FK_Data_4 ? 4 : 8; + +-- +1.8.3.1 + diff --git a/llvm.spec b/llvm.spec index 9b2cd13..38bd75d 100644 --- a/llvm.spec +++ b/llvm.spec @@ -31,7 +31,7 @@ Name: %{pkg_name} Version: %{maj_ver}.%{min_ver}.%{patch_ver} -Release: 7%{?dist} +Release: 8%{?dist} Summary: The Low Level Virtual Machine License: NCSA @@ -47,6 +47,7 @@ Patch9: 0001-Export-LLVM_DYLIB_COMPONENTS-in-LLVMConfig.cmake.patch Patch10: 0001-Don-t-run-BV-DAG-Combine-before-legalization-if-it-a.patch Patch11: 0001-PowerPC-Do-not-round-values-prior-to-converting-to-i.patch Patch12: 0001-SystemZ-TableGen-Fix-shift-count-handling.patch +Patch13: 0001-Merging-r340455.patch BuildRequires: gcc BuildRequires: gcc-c++ @@ -315,6 +316,9 @@ fi %endif %changelog +* Wed Sep 26 2018 Tom Stellard - 6.0.1-8 +- BPF unknown opcode fix: rhbz#1618958 + * Wed Aug 29 2018 Tom Stellard - 6.0.1-7 - Build the gold plugin on all supported architectures