path: root/tools/build
diff options
authorWang Nan <>2016-01-25 09:55:49 +0000
committerArnaldo Carvalho de Melo <>2016-01-26 12:11:01 -0300
commit666810e86a3b7531cce892fbeda3b2f2322e1d72 (patch)
tree610e4acf2202a18e555135d097ad323e491f2fc2 /tools/build
parent7b6982ce4b38ecc3f63be46beb7bd079aa290fd7 (diff)
perf bpf: Check relocation target section
Libbpf should check the target section before doing relocation to ensure the relocation is correct. If not, a bug in LLVM causes an error. See [1]. Also, if an incorrect BPF script uses both global variable and map, global variable whould be treated as map and be relocated without error. This patch saves the id of the map section into obj->efile and compare target section of a relocation symbol against it during relocation. Previous patch introduces a test case about this problem. After this patch: # ~/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 : Ok # perf test -v BPF ... 37.3: Test BPF relocation checker : ... 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 .bss, size 0, link 0, flags 3, type=8 libbpf: section func=sys_write, size 104, link 0, flags 6, type=1 libbpf: found program func=sys_write libbpf: section .relfunc=sys_write, size 16, link 10, flags 0, type=9 libbpf: section maps, size 16, link 0, flags 3, type=1 libbpf: maps in [bpf_relocation_test]: 16 bytes libbpf: section license, size 4, link 0, flags 3, type=1 libbpf: license of [bpf_relocation_test] is GPL libbpf: section version, size 4, link 0, flags 3, type=1 libbpf: kernel version of [bpf_relocation_test] is 40400 libbpf: section .symtab, size 144, link 1, flags 0, type=2 libbpf: map 0 is "my_table" libbpf: collecting relocating info for: 'func=sys_write' libbpf: Program 'func=sys_write' contains non-map related relo data pointing to section 65522 bpf: failed to load buffer Compile BPF program failed. test child finished with 0 ---- end ---- Test BPF filter subtest 2: Ok [1] Signed-off-by: Wang Nan <> Acked-by: Alexei Starovoitov <> Tested-by: Arnaldo Carvalho de Melo <> Cc: "David S. Miller" <> Cc: Brendan Gregg <> Cc: Daniel Borkmann <> Cc: He Kuang <> Cc: Jiri Olsa <> Cc: Li Zefan <> Cc: Masami Hiramatsu <> Cc: Namhyung Kim <> Cc: Peter Zijlstra <> Cc: Will Deacon <> Cc: Link: Signed-off-by: Arnaldo Carvalho de Melo <>
Diffstat (limited to 'tools/build')
0 files changed, 0 insertions, 0 deletions