Skip to content

Commit e10cd8f

Browse files
jpoimboeKAGA-KOKO
authored andcommitted
objtool: Refactor function alias logic
- Add an alias check in validate_functions(). With this change, aliases no longer need uaccess_safe set. - Add an alias check in decode_instructions(). With this change, the "if (!insn->func)" check is no longer needed. - Don't create aliases for zero-length functions, as it can have unexpected results. The next patch will spit out a warning for zero-length functions anyway. Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Nick Desaulniers <ndesaulniers@google.com> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lkml.kernel.org/r/26a99c31426540f19c9a58b9e10727c385a147bc.1563413318.git.jpoimboe@redhat.com
1 parent c705cec commit e10cd8f

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

‎tools/objtool/check.c‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ static int decode_instructions(struct objtool_file *file)
276276
}
277277

278278
list_for_each_entry(func, &sec->symbol_list, list) {
279-
if (func->type != STT_FUNC)
279+
if (func->type != STT_FUNC || func->alias != func)
280280
continue;
281281

282282
if (!find_insn(file, sec, func->offset)) {
@@ -286,8 +286,7 @@ static int decode_instructions(struct objtool_file *file)
286286
}
287287

288288
func_for_each_insn(file, func, insn)
289-
if (!insn->func)
290-
insn->func = func;
289+
insn->func = func;
291290
}
292291
}
293292

@@ -508,7 +507,7 @@ static void add_uaccess_safe(struct objtool_file *file)
508507
if (!func)
509508
continue;
510509

511-
func->alias->uaccess_safe = true;
510+
func->uaccess_safe = true;
512511
}
513512
}
514513

@@ -1887,7 +1886,7 @@ static bool insn_state_match(struct instruction *insn, struct insn_state *state)
18871886
static inline bool func_uaccess_safe(struct symbol *func)
18881887
{
18891888
if (func)
1890-
return func->alias->uaccess_safe;
1889+
return func->uaccess_safe;
18911890

18921891
return false;
18931892
}
@@ -2355,14 +2354,17 @@ static int validate_functions(struct objtool_file *file)
23552354

23562355
for_each_sec(file, sec) {
23572356
list_for_each_entry(func, &sec->symbol_list, list) {
2358-
if (func->type != STT_FUNC || func->pfunc != func)
2357+
if (func->type != STT_FUNC)
2358+
continue;
2359+
2360+
if (func->pfunc != func || func->alias != func)
23592361
continue;
23602362

23612363
insn = find_insn(file, sec, func->offset);
23622364
if (!insn || insn->ignore || insn->visited)
23632365
continue;
23642366

2365-
state.uaccess = func->alias->uaccess_safe;
2367+
state.uaccess = func->uaccess_safe;
23662368

23672369
ret = validate_branch(file, func, insn, state);
23682370
if (ret && backtrace)

‎tools/objtool/elf.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ static int read_symbols(struct elf *elf)
278278
}
279279

280280
if (sym->offset == s->offset) {
281-
if (sym->len == s->len && alias == sym)
281+
if (sym->len && sym->len == s->len && alias == sym)
282282
alias = s;
283283

284284
if (sym->len >= s->len) {

0 commit comments

Comments
 (0)