diff --git a/tools/objtool/arch/powerpc/special.c b/tools/objtool/arch/powerpc/special.c
index 51610689abf7..0b3a766c4842 100644
--- a/tools/objtool/arch/powerpc/special.c
+++ b/tools/objtool/arch/powerpc/special.c
@@ -14,7 +14,8 @@ bool arch_support_alt_relocation(struct special_alt *special_alt,
struct reloc *arch_find_switch_table(struct objtool_file *file,
struct instruction *insn,
- unsigned long *table_size)
+ unsigned long *table_size,
+ struct instruction *orig_insn)
{
exit(-1);
}diff --git a/tools/objtool/arch/x86/special.c b/tools/objtool/arch/x86/special.c
index 76c7933bcb19..b0147923a70c 100644
--- a/tools/objtool/arch/x86/special.c
+++ b/tools/objtool/arch/x86/special.c
@@ -110,7 +110,8 @@ bool arch_support_alt_relocation(struct special_alt *special_alt,
*/
struct reloc *arch_find_switch_table(struct objtool_file *file,
struct instruction *insn,
- unsigned long *table_size)
+ unsigned long *table_size,
+ struct instruction *orig_insn)
{
struct reloc *text_reloc, *rodata_reloc;
struct section *table_sec;diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 613d169eb6b8..72b977f81dd6 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -81,8 +81,8 @@ static struct instruction *next_insn_same_func(struct objtool_file *file,
return find_insn(file, func->cfunc->sec, func->cfunc->offset);
}
-static struct instruction *prev_insn_same_sec(struct objtool_file *file,
- struct instruction *insn)
+struct instruction *prev_insn_same_sec(struct objtool_file *file,
+ struct instruction *insn)
{
if (insn->idx == 0) {
if (insn->prev_len)@@ -2028,7 +2028,8 @@ static void find_jump_table(struct objtool_file *file, struct symbol *func,
insn && insn_func(insn) && insn_func(insn)->pfunc == func;
insn = insn->first_jump_src ?: prev_insn_same_sym(file, insn)) {
- if (insn != orig_insn && insn->type == INSN_JUMP_DYNAMIC)
+ if (insn != orig_insn && insn->type == INSN_JUMP_DYNAMIC &&
+ insn->gpr == orig_insn->gpr)
break;
/* allow small jumps within the range */@@ -2038,7 +2039,7 @@ static void find_jump_table(struct objtool_file *file, struct symbol *func,
insn->jump_dest->offset > orig_insn->offset))
break;
- table_reloc = arch_find_switch_table(file, insn, &table_size);
+ table_reloc = arch_find_switch_table(file, insn, &table_size, orig_insn);
if (!table_reloc)
continue;
diff --git a/tools/objtool/include/objtool/check.h b/tools/objtool/include/objtool/check.h
index e1cd13cd28a3..8b68f840dddb 100644
--- a/tools/objtool/include/objtool/check.h
+++ b/tools/objtool/include/objtool/check.h
@@ -63,8 +63,9 @@ struct instruction {
noendbr : 1,
unret : 1,
visited : 4,
- no_reloc : 1;
- /* 10 bit hole */
+ no_reloc : 1,
+ gpr : 5;
+ /* 5 bit hole */
struct alt_group *alt_group;
struct instruction *jump_dest;@@ -118,6 +119,7 @@ struct instruction *find_insn(struct objtool_file *file,
struct section *sec, unsigned long offset);
struct instruction *next_insn_same_sec(struct objtool_file *file, struct instruction *insn);
+struct instruction *prev_insn_same_sec(struct objtool_file *file, struct instruction *insn);
#define sec_for_each_insn(file, _sec, insn) \
for (insn = find_insn(file, _sec, 0); \
diff --git a/tools/objtool/include/objtool/special.h b/tools/objtool/include/objtool/special.h
index e7ee7ffccefd..aca1f7762f5d 100644
--- a/tools/objtool/include/objtool/special.h
+++ b/tools/objtool/include/objtool/special.h
@@ -39,5 +39,6 @@ bool arch_support_alt_relocation(struct special_alt *special_alt,
struct reloc *reloc);
struct reloc *arch_find_switch_table(struct objtool_file *file,
struct instruction *insn,
- unsigned long *table_size);
+ unsigned long *table_size,
+ struct instruction *orig_insn);
#endif /* _SPECIAL_H */
--
2.47.0