Skip to content

Commit aaf5c62

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
objtool: Rewrite add_ignores()
The whole add_ignores() thing was wildly weird; rewrite it according to 'modern' ways. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Borislav Petkov <bp@alien8.de> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 09f30d8 commit aaf5c62

File tree

2 files changed

+20
-32
lines changed

2 files changed

+20
-32
lines changed

tools/objtool/check.c

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -104,29 +104,6 @@ static struct instruction *next_insn_same_func(struct objtool_file *file,
104104
for (insn = next_insn_same_sec(file, insn); insn; \
105105
insn = next_insn_same_sec(file, insn))
106106

107-
/*
108-
* Check if the function has been manually whitelisted with the
109-
* STACK_FRAME_NON_STANDARD macro, or if it should be automatically whitelisted
110-
* due to its use of a context switching instruction.
111-
*/
112-
static bool ignore_func(struct objtool_file *file, struct symbol *func)
113-
{
114-
struct rela *rela;
115-
116-
/* check for STACK_FRAME_NON_STANDARD */
117-
if (file->whitelist && file->whitelist->rela)
118-
list_for_each_entry(rela, &file->whitelist->rela->rela_list, list) {
119-
if (rela->sym->type == STT_SECTION &&
120-
rela->sym->sec == func->sec &&
121-
rela->addend == func->offset)
122-
return true;
123-
if (rela->sym->type == STT_FUNC && rela->sym == func)
124-
return true;
125-
}
126-
127-
return false;
128-
}
129-
130107
/*
131108
* This checks to see if the given function is a "noreturn" function.
132109
*
@@ -436,18 +413,31 @@ static void add_ignores(struct objtool_file *file)
436413
struct instruction *insn;
437414
struct section *sec;
438415
struct symbol *func;
416+
struct rela *rela;
439417

440-
for_each_sec(file, sec) {
441-
list_for_each_entry(func, &sec->symbol_list, list) {
442-
if (func->type != STT_FUNC)
443-
continue;
418+
sec = find_section_by_name(file->elf, ".rela.discard.func_stack_frame_non_standard");
419+
if (!sec)
420+
return;
444421

445-
if (!ignore_func(file, func))
422+
list_for_each_entry(rela, &sec->rela_list, list) {
423+
switch (rela->sym->type) {
424+
case STT_FUNC:
425+
func = rela->sym;
426+
break;
427+
428+
case STT_SECTION:
429+
func = find_symbol_by_offset(rela->sym->sec, rela->addend);
430+
if (!func || func->type != STT_FUNC)
446431
continue;
432+
break;
447433

448-
func_for_each_insn_all(file, func, insn)
449-
insn->ignore = true;
434+
default:
435+
WARN("unexpected relocation symbol type in %s: %d", sec->name, rela->sym->type);
436+
continue;
450437
}
438+
439+
func_for_each_insn_all(file, func, insn)
440+
insn->ignore = true;
451441
}
452442
}
453443

@@ -2199,7 +2189,6 @@ int check(const char *_objname, bool orc)
21992189

22002190
INIT_LIST_HEAD(&file.insn_list);
22012191
hash_init(file.insn_hash);
2202-
file.whitelist = find_section_by_name(file.elf, ".discard.func_stack_frame_non_standard");
22032192
file.c_file = find_section_by_name(file.elf, ".comment");
22042193
file.ignore_unreachables = no_unreachable;
22052194
file.hints = false;

tools/objtool/check.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ struct objtool_file {
6060
struct elf *elf;
6161
struct list_head insn_list;
6262
DECLARE_HASHTABLE(insn_hash, 16);
63-
struct section *whitelist;
6463
bool ignore_unreachables, c_file, hints, rodata;
6564
};
6665

0 commit comments

Comments
 (0)