summaryrefslogtreecommitdiffstats
path: root/tools/objtool/elf.c
diff options
context:
space:
mode:
authorJosh Poimboeuf <jpoimboe@redhat.com>2020-02-18 04:41:54 +0100
committerBorislav Petkov <bp@suse.de>2020-02-21 10:20:34 +0100
commit7acfe5315312fc56c2a94c9216448087b38ae909 (patch)
treee3187f3209664e907dabf0fa7a0151d1a82e487f /tools/objtool/elf.c
parentobjtool: Fix clang switch table edge case (diff)
downloadlinux-7acfe5315312fc56c2a94c9216448087b38ae909.tar.xz
linux-7acfe5315312fc56c2a94c9216448087b38ae909.zip
objtool: Improve call destination function detection
A recent clang change, combined with a binutils bug, can trigger a situation where a ".Lprintk$local" STT_NOTYPE symbol gets created at the same offset as the "printk" STT_FUNC symbol. This confuses objtool: kernel/printk/printk.o: warning: objtool: ignore_loglevel_setup()+0x10: can't find call dest symbol at .text+0xc67 Improve the call destination detection by looking specifically for an STT_FUNC symbol. Reported-by: Nick Desaulniers <ndesaulniers@google.com> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> Signed-off-by: Borislav Petkov <bp@suse.de> Tested-by: Nick Desaulniers <ndesaulniers@google.com> Tested-by: Nathan Chancellor <natechancellor@gmail.com> Link: https://github.com/ClangBuiltLinux/linux/issues/872 Link: https://sourceware.org/bugzilla/show_bug.cgi?id=25551 Link: https://lkml.kernel.org/r/0a7ee320bc0ea4469bd3dc450a7b4725669e0ea9.1581997059.git.jpoimboe@redhat.com
Diffstat (limited to 'tools/objtool/elf.c')
-rw-r--r--tools/objtool/elf.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index edba4745f25a..cc4601c879ce 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -62,8 +62,18 @@ struct symbol *find_symbol_by_offset(struct section *sec, unsigned long offset)
struct symbol *sym;
list_for_each_entry(sym, &sec->symbol_list, list)
- if (sym->type != STT_SECTION &&
- sym->offset == offset)
+ if (sym->type != STT_SECTION && sym->offset == offset)
+ return sym;
+
+ return NULL;
+}
+
+struct symbol *find_func_by_offset(struct section *sec, unsigned long offset)
+{
+ struct symbol *sym;
+
+ list_for_each_entry(sym, &sec->symbol_list, list)
+ if (sym->type == STT_FUNC && sym->offset == offset)
return sym;
return NULL;