]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
tc, bpf: give some more hints wrt false relos
authorDaniel Borkmann <daniel@iogearbox.net>
Sun, 7 Feb 2016 01:11:52 +0000 (02:11 +0100)
committerStephen Hemminger <stephen@networkplumber.org>
Sun, 7 Feb 2016 19:27:38 +0000 (11:27 -0800)
Provide some more hints to the user/developer when relos have been found
that don't point to ld64 imm instruction. Ran couple of times into relos
generated by clang [1], where the compiler tried to uninline inlined
functions with eBPF and emitted BPF_JMP | BPF_CALL opcodes. If this seems
the case, give a hint that the user should do a work-around to use
always_inline annotation.

  [1] https://llvm.org/bugs/show_bug.cgi?id=26243#c3

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
tc/tc_bpf.c

index a1286baab20f3fdb900a0a822ceed8451405994d..5e80d0f98483d0bba2ad750ae4b0d37514d3f409 100644 (file)
@@ -1385,8 +1385,16 @@ static int bpf_apply_relo_data(struct bpf_elf_ctx *ctx,
 
                ioff = relo.r_offset / sizeof(struct bpf_insn);
                if (ioff >= num_insns ||
-                   insns[ioff].code != (BPF_LD | BPF_IMM | BPF_DW))
+                   insns[ioff].code != (BPF_LD | BPF_IMM | BPF_DW)) {
+                       fprintf(stderr, "ELF contains relo data for non ld64 "
+                               "instruction at offset %u! Compiler bug?!\n",
+                               ioff);
+                       if (ioff < num_insns &&
+                           insns[ioff].code == (BPF_JMP | BPF_CALL))
+                               fprintf(stderr, " - Try to annotate functions "
+                                       "with always_inline attribute!\n");
                        return -EINVAL;
+               }
 
                if (gelf_getsym(ctx->sym_tab, GELF_R_SYM(relo.r_info), &sym) != &sym)
                        return -EIO;