Skip to content

Commit 4d8b359

Browse files
committed
objtool: Remove reloc symbol type checks in get_alt_entry()
Converting a special section's relocation reference to a symbol is straightforward. No need for objtool to complain that it doesn't know how to handle it. Just handle it. This fixes the following warning: arch/x86/kvm/emulate.o: warning: objtool: __ex_table+0x4: don't know how to handle reloc symbol type: kvm_fastop_exception Fixes: 24ff652 ("objtool: Teach get_alt_entry() about more relocation types") Reported-by: Linus Torvalds <[email protected]> Signed-off-by: Josh Poimboeuf <[email protected]> Link: https://lore.kernel.org/r/feadbc3dfb3440d973580fad8d3db873cbfe1694.1633367242.git.jpoimboe@redhat.com Cc: Peter Zijlstra <[email protected]> Cc: [email protected] Cc: Miroslav Benes <[email protected]> Cc: [email protected]
1 parent 9e1ff30 commit 4d8b359

File tree

1 file changed

+7
-29
lines changed

1 file changed

+7
-29
lines changed

tools/objtool/special.c

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -58,22 +58,11 @@ void __weak arch_handle_alternative(unsigned short feature, struct special_alt *
5858
{
5959
}
6060

61-
static bool reloc2sec_off(struct reloc *reloc, struct section **sec, unsigned long *off)
61+
static void reloc_to_sec_off(struct reloc *reloc, struct section **sec,
62+
unsigned long *off)
6263
{
63-
switch (reloc->sym->type) {
64-
case STT_FUNC:
65-
*sec = reloc->sym->sec;
66-
*off = reloc->sym->offset + reloc->addend;
67-
return true;
68-
69-
case STT_SECTION:
70-
*sec = reloc->sym->sec;
71-
*off = reloc->addend;
72-
return true;
73-
74-
default:
75-
return false;
76-
}
64+
*sec = reloc->sym->sec;
65+
*off = reloc->sym->offset + reloc->addend;
7766
}
7867

7968
static int get_alt_entry(struct elf *elf, struct special_entry *entry,
@@ -109,13 +98,8 @@ static int get_alt_entry(struct elf *elf, struct special_entry *entry,
10998
WARN_FUNC("can't find orig reloc", sec, offset + entry->orig);
11099
return -1;
111100
}
112-
if (!reloc2sec_off(orig_reloc, &alt->orig_sec, &alt->orig_off)) {
113-
WARN_FUNC("don't know how to handle reloc symbol type %d: %s",
114-
sec, offset + entry->orig,
115-
orig_reloc->sym->type,
116-
orig_reloc->sym->name);
117-
return -1;
118-
}
101+
102+
reloc_to_sec_off(orig_reloc, &alt->orig_sec, &alt->orig_off);
119103

120104
if (!entry->group || alt->new_len) {
121105
new_reloc = find_reloc_by_dest(elf, sec, offset + entry->new);
@@ -133,13 +117,7 @@ static int get_alt_entry(struct elf *elf, struct special_entry *entry,
133117
if (arch_is_retpoline(new_reloc->sym))
134118
return 1;
135119

136-
if (!reloc2sec_off(new_reloc, &alt->new_sec, &alt->new_off)) {
137-
WARN_FUNC("don't know how to handle reloc symbol type %d: %s",
138-
sec, offset + entry->new,
139-
new_reloc->sym->type,
140-
new_reloc->sym->name);
141-
return -1;
142-
}
120+
reloc_to_sec_off(new_reloc, &alt->new_sec, &alt->new_off);
143121

144122
/* _ASM_EXTABLE_EX hack */
145123
if (alt->new_off >= 0x7ffffff0)

0 commit comments

Comments
 (0)