* [PATCH] powerpc: Fix stackprotector detection for non-glibc toolchains
@ 2018-10-12 22:58 Michael Ellerman
2018-10-13 7:32 ` Christophe LEROY
2018-10-15 4:01 ` Michael Ellerman
0 siblings, 2 replies; 6+ messages in thread
From: Michael Ellerman @ 2018-10-12 22:58 UTC (permalink / raw)
To: linuxppc-dev
If GCC is not built with glibc support then we must explicitly tell it
which register to use for TLS mode stack protector, otherwise it will
error out and the cc-option check will fail.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/Kconfig | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 1888636c9eb6..3d008115fe18 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -180,7 +180,8 @@ config PPC
select HAVE_ARCH_SECCOMP_FILTER
select HAVE_ARCH_TRACEHOOK
select HAVE_CBPF_JIT if !PPC64
- select HAVE_STACKPROTECTOR if $(cc-option,-mstack-protector-guard=tls)
+ select HAVE_STACKPROTECTOR if PPC64 && $(cc-option,-mstack-protector-guard=tls -mstack-protector-guard-reg=r13)
+ select HAVE_STACKPROTECTOR if PPC32 && $(cc-option,-mstack-protector-guard=tls -mstack-protector-guard-reg=r2)
select HAVE_CONTEXT_TRACKING if PPC64
select HAVE_DEBUG_KMEMLEAK
select HAVE_DEBUG_STACKOVERFLOW
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] powerpc: Fix stackprotector detection for non-glibc toolchains
2018-10-12 22:58 [PATCH] powerpc: Fix stackprotector detection for non-glibc toolchains Michael Ellerman
@ 2018-10-13 7:32 ` Christophe LEROY
2018-10-13 11:55 ` Michael Ellerman
2018-10-15 4:01 ` Michael Ellerman
1 sibling, 1 reply; 6+ messages in thread
From: Christophe LEROY @ 2018-10-13 7:32 UTC (permalink / raw)
To: Michael Ellerman, linuxppc-dev
Le 13/10/2018 à 00:58, Michael Ellerman a écrit :
> If GCC is not built with glibc support then we must explicitly tell it
> which register to use for TLS mode stack protector, otherwise it will
> error out and the cc-option check will fail.
Oh ? I didn't encounter such a problem with the nolibc GCC from
https://mirrors.edge.kernel.org/pub/tools/crosstool/
I did all my tests with powerpc64-linux-gcc 8.1 on x86_64
Christophe
>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Reviewed-by: Christophe Leroy <christophe.leroy@c-s.fr>
> ---
> arch/powerpc/Kconfig | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index 1888636c9eb6..3d008115fe18 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -180,7 +180,8 @@ config PPC
> select HAVE_ARCH_SECCOMP_FILTER
> select HAVE_ARCH_TRACEHOOK
> select HAVE_CBPF_JIT if !PPC64
> - select HAVE_STACKPROTECTOR if $(cc-option,-mstack-protector-guard=tls)
> + select HAVE_STACKPROTECTOR if PPC64 && $(cc-option,-mstack-protector-guard=tls -mstack-protector-guard-reg=r13)
> + select HAVE_STACKPROTECTOR if PPC32 && $(cc-option,-mstack-protector-guard=tls -mstack-protector-guard-reg=r2)
> select HAVE_CONTEXT_TRACKING if PPC64
> select HAVE_DEBUG_KMEMLEAK
> select HAVE_DEBUG_STACKOVERFLOW
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] powerpc: Fix stackprotector detection for non-glibc toolchains
2018-10-13 7:32 ` Christophe LEROY
@ 2018-10-13 11:55 ` Michael Ellerman
2018-10-13 15:48 ` Segher Boessenkool
0 siblings, 1 reply; 6+ messages in thread
From: Michael Ellerman @ 2018-10-13 11:55 UTC (permalink / raw)
To: Christophe LEROY, linuxppc-dev, Segher Boessenkool
Christophe LEROY <christophe.leroy@c-s.fr> writes:
> Le 13/10/2018 à 00:58, Michael Ellerman a écrit :
>> If GCC is not built with glibc support then we must explicitly tell it
>> which register to use for TLS mode stack protector, otherwise it will
>> error out and the cc-option check will fail.
>
> Oh ? I didn't encounter such a problem with the nolibc GCC from
> https://mirrors.edge.kernel.org/pub/tools/crosstool/
Yes, you're right.
$ /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux-gcc -o empty.o -Wall -c empty.c -mstack-protector-guard=tls
$ echo $?
0
But with mine:
$ /home/kerkins/toolchains/ppc/gcc-8-branch/powerpc-linux/bin/powerpc-linux-gcc -o empty.o -Wall -c empty.c -mstack-protector-guard=tls
cc1: error: ‘-mstack-protector-guard=tls’ needs a valid base register
So it's only my cross compilers that don't work.
The kernel.org ones are:
Configured with: /home/arnd/git/gcc/configure --target=powerpc64-linux
--enable-targets=all
--prefix=/home/arnd/cross/x86_64/gcc-8.1.0-nolibc/powerpc64-linux
--enable-languages=c --without-headers --disable-bootstrap
--disable-nls --disable-threads --disable-shared --disable-libmudflap
--disable-libssp --disable-libgomp --disable-decimal-float
--disable-libquadmath --disable-libatomic --disable-libcc1
--disable-libmpx --enable-checking=release
Whereas mine is:
Configured with: ../../src/gcc/configure
--prefix=/home/kerkins/workspace/gcc-build/gcc/gcc-8-branch/target/ppc/build/install/powerpc-linux
--disable-multilib --disable-bootstrap --enable-languages=c
--with-pkgversion='Custom 2c79ff811dfcee1c' --target=powerpc-linux
--enable-targets=all
So I wonder if something in there is making the difference?
I guess I'll just rewrite the change log to say "some toolchains".
cheers
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] powerpc: Fix stackprotector detection for non-glibc toolchains
2018-10-13 11:55 ` Michael Ellerman
@ 2018-10-13 15:48 ` Segher Boessenkool
2018-10-15 9:36 ` Michael Ellerman
0 siblings, 1 reply; 6+ messages in thread
From: Segher Boessenkool @ 2018-10-13 15:48 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linuxppc-dev
On Sat, Oct 13, 2018 at 10:55:01PM +1100, Michael Ellerman wrote:
> So it's only my cross compilers that don't work.
>
> The kernel.org ones are:
> Configured with: /home/arnd/git/gcc/configure --target=powerpc64-linux
> --enable-targets=all
> --prefix=/home/arnd/cross/x86_64/gcc-8.1.0-nolibc/powerpc64-linux
> --enable-languages=c --without-headers --disable-bootstrap
> --disable-nls --disable-threads --disable-shared --disable-libmudflap
> --disable-libssp --disable-libgomp --disable-decimal-float
> --disable-libquadmath --disable-libatomic --disable-libcc1
> --disable-libmpx --enable-checking=release
>
> Whereas mine is:
> Configured with: ../../src/gcc/configure
> --prefix=/home/kerkins/workspace/gcc-build/gcc/gcc-8-branch/target/ppc/build/install/powerpc-linux
> --disable-multilib --disable-bootstrap --enable-languages=c
> --with-pkgversion='Custom 2c79ff811dfcee1c' --target=powerpc-linux
> --enable-targets=all
>
>
> So I wonder if something in there is making the difference?
You have --disable-libssp on the buildall-built compiler, which makes GCC
assume your libc has the SSP support routines, which gives you these default
offsets (which are what they are on glibc). Never mind that you explicitly
do not have a libc ;-)
> I guess I'll just rewrite the change log to say "some toolchains".
Or "most".
Segher
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: powerpc: Fix stackprotector detection for non-glibc toolchains
2018-10-12 22:58 [PATCH] powerpc: Fix stackprotector detection for non-glibc toolchains Michael Ellerman
2018-10-13 7:32 ` Christophe LEROY
@ 2018-10-15 4:01 ` Michael Ellerman
1 sibling, 0 replies; 6+ messages in thread
From: Michael Ellerman @ 2018-10-15 4:01 UTC (permalink / raw)
To: Michael Ellerman, linuxppc-dev
On Fri, 2018-10-12 at 22:58:32 UTC, Michael Ellerman wrote:
> If GCC is not built with glibc support then we must explicitly tell it
> which register to use for TLS mode stack protector, otherwise it will
> error out and the cc-option check will fail.
>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> Reviewed-by: Christophe Leroy <christophe.leroy@c-s.fr>
Applied to powerpc next.
https://git.kernel.org/powerpc/c/bf6cbd0c87f30d0e4401be91a8161c
cheers
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] powerpc: Fix stackprotector detection for non-glibc toolchains
2018-10-13 15:48 ` Segher Boessenkool
@ 2018-10-15 9:36 ` Michael Ellerman
0 siblings, 0 replies; 6+ messages in thread
From: Michael Ellerman @ 2018-10-15 9:36 UTC (permalink / raw)
To: Segher Boessenkool; +Cc: linuxppc-dev
Segher Boessenkool <segher@kernel.crashing.org> writes:
> On Sat, Oct 13, 2018 at 10:55:01PM +1100, Michael Ellerman wrote:
>> So it's only my cross compilers that don't work.
>>
>> The kernel.org ones are:
>> Configured with: /home/arnd/git/gcc/configure --target=powerpc64-linux
>> --enable-targets=all
>> --prefix=/home/arnd/cross/x86_64/gcc-8.1.0-nolibc/powerpc64-linux
>> --enable-languages=c --without-headers --disable-bootstrap
>> --disable-nls --disable-threads --disable-shared --disable-libmudflap
>> --disable-libssp --disable-libgomp --disable-decimal-float
>> --disable-libquadmath --disable-libatomic --disable-libcc1
>> --disable-libmpx --enable-checking=release
>>
>> Whereas mine is:
>> Configured with: ../../src/gcc/configure
>> --prefix=/home/kerkins/workspace/gcc-build/gcc/gcc-8-branch/target/ppc/build/install/powerpc-linux
>> --disable-multilib --disable-bootstrap --enable-languages=c
>> --with-pkgversion='Custom 2c79ff811dfcee1c' --target=powerpc-linux
>> --enable-targets=all
>>
>>
>> So I wonder if something in there is making the difference?
>
> You have --disable-libssp on the buildall-built compiler, which makes GCC
> assume your libc has the SSP support routines, which gives you these default
> offsets (which are what they are on glibc). Never mind that you explicitly
> do not have a libc ;-)
OK thanks, things just get weirder and weirder :)
>> I guess I'll just rewrite the change log to say "some toolchains".
>
> Or "most".
As it happens I forgot to update the change log anyway :/
Oh well.
cheers
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-10-15 9:54 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-12 22:58 [PATCH] powerpc: Fix stackprotector detection for non-glibc toolchains Michael Ellerman
2018-10-13 7:32 ` Christophe LEROY
2018-10-13 11:55 ` Michael Ellerman
2018-10-13 15:48 ` Segher Boessenkool
2018-10-15 9:36 ` Michael Ellerman
2018-10-15 4:01 ` Michael Ellerman
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.