Subject: Re: [RFT PATCH] arm64: relocatable: build the kernel as a proper shared library

From: Will Deacon <[email-masked]>
Date: Mon, 3 Dec 2018 19:22:49 +0000

On Mon, Dec 03, 2018 at 10:29:00AM -0800, Nick Desaulniers wrote:
> On Mon, Dec 3, 2018 at 9:08 AM Will Deacon <[email-masked]> wrote:
> >
> > Hi Ard,
> >
> > On Sat, Dec 01, 2018 at 12:53:24PM +0100, Ard Biesheuvel wrote:
> > > readelf complains about the section layout of vmlinux when building
> > > with CONFIG_RELOCATABLE=y (for KASLR):
> > >
> > >   readelf: Warning: [21]: Link field (0) should index a symtab section.
> > >   readelf: Warning: [21]: Info field (0) should index a relocatable section.
> > >
> > > Also, it seems that our use of '-pie -shared' is contradictory, and
> > > thus ambiguous. In general, the way KASLR is wired up at the moment
> > > is highly tailored to how ld.bfd happens to implement (and conflate)
> > > PIE executables and shared libraries, so given the current effort to
> > > support other toolchains, let's fix some of these issues as well.
> > >
> > > - Drop the -pie linker argument and just leave -shared. In ld.bfd,
> > >   the differences between them are unclear (except for the ELF type
> > >   of the produced image [0]) but lld chokes on seeing both at the
> > >   same time.
> > >
> > > - Rename the .rela output section to .rela.dyn, as is customary for
> > >   shared libraries and PIE executables.
> > >
> > > - Don't discard the .dynamic, .dynsym, .dynstr and .hash sections.
> > >   Instead, make sure that they are [mostly] empty by marking all
> > >   symbols as local, and emit them into the .init segment.
> >
> > These second two changes seem fairly arbitrary to me: is lld unhappy without
> > them?
> 
> I don't know about .rela -> .rela.dyn, or .hash, but LLD developers
> just issued patches allowing the following sections to be discarded:
> 
> .dynamic:
> https://reviews.llvm.org/D55211
> .dynsym:
> https://reviews.llvm.org/D55218
> .dynstr:
> https://reviews.llvm.org/D55215

Thanks again.

> > My concern is that we'll make some other change in the future and run
> > into more arbitrary breakage. Is there any build bots hooked up with lld so
> > help us catch regressions quickly? (i.e nightly builds of mainline and next)
> 
> Yes.  We're running continuous integration at:
> https://github.com/ClangBuiltLinux/continuous-integration
> 
> We have nightly cron jobs building arm64 defconfigs with clang for
> mainline, -next, and some LTS branches of the stable tree. ex.
> https://travis-ci.com/ClangBuiltLinux/continuous-integration/builds/93312295

Great, that looks very promising! Hopefully that means we can keep things
building reliably once we get to that point.

Will

_______________________________________________
linux-arm-kernel mailing list
[email-masked]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel