Patchwork [U-Boot,1/6] mpc83xx: Add relocation support for -fpic

login
register
mail settings
Submitter Joakim Tjernlund
Date Nov. 23, 2010, 6:48 p.m.
Message ID <1290538131-12383-2-git-send-email-Joakim.Tjernlund@transmode.se>
Download mbox | patch
Permalink /patch/72716/
State RFC
Headers show

Comments

Joakim Tjernlund - Nov. 23, 2010, 6:48 p.m.
By rearranging the linker script we get support for
relocation of -fpic for free.
---
 arch/powerpc/cpu/mpc83xx/u-boot.lds             |    5 +++--
 nand_spl/board/freescale/mpc8313erdb/u-boot.lds |    4 +++-
 nand_spl/board/freescale/mpc8315erdb/u-boot.lds |    4 +++-
 3 files changed, 9 insertions(+), 4 deletions(-)

Patch

diff --git a/arch/powerpc/cpu/mpc83xx/u-boot.lds b/arch/powerpc/cpu/mpc83xx/u-boot.lds
index 0b74a13..877f298 100644
--- a/arch/powerpc/cpu/mpc83xx/u-boot.lds
+++ b/arch/powerpc/cpu/mpc83xx/u-boot.lds
@@ -67,13 +67,14 @@  SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    *(.got)
     _GOT2_TABLE_ = .;
     *(.got2)
+    *(.got)
+    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
     _FIXUP_TABLE_ = .;
     *(.fixup)
   }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >> 2;
+  __got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
   __fixup_entries = (. - _FIXUP_TABLE_) >> 2;
 
   .data    :
diff --git a/nand_spl/board/freescale/mpc8313erdb/u-boot.lds b/nand_spl/board/freescale/mpc8313erdb/u-boot.lds
index 853b2de..7c5a40f 100644
--- a/nand_spl/board/freescale/mpc8313erdb/u-boot.lds
+++ b/nand_spl/board/freescale/mpc8313erdb/u-boot.lds
@@ -40,8 +40,10 @@  SECTIONS
 		*(.sdata*)
 		_GOT2_TABLE_ = .;
 		*(.got2)
+		*(.got)
+		PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
 	}
-	__got2_entries = (. - _GOT2_TABLE_) >> 2;
+	__got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
 
 	. = ALIGN(8);
 	__bss_start = .;
diff --git a/nand_spl/board/freescale/mpc8315erdb/u-boot.lds b/nand_spl/board/freescale/mpc8315erdb/u-boot.lds
index 853b2de..7c5a40f 100644
--- a/nand_spl/board/freescale/mpc8315erdb/u-boot.lds
+++ b/nand_spl/board/freescale/mpc8315erdb/u-boot.lds
@@ -40,8 +40,10 @@  SECTIONS
 		*(.sdata*)
 		_GOT2_TABLE_ = .;
 		*(.got2)
+		*(.got)
+		PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
 	}
-	__got2_entries = (. - _GOT2_TABLE_) >> 2;
+	__got2_entries = ((_GLOBAL_OFFSET_TABLE_ - _GOT2_TABLE_) >> 2) - 1;
 
 	. = ALIGN(8);
 	__bss_start = .;