Thread (19 messages) 19 messages, 5 authors, 17d ago

Re: [RFC PATCH v2 4/7] objtool: add target architecture to usage

From: sashiko-bot@kernel.org
Date: 2026-08-26 19:57:53

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Unintended macro expansion of architecture names during stringification results in an incorrect objtool usage string on certain architectures.
--

commit d81c5c3b288ffe16035a8655c9eb901dce1a358a
Author: Joe Lawrence [off-list ref]

objtool: add target architecture to usage
    
Display the target architecture in the objtool usage string so that
users can identify which arch variant of objtool they are running.
quoted hunk ↗ jump to hunk
diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile
index a4484fd22a96d..c73c80af5ef3d 100644
--- a/tools/objtool/Makefile
+++ b/tools/objtool/Makefile
@@ -61,7 +61,8 @@ INCLUDES := -I$(srctree)/tools/include \
 	    -I$(srctree)/tools/lib
 
 OBJTOOL_CFLAGS  := -std=gnu11 -fomit-frame-pointer -O2 -g $(WARNINGS)	\
-		   $(INCLUDES) $(LIBELF_FLAGS) $(LIBXXHASH_CFLAGS) $(HOSTCFLAGS)
+		   $(INCLUDES) $(LIBELF_FLAGS) $(LIBXXHASH_CFLAGS) $(HOSTCFLAGS) \
+		   -DOBJTOOL_TARGET_ARCH=$(SRCARCH)
[Severity: Low]
Can passing the architecture name unquoted here cause a regression due to
compiler macro expansion?

For example, on architectures where the target name matches a predefined
compiler macro (like powerpc or sparc), OBJTOOL_TARGET_ARCH becomes an alias
to that predefined macro, which the preprocessor might then expand to a value
like 1.

[ ... ]
quoted hunk ↗ jump to hunk
diff --git a/tools/objtool/builtin-check.c b/tools/objtool/builtin-check.c
index 75b11dc85010e..64651d90986fd 100644
--- a/tools/objtool/builtin-check.c
+++ b/tools/objtool/builtin-check.c
[ ... ]
quoted hunk ↗ jump to hunk
@@ -23,7 +24,7 @@ const char *objname;
 struct opts opts;
 
 static const char * const check_usage[] = {
-	"objtool <actions> [<options>] file.o",
+	"objtool <actions> [<options>] file-" __stringify(OBJTOOL_TARGET_ARCH) ".o",
[Severity: Low]
Will this usage of __stringify() introduce a regression where the help string
is incorrect on certain architectures?

The __stringify() macro evaluates and expands its argument before converting it
to a string. If OBJTOOL_TARGET_ARCH evaluates to 1 due to predefined macros
as noted above, the resulting string will be "file-1.o" instead of
"file-powerpc.o".

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260826195000.455905-1-joe.lawrence@redhat.com?part=4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help