x86/purgatory: Fail the build if purgatory.ro has missing symbols
authorHans de Goede <hdegoede@redhat.com>
Tue, 17 Mar 2020 13:08:41 +0000 (14:08 +0100)
committerBorislav Petkov <bp@suse.de>
Tue, 17 Mar 2020 14:59:12 +0000 (15:59 +0100)
commite4160b2e4b02377c67f8ecd05786811598f39acd
treefbfbb2146962bf64d57defc66c88746d12fd2681
parente2ac07c06058ae2d58b45bbf2a2a352771d76fcb
x86/purgatory: Fail the build if purgatory.ro has missing symbols

Linking purgatory.ro with -r enables "incremental linking"; this means
no checks for unresolved symbols are done while linking purgatory.ro.

A change 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.

Add 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/purgatory.ro
  ld: arch/x86/purgatory/purgatory.ro: 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/Makefile.build:509: arch/x86/purgatory] Error 2
  make: *** [Makefile:1650: arch/x86] Error 2

Also remove --no-undefined from LDFLAGS_purgatory.ro as that has no
effect.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20200317130841.290418-2-hdegoede@redhat.com
arch/x86/purgatory/.gitignore [new file with mode: 0644]
arch/x86/purgatory/Makefile