summaryrefslogtreecommitdiffstats
path: root/samples
diff options
context:
space:
mode:
authorAlexei Starovoitov <ast@fb.com>2016-11-23 01:52:09 +0100
committerDavid S. Miller <davem@davemloft.net>2016-11-24 22:04:52 +0100
commitdb6a71dd9a75fb07f6758582299acfe1ab5827dc (patch)
treec666faa713221f3177d849f99b16ad3428d7d684 /samples
parentsamples/bpf: fix sockex2 example (diff)
downloadlinux-db6a71dd9a75fb07f6758582299acfe1ab5827dc.tar.xz
linux-db6a71dd9a75fb07f6758582299acfe1ab5827dc.zip
samples/bpf: fix bpf loader
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 <ast@kernel.org> Acked-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'samples')
-rw-r--r--samples/bpf/bpf_load.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/samples/bpf/bpf_load.c b/samples/bpf/bpf_load.c
index 97913e109b14..62f54d6eb8bf 100644
--- a/samples/bpf/bpf_load.c
+++ b/samples/bpf/bpf_load.c
@@ -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;