Re: [PATCH] x86/build: Move _etext to actual end of .text

From: Kees Cook
Date: Thu Jun 20 2019 - 13:58:16 EST


On Wed, Jun 19, 2019 at 12:37:11PM -0600, Ross Zwisler wrote:
> On Sun, Jun 9, 2019 at 1:00 PM Johannes Hirte
> <johannes.hirte@xxxxxxxxxxxxx> wrote:
> > On 2019 Jun 09, Klaus Kusche wrote:
> > > Hello,
> > >
> > > Same problem for linux 5.1.7:
> > > Kernel building fails with the same relocation error.
> > >
> > > 5.1.5 does not have the problem, builds fine for me.
> > >
> > > Is there anything I can do to investigate the problem?
> > >
> >
> > Please try linux 5.1.8. The problematic patch was reverted there.
>
> I'm having this same issue with v5.2-rc5 using an older version of gcc
> (4.9.2). If I use a more recent version of gcc (7.3.0) it works fine.
>
> Reverting this patch allows gcc v4.9.2 to build kernel v5.2-rc5 successfully.
>
> You said in this chain that you were reverting this patch in stable
> kernels. Are you going to revert it in tip-of-tree as well?

My original rationale was that we shouldn't break old toolchains on
old kernels (i.e. if a stable kernel built before it should continue to
bulid). For the latest kernel it was fixing a future problem and
regularizing the linker script (other architectures already do it in
this style), however, it seems to not only be an old gcc issue, but also
a Gold linker issue. Building with LD=ld.gold blows up on a modern gcc
too:

$ gcc --version
gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
...
$ ld.gold --version
GNU gold (GNU Binutils for Ubuntu 2.30) 1.15
...
$ make LD=ld.gold ...
...
Invalid absolute R_X86_64_32S relocation: _etext

Ingo, seems like this should be reverted. What do you think?

--
Kees Cook