From f170061c06269bcf4e9858cc91fbd2b708e556b6 Mon Sep 17 00:00:00 2001
From: =?utf8?q?=E9=BB=84=E6=B6=9B?= <huangtao@rock-chips.com>
Date: Fri, 22 Nov 2013 18:38:07 +0800
Subject: [PATCH] rk: add and fix PIE support

1) PIE depends on GENERIC_ALLOCATOR
2) fix old version objcopy -j do not support wildcard
3) add rockchip PIE section group
---
 arch/arm/kernel/pie.lds.S | 1 +
 lib/Kconfig               | 1 +
 pie/Makefile              | 2 ++
 3 files changed, 4 insertions(+)

diff --git a/arch/arm/kernel/pie.lds.S b/arch/arm/kernel/pie.lds.S
index 4fd5ac5b0807..7950758f36fb 100644
--- a/arch/arm/kernel/pie.lds.S
+++ b/arch/arm/kernel/pie.lds.S
@@ -23,6 +23,7 @@ SECTIONS
 
 	PIE_OVERLAY_START
 	OVERLAY : NOCROSSREFS {
+		PIE_OVERLAY_SECTION(rockchip)
 	}
 	PIE_OVERLAY_SEND
 
diff --git a/lib/Kconfig b/lib/Kconfig
index 8d428a5c8f01..61b4be9e603b 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -345,6 +345,7 @@ config HAVE_PIE
 config PIE
 	bool "Embedded position independant executables"
 	depends on HAVE_PIE
+	select GENERIC_ALLOCATOR
 	help
 	  This option adds support for embedding position indepentant (PIE)
 	  executables into the kernel. The PIEs can then be copied into
diff --git a/pie/Makefile b/pie/Makefile
index 9afed70fa0c5..954ae12d9cdd 100644
--- a/pie/Makefile
+++ b/pie/Makefile
@@ -62,6 +62,8 @@ $(obj)/pie_stage2.o: $(obj)/pie_stage1.o $(obj)/libpie_stage2.o
 
 # Drop everything but the pie sections
 OBJCOPYFLAGS_pie_stage3.o += -j ".pie.*"
+OBJCOPYFLAGS_pie_stage3.o += -j ".pie.text"
+OBJCOPYFLAGS_pie_stage3.o += -j ".pie.rockchip.text" -j ".pie.rockchip.data"
 
 $(obj)/pie_stage3.o: $(obj)/pie_stage2.o
 	$(call if_changed,objcopy)
-- 
2.34.1