linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kbuild: mkcompile_h: Include $LD version in /proc/version
@ 2020-04-02  8:18 Kees Cook
  2020-04-02 14:24 ` Sedat Dilek
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Kees Cook @ 2020-04-02  8:18 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Michal Marek, Thomas Gleixner, linux-kbuild, clang-built-linux,
	linux-kernel

When doing Clang builds of the kernel, it is possible to link with
either ld.bfd (binutils) or ld.lld (LLVM), but it is not possible to
discover this from a running kernel. Add the "$LD -v" output to
/proc/version.

Signed-off-by: Kees Cook <keescook@chromium.org>
---
 init/Makefile       | 2 +-
 scripts/mkcompile_h | 8 ++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/init/Makefile b/init/Makefile
index 6246a06364d0..82c15bdb42d7 100644
--- a/init/Makefile
+++ b/init/Makefile
@@ -35,4 +35,4 @@ include/generated/compile.h: FORCE
 	@$($(quiet)chk_compile.h)
 	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkcompile_h $@	\
 	"$(UTS_MACHINE)" "$(CONFIG_SMP)" "$(CONFIG_PREEMPT)"	\
-	"$(CONFIG_PREEMPT_RT)" "$(CC) $(KBUILD_CFLAGS)"
+	"$(CONFIG_PREEMPT_RT)" "$(LD)" "$(CC) $(KBUILD_CFLAGS)"
diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h
index 3a5a4b210c86..f98c07709370 100755
--- a/scripts/mkcompile_h
+++ b/scripts/mkcompile_h
@@ -6,7 +6,8 @@ ARCH=$2
 SMP=$3
 PREEMPT=$4
 PREEMPT_RT=$5
-CC=$6
+LD=$6
+CC=$7
 
 vecho() { [ "${quiet}" = "silent_" ] || echo "$@" ; }
 
@@ -72,7 +73,10 @@ UTS_VERSION="$(echo $UTS_VERSION $CONFIG_FLAGS $TIMESTAMP | cut -b -$UTS_LEN)"
   printf '#define LINUX_COMPILE_BY "%s"\n' "$LINUX_COMPILE_BY"
   echo \#define LINUX_COMPILE_HOST \"$LINUX_COMPILE_HOST\"
 
-  echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | grep ' version ' | sed 's/[[:space:]]*$//'`\"
+  CC_VERSION=$($CC -v 2>&1 | grep ' version ' | sed 's/[[:space:]]*$//')
+  LD_VERSION=$($LD -v | head -n1 | sed 's/(compatible with [^)]*)//' \
+		      | sed 's/[[:space:]]*$//')
+  printf '#define LINUX_COMPILER "%s"\n' "$CC_VERSION, $LD_VERSION"
 } > .tmpcompile
 
 # Only replace the real compile.h if the new one is different,
-- 
2.20.1


-- 
Kees Cook

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2020-04-08 10:22 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-02  8:18 [PATCH] kbuild: mkcompile_h: Include $LD version in /proc/version Kees Cook
2020-04-02 14:24 ` Sedat Dilek
2020-04-05 11:23   ` Sedat Dilek
2020-04-05 13:55     ` Masahiro Yamada
2020-04-06 10:35       ` Sedat Dilek
2020-04-06 15:53         ` Kees Cook
2020-04-06 17:13           ` Sedat Dilek
2020-04-02 17:00 ` Masahiro Yamada
2020-04-02 17:33   ` Kees Cook
2020-04-02 18:22   ` Nick Desaulniers
2020-04-02 18:31     ` Kees Cook
2020-04-04  4:51       ` Fangrui Song
2020-04-04  4:02 ` Nathan Chancellor
2020-04-08 10:22 ` Sedat Dilek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).