Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
From: Huacai Chen <chenhuacai@kernel.org>
To: Ard Biesheuvel <ardb@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>,
	Bill Wendling <morbo@google.com>,
	 Justin Stitt <justinstitt@google.com>,
	WANG Xuerui <kernel@xen0n.name>,
	linux-efi@vger.kernel.org,  loongarch@lists.linux.dev,
	llvm@lists.linux.dev, patches@lists.linux.dev
Subject: Re: [PATCH] efi/libstub: zboot.lds: Discard .discard sections
Date: Thu, 23 May 2024 10:19:47 +0800	[thread overview]
Message-ID: <CAAhV-H4EOV8cMPpO_=O4rnCNKcMwVa_NeeoA9w8unC5nJU5LzQ@mail.gmail.com> (raw)
In-Reply-To: <CAMj1kXG-Ck3y1STD9GeS6gyqUgOL6ch3jjCtdZjN_w+LScOzpw@mail.gmail.com>

Acked-by: Huacai Chen <chenhuacai@loongson.cn>

On Thu, May 23, 2024 at 1:37 AM Ard Biesheuvel <ardb@kernel.org> wrote:
>
> On Wed, 22 May 2024 at 19:32, Nathan Chancellor <nathan@kernel.org> wrote:
> >
> > When building ARCH=loongarch defconfig + CONFIG_UNWINDER_ORC=y using
> > LLVM, there is a warning from ld.lld when linking the EFI zboot image
> > due to the use of unreachable() in number() in vsprintf.c:
> >
> >   ld.lld: warning: drivers/firmware/efi/libstub/lib.a(vsprintf.stub.o):(.discard.unreachable+0x0): has non-ABS relocation R_LARCH_32_PCREL against symbol ''
> >
> > If the compiler cannot eliminate the default case for any reason, the
> > .discard.unreachable section will remain in the final binary but the
> > entire point of any section prefixed with .discard is that it is only
> > used at compile time, so it can be discarded via /DISCARD/ in a linker
> > script. The asm-generic vmlinux.lds.h includes .discard and .discard.*
> > in the COMMON_DISCARDS macro but that is not used for zboot.lds, as it
> > is not a kernel image linker script.
> >
> > Add .discard and .discard.* to /DISCARD/ in zboot.lds, so that any
> > sections meant to be discarded at link time are not included in the
> > final zboot image. This issue is not specific to LoongArch, it is just
> > the first architecture to select CONFIG_OBJTOOL, which defines
> > annotate_unreachable() as an asm statement to add the
> > .discard.unreachable section, and use the EFI stub.
> >
> > Closes: https://github.com/ClangBuiltLinux/linux/issues/2023
> > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
>
> Thanks, I'll take this as a fix.
>
>
> > ---
> >  drivers/firmware/efi/libstub/zboot.lds | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/firmware/efi/libstub/zboot.lds b/drivers/firmware/efi/libstub/zboot.lds
> > index ac8c0ef85158..af2c82f7bd90 100644
> > --- a/drivers/firmware/efi/libstub/zboot.lds
> > +++ b/drivers/firmware/efi/libstub/zboot.lds
> > @@ -41,6 +41,7 @@ SECTIONS
> >         }
> >
> >         /DISCARD/ : {
> > +               *(.discard .discard.*)
> >                 *(.modinfo .init.modinfo)
> >         }
> >  }
> >
> > ---
> > base-commit: 15aa8fb852f995dd234a57f12dfb989044968bb6
> > change-id: 20240522-efi-zboot-lds-add-discard-sections-to-discard-5fe29bf42d6a
> >
> > Best regards,
> > --
> > Nathan Chancellor <nathan@kernel.org>
> >

      reply	other threads:[~2024-05-23  2:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-22 17:32 [PATCH] efi/libstub: zboot.lds: Discard .discard sections Nathan Chancellor
2024-05-22 17:37 ` Ard Biesheuvel
2024-05-23  2:19   ` Huacai Chen [this message]

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='CAAhV-H4EOV8cMPpO_=O4rnCNKcMwVa_NeeoA9w8unC5nJU5LzQ@mail.gmail.com' \
    --to=chenhuacai@kernel.org \
    --cc=ardb@kernel.org \
    --cc=justinstitt@google.com \
    --cc=kernel@xen0n.name \
    --cc=linux-efi@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=loongarch@lists.linux.dev \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=patches@lists.linux.dev \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).