Skip to contentSkip to conversation

nds32: Support relocation.

PATCH New Andes 1 participant 1 message Sep 29, 2016 Arm/actions semi architecture

lore
Share & tools
lore

Andes

author
#0 lore raw

PATCH 1/1 nds32: Support relocation.

From: rick <[email protected]>

Enable pie option for relocation.

---
 arch/nds32/config.mk                       |    2 +-
 arch/nds32/cpu/n1213/ag101/lowlevel_init.S |   13 +--
 arch/nds32/cpu/n1213/start.S               |  120 +++++++++++++++-------------
 arch/nds32/cpu/n1213/u-boot.lds            |   13 ++-
 arch/nds32/include/asm/config.h            |    2 -
 include/configs/adp-ag101p.h               |    1 -
 6 files changed, 77 insertions(+), 74 deletions(-)
arch/nds32/config.mk +1 -1
index 5ac9f90..ca76641 100644
@@ -19,4 +19,4 @@ PLATFORM_RELFLAGS	+= -fno-strict-aliasing -fno-common -mrelax
 PLATFORM_RELFLAGS	+= -gdwarf-2
 PLATFORM_CPPFLAGS	+= -D__nds32__ -G0 -ffixed-10 -fpie
 
-LDFLAGS_u-boot		= --gc-sections --relax
+LDFLAGS_u-boot		= --gc-sections --relax -pie
arch/nds32/cpu/n1213/ag101/lowlevel_init.S +5 -8
index 1a94868..abdd340 100644
@@ -6,6 +6,8 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
+.pic
+
 .text
 
 #include <common.h>
@@ -248,16 +250,11 @@ relo_base:
     */
 	li	$r5, AHBC_BSR6_A
 	lwi $r8, [$r5]
-	li	$r4, 0xfff00000
+	li	$r4, 0xfff00000   /* r4 = bank6 base */
 	and $r4, $r4, $r8
 
-
-	li	$r5, 0x0
-	la	$r1, relo_base				/* get $pc or $lp */
-	sub	$r2, $r0, $r1
-	sethi	$r6, hi20(_end)
-	ori	$r6, $r6, lo12(_end)
-	add	$r6, $r6, $r2
+	la	$r5, _start at GOTOFF
+	la  $r6, _end at GOTOFF
 1:
 	lwi.p	$r7, [$r5], #4
 	swi.p	$r7, [$r4], #4
arch/nds32/cpu/n1213/start.S +63 -57

196 lines not on this page · raw message

arch/nds32/cpu/n1213/u-boot.lds +8 -5
index b88d742..40db0e6 100644
@@ -31,25 +31,28 @@ SECTIONS
 
 	.got : {
 		__got_start = .;
-		 *(.got.plt) *(.got)
+		*(.got.plt) *(.got)
 		__got_end = .;
 	}
 
-	. = .;
-
 	. = ALIGN(4);
 	.u_boot_list : {
 		KEEP(*(SORT(.u_boot_list*)));
 	}
 
 	. = ALIGN(4);
-
+	/DISCARD/ : { *(.rela.plt*) }
+	.rela.dyn : {
+		__rel_dyn_start = .;
+		*(.rela*)
+		__rel_dyn_end = .;
+ }
 	_end = .;
 
 	.bss : {
 		__bss_start = .;
 		*(.bss)
-		 . = ALIGN(4);
+		. = ALIGN(4);
 		__bss_end = .;
 	}
 
arch/nds32/include/asm/config.h +0 -2
index 3d1886e..054cc48 100644
@@ -9,6 +9,4 @@
 #ifndef _ASM_CONFIG_H_
 #define _ASM_CONFIG_H_
 
-#define CONFIG_NEEDS_MANUAL_RELOC
-
 #endif
include/configs/adp-ag101p.h +0 -1
index 2499b39..0ef329c 100644
@@ -28,7 +28,6 @@
 #define CONFIG_CMDLINE_TAG			/* send commandline to Kernel */
 #define CONFIG_SETUP_MEMORY_TAGS	/* send memory definition to kernel */
 #define CONFIG_INITRD_TAG			/* send initrd params */
-#define CONFIG_NEEDS_MANUAL_RELOC
 
 #ifndef CONFIG_SKIP_LOWLEVEL_INIT
 #define CONFIG_MEM_REMAP
Signature · 1 line
1.7.1