objtool: Find unused ENDBR instructions

Find all ENDBR instructions which are never referenced and stick them
in a section such that the kernel can poison them, sealing the
functions from ever being an indirect call target.

This removes about 1-in-4 ENDBR instructions.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lore.kernel.org/r/20220308154319.763643193@infradead.org
This commit is contained in:
Peter Zijlstra
2022-03-08 16:30:55 +01:00
parent 08f87a93c8
commit 89bc853eae
4 changed files with 78 additions and 2 deletions

View File

@@ -26,6 +26,7 @@ struct objtool_file {
struct list_head retpoline_call_list;
struct list_head static_call_list;
struct list_head mcount_loc_list;
struct list_head endbr_list;
bool ignore_unreachables, c_file, hints, rodata;
unsigned int nr_endbr;