objtool: Support retpoline jump detection for vmlinux.o
authorJosh Poimboeuf <jpoimboe@redhat.com>
Thu, 21 Jan 2021 21:29:20 +0000 (15:29 -0600)
committerJosh Poimboeuf <jpoimboe@redhat.com>
Tue, 26 Jan 2021 17:11:59 +0000 (11:11 -0600)
Objtool converts direct retpoline jumps to type INSN_JUMP_DYNAMIC, since
that's what they are semantically.

That conversion doesn't work in vmlinux.o validation because the
indirect thunk function is present in the object, so the intra-object
jump check succeeds before the retpoline jump check gets a chance.

Rearrange the checks: check for a retpoline jump before checking for an
intra-object jump.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lore.kernel.org/r/4302893513770dde68ddc22a9d6a2a04aca491dd.1611263461.git.jpoimboe@redhat.com
tools/objtool/check.c

index c964cd56b557c4f43d2618f47e82b52a007f846f..5f5949951ca76400aef96e74c41765e7f2f10a40 100644 (file)
@@ -781,10 +781,6 @@ static int add_jump_destinations(struct objtool_file *file)
                } else if (reloc->sym->type == STT_SECTION) {
                        dest_sec = reloc->sym->sec;
                        dest_off = arch_dest_reloc_offset(reloc->addend);
-               } else if (reloc->sym->sec->idx) {
-                       dest_sec = reloc->sym->sec;
-                       dest_off = reloc->sym->sym.st_value +
-                                  arch_dest_reloc_offset(reloc->addend);
                } else if (!strncmp(reloc->sym->name, "__x86_indirect_thunk_", 21) ||
                           !strncmp(reloc->sym->name, "__x86_retpoline_", 16)) {
                        /*
@@ -798,6 +794,10 @@ static int add_jump_destinations(struct objtool_file *file)
 
                        insn->retpoline_safe = true;
                        continue;
+               } else if (reloc->sym->sec->idx) {
+                       dest_sec = reloc->sym->sec;
+                       dest_off = reloc->sym->sym.st_value +
+                                  arch_dest_reloc_offset(reloc->addend);
                } else {
                        /* external sibling call */
                        insn->call_dest = reloc->sym;