objtool: Fix sibling call detection in alternatives
In add_jump_destinations(), sibling call detection requires 'insn->func' to be valid. But alternative instructions get their 'func' set in handle_group_alt(), which runs *after* add_jump_destinations(). So sibling calls in alternatives code don't get properly detected. Fix that by changing the initialization order: call add_special_section_alts() *before* add_jump_destinations(). This also means the special case for a missing 'jump_dest' in add_jump_destinations() can be removed, as it has already been dealt with. Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lkml.kernel.org/r/c02e0a0a2a4286b5f848d17c77fdcb7e0caf709c.1649718562.git.jpoimboe@redhat.com
This commit is contained in:
parent
26ff604102
commit
34c861e806
|
@ -1277,6 +1277,13 @@ static int add_jump_destinations(struct objtool_file *file)
|
||||||
unsigned long dest_off;
|
unsigned long dest_off;
|
||||||
|
|
||||||
for_each_insn(file, insn) {
|
for_each_insn(file, insn) {
|
||||||
|
if (insn->jump_dest) {
|
||||||
|
/*
|
||||||
|
* handle_group_alt() may have previously set
|
||||||
|
* 'jump_dest' for some alternatives.
|
||||||
|
*/
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!is_static_jump(insn))
|
if (!is_static_jump(insn))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -1308,15 +1315,6 @@ static int add_jump_destinations(struct objtool_file *file)
|
||||||
|
|
||||||
jump_dest = find_insn(file, dest_sec, dest_off);
|
jump_dest = find_insn(file, dest_sec, dest_off);
|
||||||
if (!jump_dest) {
|
if (!jump_dest) {
|
||||||
|
|
||||||
/*
|
|
||||||
* This is a special case where an alt instruction
|
|
||||||
* jumps past the end of the section. These are
|
|
||||||
* handled later in handle_group_alt().
|
|
||||||
*/
|
|
||||||
if (!strcmp(insn->sec->name, ".altinstr_replacement"))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
WARN_FUNC("can't find jump dest instruction at %s+0x%lx",
|
WARN_FUNC("can't find jump dest instruction at %s+0x%lx",
|
||||||
insn->sec, insn->offset, dest_sec->name,
|
insn->sec, insn->offset, dest_sec->name,
|
||||||
dest_off);
|
dest_off);
|
||||||
|
@ -1549,13 +1547,13 @@ static int handle_group_alt(struct objtool_file *file,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
dest_off = arch_jump_destination(insn);
|
dest_off = arch_jump_destination(insn);
|
||||||
if (dest_off == special_alt->new_off + special_alt->new_len)
|
if (dest_off == special_alt->new_off + special_alt->new_len) {
|
||||||
insn->jump_dest = next_insn_same_sec(file, last_orig_insn);
|
insn->jump_dest = next_insn_same_sec(file, last_orig_insn);
|
||||||
|
if (!insn->jump_dest) {
|
||||||
if (!insn->jump_dest) {
|
WARN_FUNC("can't find alternative jump destination",
|
||||||
WARN_FUNC("can't find alternative jump destination",
|
insn->sec, insn->offset);
|
||||||
insn->sec, insn->offset);
|
return -1;
|
||||||
return -1;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2254,14 +2252,14 @@ static int decode_sections(struct objtool_file *file)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Must be before add_special_section_alts() as that depends on
|
* Must be before add_jump_destinations(), which depends on 'func'
|
||||||
* jump_dest being set.
|
* being set for alternatives, to enable proper sibling call detection.
|
||||||
*/
|
*/
|
||||||
ret = add_jump_destinations(file);
|
ret = add_special_section_alts(file);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = add_special_section_alts(file);
|
ret = add_jump_destinations(file);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue