[PATCH] objtool: Make 'sec-address' always on

From: Christophe Leroy
Date: Wed Jun 21 2023 - 11:22:59 EST


Most of the time objtool warnings are useless without the
absolute address within the section.

Today there is --sec-address option to get it printed, but
that option is nowhere used and requires a change in Makefile
to use it.

Having the address inside the section at all time in addition
to the address within the object doesn't hurt and will help.

Remove the --sec-address option and print it at all time.

Signed-off-by: Christophe Leroy <christophe.leroy@xxxxxxxxxx>
---
tools/objtool/builtin-check.c | 1 -
tools/objtool/include/objtool/builtin.h | 1 -
tools/objtool/include/objtool/warn.h | 6 ++----
3 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/tools/objtool/builtin-check.c b/tools/objtool/builtin-check.c
index 7c175198d09f..d5024a95467a 100644
--- a/tools/objtool/builtin-check.c
+++ b/tools/objtool/builtin-check.c
@@ -91,7 +91,6 @@ static const struct option check_options[] = {
OPT_BOOLEAN(0, "module", &opts.module, "object is part of a kernel module"),
OPT_BOOLEAN(0, "mnop", &opts.mnop, "nop out mcount call sites"),
OPT_BOOLEAN(0, "no-unreachable", &opts.no_unreachable, "skip 'unreachable instruction' warnings"),
- OPT_BOOLEAN(0, "sec-address", &opts.sec_address, "print section addresses in warnings"),
OPT_BOOLEAN(0, "stats", &opts.stats, "print statistics"),

OPT_END(),
diff --git a/tools/objtool/include/objtool/builtin.h b/tools/objtool/include/objtool/builtin.h
index 2a108e648b7a..af79618cf6ab 100644
--- a/tools/objtool/include/objtool/builtin.h
+++ b/tools/objtool/include/objtool/builtin.h
@@ -35,7 +35,6 @@ struct opts {
bool mnop;
bool module;
bool no_unreachable;
- bool sec_address;
bool stats;
};

diff --git a/tools/objtool/include/objtool/warn.h b/tools/objtool/include/objtool/warn.h
index b1c920dc9516..2db9717d0558 100644
--- a/tools/objtool/include/objtool/warn.h
+++ b/tools/objtool/include/objtool/warn.h
@@ -21,7 +21,6 @@ static inline char *offstr(struct section *sec, unsigned long offset)
bool is_text = (sec->sh.sh_flags & SHF_EXECINSTR);
struct symbol *sym = NULL;
char *str;
- int len;

if (is_text)
sym = find_func_containing(sec, offset);
@@ -30,9 +29,8 @@ static inline char *offstr(struct section *sec, unsigned long offset)

if (sym) {
str = malloc(strlen(sym->name) + strlen(sec->name) + 40);
- len = sprintf(str, "%s+0x%lx", sym->name, offset - sym->offset);
- if (opts.sec_address)
- sprintf(str+len, " (%s+0x%lx)", sec->name, offset);
+ sprintf(str, "%s+0x%lx (%s+0x%lx)", sym->name,
+ offset - sym->offset, sec->name, offset);
} else {
str = malloc(strlen(sec->name) + 20);
sprintf(str, "%s+0x%lx", sec->name, offset);
--
2.40.1