From: Hans de Goede <hdegoede@redhat.com>
To: Nathan Chancellor <natechancellor@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
"H . Peter Anvin" <hpa@zytor.com>,
Arvind Sankar <nivedita@alum.mit.edu>,
x86@kernel.org, linux-kernel@vger.kernel.org,
clang-built-linux@googlegroups.com
Subject: Re: [PATCH] x86/purgatory: Make sure we fail the build if purgatory.ro has missing symbols
Date: Mon, 7 Oct 2019 22:31:49 +0200 [thread overview]
Message-ID: <c24d8bef-ad76-4986-0c16-268e7d09bf7c@redhat.com> (raw)
In-Reply-To: <20191007200529.GA716619@archlinux-threadripper>
HI,
On 07-10-2019 22:05, Nathan Chancellor wrote:
> On Mon, Oct 07, 2019 at 07:55:46PM +0200, Hans de Goede wrote:
>> Since we link purgatory.ro with -r aka we enable "incremental linking"
>> no checks for unresolved symbols is done while linking purgatory.ro.
>>
>> 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/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
>>
>> This will help us catch missing symbols in the purgatory sooner.
>>
>> Note this commit also removes --no-undefined from LDFLAGS_purgatory.ro
>> as that has no effect.
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>> ---
>> arch/x86/purgatory/Makefile | 8 +++++++-
>> 1 file changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/x86/purgatory/Makefile b/arch/x86/purgatory/Makefile
>> index fb4ee5444379..0da0794ef1f0 100644
>> --- a/arch/x86/purgatory/Makefile
>> +++ b/arch/x86/purgatory/Makefile
>> @@ -14,7 +14,7 @@ $(obj)/sha256.o: $(srctree)/lib/crypto/sha256.c FORCE
>>
>> CFLAGS_sha256.o := -D__DISABLE_EXPORTS
>>
>> -LDFLAGS_purgatory.ro := -e purgatory_start -r --no-undefined -nostdlib -z nodefaultlib
>> +LDFLAGS_purgatory.ro := -e purgatory_start -r -nostdlib -z nodefaultlib
>> targets += purgatory.ro
>>
>> KASAN_SANITIZE := n
>> @@ -60,10 +60,16 @@ $(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE
>>
>> targets += kexec-purgatory.c
>>
>> +# Since we link purgatory.ro with -r unresolved symbols are not checked,
>> +# so we check this before generating kexec-purgatory.c instead
>> +quiet_cmd_check_purgatory = CHK $<
>> + cmd_check_purgatory = ld -e purgatory_start $<
>
> I think this should be $(LD) -e ... so that using a cross compile prefix
> (like x86_64-linux-) or an alternative linker like ld.lld works properly.
Good point, also the ld command is actually outputting an a.out file
which is also something which we do not want.
I will prepare a new version fixing both.
Regards,
Hans
next prev parent reply other threads:[~2019-10-07 20:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-07 17:55 Hans de Goede
2019-10-07 20:05 ` Nathan Chancellor
2019-10-07 20:31 ` Hans de Goede [this message]
2019-10-07 21:52 ` Arvind Sankar
2019-10-08 5:57 ` 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:
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=c24d8bef-ad76-4986-0c16-268e7d09bf7c@redhat.com \
--to=hdegoede@redhat.com \
--cc=bp@alien8.de \
--cc=clang-built-linux@googlegroups.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=natechancellor@gmail.com \
--cc=nivedita@alum.mit.edu \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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
all inboxes | Powered by JetHome®