1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-22 04:22:57 +02:00
llvm-mirror/lib/Target/BPF
Yonghong Song bd27c2c168 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 <yhs@fb.com>
llvm-svn: 340455
2018-08-22 21:21:03 +00:00
..
AsmParser
Disassembler
InstPrinter
MCTargetDesc bpf: fix an assertion in BPFAsmBackend applyFixup() 2018-08-22 21:21:03 +00:00
TargetInfo
BPF.h
BPF.td
BPFAsmPrinter.cpp
BPFCallingConv.td
BPFFrameLowering.cpp
BPFFrameLowering.h
BPFInstrFormats.td
BPFInstrInfo.cpp bpf: add missing RegState to notify MachineInstr verifier necessary register usage 2018-07-27 16:58:52 +00:00
BPFInstrInfo.h bpf: new option -bpf-expand-memcpy-in-order to expand memcpy in order 2018-07-25 22:40:02 +00:00
BPFInstrInfo.td bpf: new option -bpf-expand-memcpy-in-order to expand memcpy in order 2018-07-25 22:40:02 +00:00
BPFISelDAGToDAG.cpp
BPFISelLowering.cpp bpf: new option -bpf-expand-memcpy-in-order to expand memcpy in order 2018-07-25 22:40:02 +00:00
BPFISelLowering.h bpf: new option -bpf-expand-memcpy-in-order to expand memcpy in order 2018-07-25 22:40:02 +00:00
BPFMCInstLower.cpp
BPFMCInstLower.h
BPFMIPeephole.cpp
BPFRegisterInfo.cpp
BPFRegisterInfo.h
BPFRegisterInfo.td
BPFSelectionDAGInfo.cpp bpf: new option -bpf-expand-memcpy-in-order to expand memcpy in order 2018-07-25 22:40:02 +00:00
BPFSelectionDAGInfo.h bpf: new option -bpf-expand-memcpy-in-order to expand memcpy in order 2018-07-25 22:40:02 +00:00
BPFSubtarget.cpp
BPFSubtarget.h bpf: new option -bpf-expand-memcpy-in-order to expand memcpy in order 2018-07-25 22:40:02 +00:00
BPFTargetMachine.cpp
BPFTargetMachine.h
CMakeLists.txt bpf: new option -bpf-expand-memcpy-in-order to expand memcpy in order 2018-07-25 22:40:02 +00:00
LLVMBuild.txt