[PATCH] [RFC] rs6000: -mreadonly-in-sdata (PR82411)

Segher Boessenkool segher@kernel.crashing.org
Thu Mar 1 00:39:00 GMT 2018


On Wed, Feb 28, 2018 at 04:15:23PM -0800, Kees Cook wrote:
> On Wed, Feb 28, 2018 at 3:23 PM, Segher Boessenkool
> <segher@kernel.crashing.org> wrote:
> > I'm trying to figure out how to get that file to build at all :-)

> $ CROSS_COMPILE=powerpc-linux-gnu- ARCH=powerpc make wii_defconfig
> $ for i in CONFIG_STRICT_KERNEL_RWX \
>            CONFIG_DEBUG_KERNEL \
>            CONFIG_DEBUG_RODATA_TEST ; do
>     CROSS_COMPILE=powerpc-linux-gnu- ARCH=powerpc ./scripts/config -e $i
> done

I use ppc6xx_defconfig normally; I had to disable CONFIG_HIBERNATION
as well.

Without the new flag, rodata_test_data ends up in .sdata in the object
file and in .data in vmlinux.

Adding

===
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index ccd2556..31b9613 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -143,6 +143,8 @@ CFLAGS-$(CONFIG_PPC64)      += $(call cc-option,-mcmodel=med
 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mno-pointers-to-nested-functions)
 CFLAGS-$(CONFIG_PPC32) := -ffixed-r2 $(MULTIPLEWORD)
 
+CFLAGS-$(CONFIG_PPC32)	+= $(call cc-option,-mno-readonly-in-sdata)
+
 ifeq ($(CONFIG_PPC_BOOK3S_64),y)
 CFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=power7,-mtune=power4)
 CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=power4
===

it ends up in .rodata in both.

It would be nice to have a more comprehensive test, but this will do; I'll
commit it tomorrow (will resend, with doc and changelog and all that).

Cheers,


Segher



More information about the Gcc-patches mailing list