Re: [PATCH 1/1] x86/entry/64: randomize kernel stack offset upon syscall

From: Kees Cook
Date: Wed Apr 10 2019 - 12:21:03 EST


On Wed, Apr 10, 2019 at 7:49 AM Andy Lutomirski <luto@xxxxxxxxxx> wrote:
> And build it like this, it fails:
>
> $ gcc -o ingo -g ingo.c -pie
> /usr/bin/ld: /tmp/ccofYU9N.o: relocation R_X86_64_32 against `.rodata'
> can not be used when making a PIE object; recompile with -fPIC
> /usr/bin/ld: final link failed: nonrepresentable section on output
> collect2: error: ld returned 1 exit status
>
> Which I assume means that -pie requires -fPIC, and your toolchain is
> screwed up and is defaulting to useless options. I'm guessing you
> should file a bug against your distro gcc package. For me, it works
> if I remove -pie.

I think you need both -fPIE (object creation) and -pie (linking).

--
Kees Cook