Skip to content

Commit

Permalink
samples/bpf: fix bpf loader
Browse files Browse the repository at this point in the history
llvm can emit relocations into sections other than program code
(like debug info sections). Ignore them during parsing of elf file

Signed-off-by: Alexei Starovoitov <[email protected]>
Acked-by: Daniel Borkmann <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
4ast authored and davem330 committed Nov 24, 2016
1 parent d2b024d commit db6a71d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions samples/bpf/bpf_load.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,10 @@ int load_bpf_file(char *path)
&shdr_prog, &data_prog))
continue;

if (shdr_prog.sh_type != SHT_PROGBITS ||
!(shdr_prog.sh_flags & SHF_EXECINSTR))
continue;

insns = (struct bpf_insn *) data_prog->d_buf;

processed_sec[shdr.sh_info] = true;
Expand Down

0 comments on commit db6a71d

Please sign in to comment.