linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Laura Abbott <labbott@redhat.com>
To: Andy Lutomirski <luto@kernel.org>,
	mjw@fedoraproject.org, "H . J . Lu" <hjl.tools@gmail.com>,
	Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Laura Abbott <labbott@redhat.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	X86 ML <x86@kernel.org>,
	linux-kernel@vger.kernel.org, Nick Clifton <nickc@redhat.com>,
	Cary Coutant <ccoutant@gmail.com>
Subject: [RFC PATCH 1/3] kbuild: Introduce build-salt generated header
Date: Tue, 20 Mar 2018 18:46:33 -0700	[thread overview]
Message-ID: <20180321014635.29113-2-labbott@redhat.com> (raw)
In-Reply-To: <20180321014635.29113-1-labbott@redhat.com>


The build id generated from --build-id can be generated in several different
ways, with the default being the sha1 on the output of the linked file. For
distributions, it can be useful to make sure this ID is unique, even if the
actual file contents don't change. The easiest way to do this is to insert
a comment section with some data.

Introduce a header which is generated from an environment varible, BUILD_TAG.
If this variable is set, an appropriate .comment section is generated. If
the environment variable isn't set, the define is simply empty and there
is no change to the build.

Suggested-by: Nick Clifton <nickc@redhat.com>
Signed-off-by: Laura Abbott <labbott@redhat.com>
---
 Makefile           |  9 ++++++++-
 scripts/gencomment | 19 +++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)
 create mode 100755 scripts/gencomment

diff --git a/Makefile b/Makefile
index d65e2e229017..de360625aec5 100644
--- a/Makefile
+++ b/Makefile
@@ -1087,7 +1087,7 @@ endif
 prepare2: prepare3 prepare-compiler-check outputmakefile asm-generic
 
 prepare1: prepare2 $(version_h) include/generated/utsrelease.h \
-                   include/config/auto.conf
+                   include/config/auto.conf include/generated/build-salt.h
 	$(cmd_crmodverdir)
 
 archprepare: archheaders archscripts prepare1 scripts_basic
@@ -1175,6 +1175,13 @@ $(version_h): $(srctree)/Makefile FORCE
 include/generated/utsrelease.h: include/config/kernel.release FORCE
 	$(call filechk,utsrelease.h)
 
+define filechk_build-salt.h
+	($(CONFIG_SHELL) $(srctree)/scripts/gencomment)
+endef
+
+include/generated/build-salt.h: $(srctree)/Makefile FORCE
+	$(call filechk,build-salt.h)
+
 PHONY += headerdep
 headerdep:
 	$(Q)find $(srctree)/include/ -name '*.h' | xargs --max-args 1 \
diff --git a/scripts/gencomment b/scripts/gencomment
new file mode 100755
index 000000000000..13b6e7739ef7
--- /dev/null
+++ b/scripts/gencomment
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+if [ -z $BUILD_TAG ]; then
+	echo "#define ID_TAG"
+	exit 0
+fi
+
+echo "#define ID_TAG \\"
+echo ".comment (INFO) : \\"
+echo " { \\"
+
+_TAG=`echo $BUILD_TAG | sed -e 's/\(.\)/\1 /g'`
+for c in $_TAG; do
+	_HEX=`echo -n $c | od -A n -t x1 | tr -d ' ' `
+	echo "BYTE(0x$_HEX); \\"
+done
+echo "BYTE(0x00); \\"
+
+echo " } "
-- 
2.16.2

  reply	other threads:[~2018-03-21  1:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-21  1:46 [RFC PATCH 0/3] Salted build ids via linker sections Laura Abbott
2018-03-21  1:46 ` Laura Abbott [this message]
2018-03-21  1:46 ` [RFC PATCH 2/3] kbuild: Link with generated build-salt header Laura Abbott
2018-03-21  1:46 ` [RFC PATCH 3/3] x86/vdso: Add build salt to the vDSO Laura Abbott
2018-03-21  9:40 ` [RFC PATCH 0/3] Salted build ids via linker sections Nick Clifton
2018-03-26  7:48 ` Masahiro Yamada
2018-03-26  9:58   ` Mark Wielaard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180321014635.29113-2-labbott@redhat.com \
    --to=labbott@redhat.com \
    --cc=ccoutant@gmail.com \
    --cc=hjl.tools@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mjw@fedoraproject.org \
    --cc=nickc@redhat.com \
    --cc=torvalds@linux-foundation.org \
    --cc=x86@kernel.org \
    --cc=yamada.masahiro@socionext.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).