LKML Archive on
help / color / mirror / Atom feed
From: Hans de Goede <>
To: Thomas Gleixner <>,
	Ingo Molnar <>, Borislav Petkov <>
Cc: Hans de Goede <>,,
Subject: [PATCH resend] x86/purgatory: Make sure we fail the build if has missing symbols
Date: Thu, 12 Dec 2019 21:50:08 +0100	[thread overview]
Message-ID: <> (raw)

Since we link with -r aka we enable "incremental linking"
no checks for unresolved symbols is done while linking

Changes to the sha256 code has caused the purgatory in 5.4-rc1 to have
a missing symbol on memzero_explicit, yet things still happily build.

This commit adds an extra check for unresolved symbols by calling ld
without -r before running bin2c to generate kexec-purgatory.c.

This causes a build of 5.4-rc1 with this patch added to fail as it should:

  CHK     arch/x86/purgatory/
ld: arch/x86/purgatory/ in function `sha256_transform':
sha256.c:(.text+0x1c0c): undefined reference to `memzero_explicit'
make[2]: *** [arch/x86/purgatory/Makefile:72:
    arch/x86/purgatory/kexec-purgatory.c] Error 1
make[1]: *** [scripts/ arch/x86/purgatory] Error 2
make: *** [Makefile:1650: arch/x86] Error 2

This will help us catch missing symbols in the purgatory sooner.

Note this commit also removes --no-undefined from
as that has no effect.

Signed-off-by: Hans de Goede <>
Changes in v3:
- Add a .gitignore file with purgatory.chk listed in it

Changes in v2:
- Using 2 if_changed lines under a single rule does not work, then
  1 of the 2 will always execute each build.
  Instead add a new (unused) purgatory.chk intermediate which gets
  linked from without -r to do the missing symbols check
- This also fixes the check generating an a.out file (oops)
 arch/x86/purgatory/.gitignore |  1 +
 arch/x86/purgatory/Makefile   | 13 ++++++++++---
 2 files changed, 11 insertions(+), 3 deletions(-)
 create mode 100644 arch/x86/purgatory/.gitignore

diff --git a/arch/x86/purgatory/.gitignore b/arch/x86/purgatory/.gitignore
new file mode 100644
index 000000000000..d2be1500671d
--- /dev/null
+++ b/arch/x86/purgatory/.gitignore
@@ -0,0 +1 @@
diff --git a/arch/x86/purgatory/Makefile b/arch/x86/purgatory/Makefile
index fb4ee5444379..5bb58247699d 100644
--- a/arch/x86/purgatory/Makefile
+++ b/arch/x86/purgatory/Makefile
@@ -14,8 +14,12 @@ $(obj)/sha256.o: $(srctree)/lib/crypto/sha256.c FORCE
 CFLAGS_sha256.o := -D__DISABLE_EXPORTS := -e purgatory_start -r --no-undefined -nostdlib -z nodefaultlib
-targets +=
+# Since we link with -r unresolved symbols are not checked, so we
+# also link a purgatory.chk binary without -r to check for unresolved symbols.
+PURGATORY_LDFLAGS := -e purgatory_start -nostdlib -z nodefaultlib := -r $(PURGATORY_LDFLAGS)
+LDFLAGS_purgatory.chk := $(PURGATORY_LDFLAGS)
+targets += purgatory.chk
@@ -58,12 +62,15 @@ CFLAGS_string.o			+= $(PURGATORY_CFLAGS)
 		$(call if_changed,ld)
+$(obj)/purgatory.chk: $(obj)/ FORCE
+		$(call if_changed,ld)
 targets += kexec-purgatory.c
 quiet_cmd_bin2c = BIN2C   $@
       cmd_bin2c = $(objtree)/scripts/bin2c kexec_purgatory < $< > $@
-$(obj)/kexec-purgatory.c: $(obj)/ FORCE
+$(obj)/kexec-purgatory.c: $(obj)/ $(obj)/purgatory.chk FORCE
 	$(call if_changed,bin2c)
 obj-$(CONFIG_KEXEC_FILE)	+= kexec-purgatory.o

             reply	other threads:[~2019-12-12 20:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-12 20:50 Hans de Goede [this message]
2020-02-21 16:59 Hans de Goede
2020-02-29 17:16 ` kbuild test robot
2020-02-29 18:12   ` Hans de Goede
2020-03-11 20:49     ` Borislav Petkov
2020-03-11 21:20       ` Arvind Sankar
2020-03-11 21:25         ` Hans de Goede

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:

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

  git send-email \ \ \ \ \ \ \ \
    --subject='Re: [PATCH resend] x86/purgatory: Make sure we fail the build if has missing symbols' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).