Skip to content

Commit 530b4dd

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
objtool: Handle per arch retpoline naming
The __x86_indirect_ naming is obviously not generic. Shorten to allow matching some additional magic names later. Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Reviewed-by: Miroslav Benes <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent bcb1b6f commit 530b4dd

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

tools/objtool/arch/x86/decode.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,3 +648,8 @@ int arch_decode_hint_reg(struct instruction *insn, u8 sp_reg)
648648

649649
return 0;
650650
}
651+
652+
bool arch_is_retpoline(struct symbol *sym)
653+
{
654+
return !strncmp(sym->name, "__x86_indirect_", 15);
655+
}

tools/objtool/check.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,11 @@ static int add_ignore_alternatives(struct objtool_file *file)
850850
return 0;
851851
}
852852

853+
__weak bool arch_is_retpoline(struct symbol *sym)
854+
{
855+
return false;
856+
}
857+
853858
/*
854859
* Find the destination instructions for all jumps.
855860
*/
@@ -872,7 +877,7 @@ static int add_jump_destinations(struct objtool_file *file)
872877
} else if (reloc->sym->type == STT_SECTION) {
873878
dest_sec = reloc->sym->sec;
874879
dest_off = arch_dest_reloc_offset(reloc->addend);
875-
} else if (!strncmp(reloc->sym->name, "__x86_indirect_thunk_", 21)) {
880+
} else if (arch_is_retpoline(reloc->sym)) {
876881
/*
877882
* Retpoline jumps are really dynamic jumps in
878883
* disguise, so convert them accordingly.
@@ -1026,7 +1031,7 @@ static int add_call_destinations(struct objtool_file *file)
10261031
return -1;
10271032
}
10281033

1029-
} else if (!strncmp(reloc->sym->name, "__x86_indirect_thunk_", 21)) {
1034+
} else if (arch_is_retpoline(reloc->sym)) {
10301035
/*
10311036
* Retpoline calls are really dynamic calls in
10321037
* disguise, so convert them accordingly.

tools/objtool/include/objtool/arch.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,6 @@ const char *arch_nop_insn(int len);
8686

8787
int arch_decode_hint_reg(struct instruction *insn, u8 sp_reg);
8888

89+
bool arch_is_retpoline(struct symbol *sym);
90+
8991
#endif /* _ARCH_H */

0 commit comments

Comments
 (0)