[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <097057f88605aa67b0e3ec573fcf394ae7ac4d6f.1649891421.git.jpoimboe@redhat.com>
Date: Wed, 13 Apr 2022 16:19:37 -0700
From: Josh Poimboeuf <jpoimboe@...hat.com>
To: x86@...nel.org
Cc: Peter Zijlstra <peterz@...radead.org>,
linux-kernel@...r.kernel.org, Miroslav Benes <mbenes@...e.cz>
Subject: [PATCH 02/18] objtool: Support data symbol printing
For data relocations to missing ENDBR, it will be useful in some cases
to print the data symbol + offset. Add support for that.
Signed-off-by: Josh Poimboeuf <jpoimboe@...hat.com>
---
tools/objtool/include/objtool/warn.h | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/tools/objtool/include/objtool/warn.h b/tools/objtool/include/objtool/warn.h
index 802cfda0a6f6..dab0dda7c617 100644
--- a/tools/objtool/include/objtool/warn.h
+++ b/tools/objtool/include/objtool/warn.h
@@ -17,16 +17,19 @@ extern const char *objname;
static inline char *offstr(struct section *sec, unsigned long offset)
{
- struct symbol *func;
- char *name, *str;
+ bool is_text = (sec->sh.sh_flags & SHF_EXECINSTR);
+ struct symbol *sym = NULL;
unsigned long name_off;
+ char *name, *str;
+
+ if (is_text)
+ sym = find_func_containing(sec, offset);
+ if (!sym)
+ sym = find_symbol_containing(sec, offset);
- func = find_func_containing(sec, offset);
- if (!func)
- func = find_symbol_containing(sec, offset);
- if (func) {
- name = func->name;
- name_off = offset - func->offset;
+ if (sym) {
+ name = sym->name;
+ name_off = offset - sym->offset;
} else {
name = sec->name;
name_off = offset;
@@ -34,8 +37,8 @@ static inline char *offstr(struct section *sec, unsigned long offset)
str = malloc(strlen(name) + 20);
- if (func)
- sprintf(str, "%s()+0x%lx", name, name_off);
+ if (sym)
+ sprintf(str, "%s%s+0x%lx", name, is_text ? "()" : "", name_off);
else
sprintf(str, "%s+0x%lx", name, name_off);
--
2.34.1
Powered by blists - more mailing lists