[PATCH v3 04/11] objtool: Pass the objtool_file to arch_support_alt_relocation()

From: Shivang Upadhyay

Date: Wed Dec 02 2026 - 02:42:19 EST


arch_support_alt_relocation() is called for each PC-relative relocation
in the replacement code of an alternative. It only gets the special_alt,
the instruction and the relocation, which is enough to tell whether an
arch can cope with it, but not to act on it: an arch that wants to fix
the instruction up has no way to reach the ELF file.

Pass the objtool_file along. No functional change. Will be utilized in
next patches.

Signed-off-by: Shivang Upadhyay <shivangu@xxxxxxxxxxxxx>
---
tools/objtool/arch/loongarch/special.c | 3 ++-
tools/objtool/arch/powerpc/special.c | 3 ++-
tools/objtool/arch/x86/special.c | 3 ++-
tools/objtool/check.c | 2 +-
tools/objtool/include/objtool/special.h | 3 ++-
5 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/tools/objtool/arch/loongarch/special.c b/tools/objtool/arch/loongarch/special.c
index aba774109437..585ba327fe86 100644
--- a/tools/objtool/arch/loongarch/special.c
+++ b/tools/objtool/arch/loongarch/special.c
@@ -3,7 +3,8 @@
#include <objtool/special.h>
#include <objtool/warn.h>

-bool arch_support_alt_relocation(struct special_alt *special_alt,
+bool arch_support_alt_relocation(struct objtool_file *file,
+ struct special_alt *special_alt,
struct instruction *insn,
struct reloc *reloc)
{
diff --git a/tools/objtool/arch/powerpc/special.c b/tools/objtool/arch/powerpc/special.c
index 8f9bf61ca089..2db320796fee 100644
--- a/tools/objtool/arch/powerpc/special.c
+++ b/tools/objtool/arch/powerpc/special.c
@@ -5,7 +5,8 @@
#include <objtool/builtin.h>


-bool arch_support_alt_relocation(struct special_alt *special_alt,
+bool arch_support_alt_relocation(struct objtool_file *file,
+ struct special_alt *special_alt,
struct instruction *insn,
struct reloc *reloc)
{
diff --git a/tools/objtool/arch/x86/special.c b/tools/objtool/arch/x86/special.c
index 1e84c81bfcd8..839997915711 100644
--- a/tools/objtool/arch/x86/special.c
+++ b/tools/objtool/arch/x86/special.c
@@ -62,7 +62,8 @@ void arch_handle_alternative(struct special_alt *alt)
prev = alt;
}

-bool arch_support_alt_relocation(struct special_alt *special_alt,
+bool arch_support_alt_relocation(struct objtool_file *file,
+ struct special_alt *special_alt,
struct instruction *insn,
struct reloc *reloc)
{
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 4ef5bf97d333..357676135680 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -1833,7 +1833,7 @@ static int handle_group_alt(struct objtool_file *file,
*/
alt_reloc = insn_reloc(file, insn);
if (alt_reloc && arch_pc_relative_reloc(alt_reloc) &&
- !arch_support_alt_relocation(special_alt, insn, alt_reloc)) {
+ !arch_support_alt_relocation(file, special_alt, insn, alt_reloc)) {

ERROR_INSN(insn, "unsupported relocation in alternatives section");
return -1;
diff --git a/tools/objtool/include/objtool/special.h b/tools/objtool/include/objtool/special.h
index 620dbf6cb0e5..eeaed4e62b86 100644
--- a/tools/objtool/include/objtool/special.h
+++ b/tools/objtool/include/objtool/special.h
@@ -39,7 +39,8 @@ void arch_handle_alternative(struct special_alt *alt);
*/
bool arch_alt_ignore_new_reloc(struct section *sec, unsigned long offset);

-bool arch_support_alt_relocation(struct special_alt *special_alt,
+bool arch_support_alt_relocation(struct objtool_file *file,
+ struct special_alt *special_alt,
struct instruction *insn,
struct reloc *reloc);
struct reloc *arch_find_switch_table(struct objtool_file *file,
--
2.56.1