]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
objtool: Rewrite jump_label instructions
authorPeter Zijlstra <peterz@infradead.org>
Thu, 6 May 2021 19:34:03 +0000 (21:34 +0200)
committerIngo Molnar <mingo@kernel.org>
Wed, 12 May 2021 12:54:56 +0000 (14:54 +0200)
When a jump_entry::key has bit1 set, rewrite the instruction to be a
NOP. This allows the compiler/assembler to emit JMP (and thus decide
on which encoding to use).

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20210506194158.091028792@infradead.org
tools/objtool/check.c

index 9ed1a4cd00dc0dce8690493f77bade0bd6ff3339..98cf87f2c5019da32d724e2859ae90acc7f11eab 100644 (file)
@@ -1234,6 +1234,20 @@ static int handle_jump_alt(struct objtool_file *file,
                return -1;
        }
 
+       if (special_alt->key_addend & 2) {
+               struct reloc *reloc = insn_reloc(file, orig_insn);
+
+               if (reloc) {
+                       reloc->type = R_NONE;
+                       elf_write_reloc(file->elf, reloc);
+               }
+               elf_write_insn(file->elf, orig_insn->sec,
+                              orig_insn->offset, orig_insn->len,
+                              arch_nop_insn(orig_insn->len));
+               orig_insn->type = INSN_NOP;
+               return 0;
+       }
+
        *new_insn = list_next_entry(orig_insn, list);
        return 0;
 }