Skip to content

Commit 50e7b4a

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
objtool: Skip magical retpoline .altinstr_replacement
When the .altinstr_replacement is a retpoline, skip the alternative. We already special case retpolines anyway. 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 7bd2a60 commit 50e7b4a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

tools/objtool/special.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,14 @@ static int get_alt_entry(struct elf *elf, struct special_entry *entry,
106106
return -1;
107107
}
108108

109+
/*
110+
* Skip retpoline .altinstr_replacement... we already rewrite the
111+
* instructions for retpolines anyway, see arch_is_retpoline()
112+
* usage in add_{call,jump}_destinations().
113+
*/
114+
if (arch_is_retpoline(new_reloc->sym))
115+
return 1;
116+
109117
alt->new_sec = new_reloc->sym->sec;
110118
alt->new_off = (unsigned int)new_reloc->addend;
111119

@@ -154,7 +162,9 @@ int special_get_alts(struct elf *elf, struct list_head *alts)
154162
memset(alt, 0, sizeof(*alt));
155163

156164
ret = get_alt_entry(elf, entry, sec, idx, alt);
157-
if (ret)
165+
if (ret > 0)
166+
continue;
167+
if (ret < 0)
158168
return ret;
159169

160170
list_add_tail(&alt->list, alts);

0 commit comments

Comments
 (0)