[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202010121426.A5FA5E59@keescook>
Date: Mon, 12 Oct 2020 14:26:52 -0700
From: Kees Cook <keescook@...omium.org>
To: Fāng-ruì Sòng <maskray@...gle.com>
Cc: Nick Desaulniers <ndesaulniers@...gle.com>,
Nathan Chancellor <natechancellor@...il.com>,
Ingo Molnar <mingo@...nel.org>,
Russell King <linux@...linux.org.uk>,
Linux ARM <linux-arm-kernel@...ts.infradead.org>,
LKML <linux-kernel@...r.kernel.org>,
clang-built-linux <clang-built-linux@...glegroups.com>,
kernel test robot <lkp@...el.com>
Subject: Re: [PATCH] arm/build: Always handle .ARM.exidx and .ARM.extab
sections
On Mon, Oct 12, 2020 at 02:22:03PM -0700, Fāng-ruì Sòng wrote:
> On Mon, Oct 12, 2020 at 2:11 PM 'Nick Desaulniers' via Clang Built
> Linux <clang-built-linux@...glegroups.com> wrote:
> >
> > On Mon, Sep 28, 2020 at 3:49 PM Nathan Chancellor
> > <natechancellor@...il.com> wrote:
> > >
> > > After turning on warnings for orphan section placement, enabling
> > > CONFIG_UNWINDER_FRAME_POINTER instead of CONFIG_UNWINDER_ARM causes
> > > thousands of warnings when clang + ld.lld are used:
> > >
> > > $ scripts/config --file arch/arm/configs/multi_v7_defconfig \
> > > -d CONFIG_UNWINDER_ARM \
> > > -e CONFIG_UNWINDER_FRAME_POINTER
> > > $ make -skj"$(nproc)" ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- LLVM=1 defconfig zImage
> > > ld.lld: warning: init/built-in.a(main.o):(.ARM.extab) is being placed in '.ARM.extab'
> > > ld.lld: warning: init/built-in.a(main.o):(.ARM.extab.init.text) is being placed in '.ARM.extab.init.text'
> > > ld.lld: warning: init/built-in.a(main.o):(.ARM.extab.ref.text) is being placed in '.ARM.extab.ref.text'
> > > ld.lld: warning: init/built-in.a(do_mounts.o):(.ARM.extab.init.text) is being placed in '.ARM.extab.init.text'
> > > ld.lld: warning: init/built-in.a(do_mounts.o):(.ARM.extab) is being placed in '.ARM.extab'
> > > ld.lld: warning: init/built-in.a(do_mounts_rd.o):(.ARM.extab.init.text) is being placed in '.ARM.extab.init.text'
> > > ld.lld: warning: init/built-in.a(do_mounts_rd.o):(.ARM.extab) is being placed in '.ARM.extab'
> > > ld.lld: warning: init/built-in.a(do_mounts_initrd.o):(.ARM.extab.init.text) is being placed in '.ARM.extab.init.text'
> > > ld.lld: warning: init/built-in.a(initramfs.o):(.ARM.extab.init.text) is being placed in '.ARM.extab.init.text'
> > > ld.lld: warning: init/built-in.a(initramfs.o):(.ARM.extab) is being placed in '.ARM.extab'
> > > ld.lld: warning: init/built-in.a(calibrate.o):(.ARM.extab.init.text) is being placed in '.ARM.extab.init.text'
> > > ld.lld: warning: init/built-in.a(calibrate.o):(.ARM.extab) is being placed in '.ARM.extab'
> > >
> > > These sections are handled by the ARM_UNWIND_SECTIONS define, which is
> > > only added to the list of sections when CONFIG_ARM_UNWIND is set.
> > > CONFIG_ARM_UNWIND is a hidden symbol that is only selected when
> > > CONFIG_UNWINDER_ARM is set so CONFIG_UNWINDER_FRAME_POINTER never
> > > handles these sections. According to the help text of
> > > CONFIG_UNWINDER_ARM, these sections should be discarded so that the
> > > kernel image size is not affected.
> >
> > My apologies for taking so long to review this.
> >
> > I have a suspicion that these come from forcing on configs that
> > Kconfig/menuconfig would block, and aren't clang or lld specific, yet
> > are exposed by the new linker warnings for orphan section placement
> > (good). That said, we definitely have OEMs in Android land that still
> > prefer the older unwinder.
> >
> > From https://developer.arm.com/documentation/ihi0038/b/ (click
> > download in top left), section 4.4.1 "Sections" has a note:
> >
> > ```
> > Tables are not required for ABI compliance at the C/Assembler level
> > but are required for C++.
> > ```
> >
> > Review-by: Nick Desaulniers <ndesaulniers@...gle.com>
> > Tested-by: Nick Desaulniers <ndesaulniers@...gle.com>
> >
> > Please submit to:
> > https://www.arm.linux.org.uk/developer/patches/add.php
> >
> > >
> > > Fixes: 5a17850e251a ("arm/build: Warn on orphan section placement")
> > > Link: https://github.com/ClangBuiltLinux/linux/issues/1152
> > > Reported-by: kernel test robot <lkp@...el.com>
> > > Signed-off-by: Nathan Chancellor <natechancellor@...il.com>
> > > ---
> > > arch/arm/kernel/vmlinux.lds.S | 4 ++++
> > > 1 file changed, 4 insertions(+)
> > >
> > > diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
> > > index 5f4922e858d0..a2c0d96b0580 100644
> > > --- a/arch/arm/kernel/vmlinux.lds.S
> > > +++ b/arch/arm/kernel/vmlinux.lds.S
> > > @@ -40,6 +40,10 @@ SECTIONS
> > > ARM_DISCARD
> > > #ifndef CONFIG_SMP_ON_UP
> > > *(.alt.smp.init)
> > > +#endif
> > > +#ifndef CONFIG_ARM_UNWIND
> > > + *(.ARM.exidx*)
> >
> > I don't think we need the wildcard, as without this line, I see:
> >
> > ld.lld: warning: <internal>:(.ARM.exidx) is being placed in '.ARM.exidx'
>
> We may need the wildcard if there are -ffunction-sections builds.
> In clang, .ARM.exidx* cannot be removed even with -fno-unwind-tables
> -fno-exceptions.
Does it need to be:
*(.ARM.exidx) *(.ARM.exidx.*)
*(.ARM.extab) *(.ARM.extab.*)
?
>
> > though I do see binutils linker scripts use precisely what you have.
> > So I guess that's fine.
> >
> > I guess we can't reuse `ARM_UNWIND_SECTIONS` since the ALIGN and
> > linker-script-defined-symbols would be weird in a DISCARD clause?
> >
> >
> > > + *(.ARM.extab*)
> > > #endif
> > > }
> > >
> > >
> > > base-commit: 6e0bf0e0e55000742a53c5f3b58f8669e0091a11
> > > --
> >
> >
> > --
> > Thanks,
> > ~Nick Desaulniers
> >
> > --
> > You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
> > To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@...glegroups.com.
> > To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/CAKwvOd%3D%2B98r6F4JjrPEoWX88WQ%3DB-KMRP2eWojabLk6it3i5KA%40mail.gmail.com.
>
>
>
> --
> 宋方睿
--
Kees Cook
Powered by blists - more mailing lists