Suggested-by: Peter Zijlstra <pet...@infradead.org>
Signed-off-by: Matt Helsley <mhels...@vmware.com>
---
 tools/objtool/check.c | 3 +--
 tools/objtool/elf.c   | 7 +++++++
 tools/objtool/elf.h   | 1 +
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 78375908acda..d08714b878c5 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -771,8 +771,7 @@ static int add_call_destinations(struct objtool_file *file)
                 * so they need a little help, NOP out any KCOV calls from 
noinstr
                 * text.
                 */
-               if (insn->sec->noinstr &&
-                   !strncmp(insn->call_dest->name, "__sanitizer_cov_", 16)) {
+               if (insn->sec->noinstr && insn->call_dest->class == SYM_KCOV) {
                        if (reloc) {
                                reloc->type = R_NONE;
                                elf_write_reloc(file->elf, reloc);
diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index d55d8fef11b4..666cbc01c332 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -402,6 +402,11 @@ static bool is_mcount_sym(const char *name)
        return false;
 }
 
+static bool is_kcov_symbol(const char *name)
+{
+       return !strncmp(name, "__sanitize_cov_", 16);
+}
+
 static int read_symbols(struct elf *elf)
 {
        struct section *symtab, *symtab_shndx, *sec;
@@ -473,6 +478,8 @@ static int read_symbols(struct elf *elf)
 
                if (is_mcount_sym(sym->name))
                        sym->class = SYM_MCOUNT;
+               else if (is_kcov_symbol(sym->name))
+                       sym->class = SYM_KCOV;
 
                sym->offset = sym->sym.st_value;
                sym->len = sym->sym.st_size;
diff --git a/tools/objtool/elf.h b/tools/objtool/elf.h
index 13935edaff54..f0b02824f9d3 100644
--- a/tools/objtool/elf.h
+++ b/tools/objtool/elf.h
@@ -45,6 +45,7 @@ struct section {
 enum symbol_class {
        SYM_REGULAR = 0,
        SYM_MCOUNT = 1,
+       SYM_KCOV = 2,
 };
 
 struct symbol {
-- 
2.20.1

Reply via email to