[tip: objtool/urgent] objtool: Fix verbose disassembly if CROSS_COMPILE isn't set

From: tip-bot2 for David Laight
Date: Tue Apr 01 2025 - 03:15:43 EST


The following commit has been merged into the objtool/urgent branch of tip:

Commit-ID: e77956e4e5c11218e60a1fe8cdbccd02476f2e56
Gitweb: https://git.kernel.org/tip/e77956e4e5c11218e60a1fe8cdbccd02476f2e56
Author: David Laight <david.laight.linux@xxxxxxxxx>
AuthorDate: Mon, 31 Mar 2025 21:26:42 -07:00
Committer: Ingo Molnar <mingo@xxxxxxxxxx>
CommitterDate: Tue, 01 Apr 2025 09:07:13 +02:00

objtool: Fix verbose disassembly if CROSS_COMPILE isn't set

In verbose mode, when printing the disassembly of affected functions, if
CROSS_COMPILE isn't set, the objdump command string gets prefixed with
"(null)".

Somehow this worked before. Maybe some versions of glibc return an
empty string instead of NULL. Fix it regardless.

[ jpoimboe: Rewrite commit log. ]

Fixes: ca653464dd097 ("objtool: Add verbose option for disassembling affected functions")
Signed-off-by: David Laight <david.laight.linux@xxxxxxxxx>
Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Link: https://lore.kernel.org/r/20250215142321.14081-1-david.laight.linux@xxxxxxxxx
Link: https://lore.kernel.org/r/b931a4786bc0127aa4c94e8b35ed617dcbd3d3da.1743481539.git.jpoimboe@xxxxxxxxxx
---
tools/objtool/check.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index ff83be1..4a1f6c3 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -4523,6 +4523,8 @@ static void disas_funcs(const char *funcs)
char *cmd;

cross_compile = getenv("CROSS_COMPILE");
+ if (!cross_compile)
+ cross_compile = "";

objdump_str = "%sobjdump -wdr %s | gawk -M -v _funcs='%s' '"
"BEGIN { split(_funcs, funcs); }"