• Wang Nan's avatar
    perf test: Add libbpf relocation checker · 7b6982ce
    Wang Nan authored
    There's a bug in LLVM that it can generate unneeded relocation
    information. See [1] and [2]. Libbpf should check the target section of
    a relocation symbol.
    
    This patch adds a testcase which references a global variable (BPF
    doesn't support global variables). Before fixing libbpf, the new test
    case can be loaded into kernel, the global variable acts like the first
    map. It is incorrect.
    
    Result:
    
      # ~/perf test BPF
      37: Test BPF filter                                          :
      37.1: Test basic BPF filtering                               : Ok
      37.2: Test BPF prologue generation                           : Ok
      37.3: Test BPF relocation checker                            : FAILED!
    
      # ~/perf test -v BPF
      ...
      libbpf: loading object '[bpf_relocation_test]' from buffer
      libbpf: section .strtab, size 126, link 0, flags 0, type=3
      libbpf: section .text, size 0, link 0, flags 6, type=1
      libbpf: section .data, size 0, link 0, flags 3, type=1
      libbpf: section .bs...
    7b6982ce
bpf-script-test-relocation.c 1.26 KB