summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2012-02-06 14:21:32 +0100
committerDirk Behme <dirk.behme@gmail.com>2012-11-11 11:42:28 +0100
commit8753f67f7e3f7a4b7b40d65213a710b7fb5daf85 (patch)
treedcf2801212f1e7121d1230b535221e562b81190c
parent91932f1f6124c339811d1dd2743497e73aa87a5f (diff)
arm: Add option to disable code relocation
This permits disabling the code relation in U-Boot which is useful when debugging with an ICE. To use it define CONFIG_SYS_SKIP_ARM_RELOCATION in your board. Signed-off-by: Simon Glass <sjg@chromium.org>
-rw-r--r--arch/arm/config.mk2
-rw-r--r--arch/arm/cpu/armv7/start.S3
-rw-r--r--arch/arm/include/asm/global_data.h3
-rw-r--r--arch/arm/lib/board.c10
4 files changed, 16 insertions, 2 deletions
diff --git a/arch/arm/config.mk b/arch/arm/config.mk
index 24b9d7c802..7f1f92f68c 100644
--- a/arch/arm/config.mk
+++ b/arch/arm/config.mk
@@ -85,8 +85,10 @@ endif
# needed for relocation
ifndef CONFIG_NAND_SPL
+ifndef CONFIG_SYS_SKIP_ARM_RELOCATION
LDFLAGS_u-boot += -pie
endif
+endif
#
# FIXME: binutils versions < 2.22 have a bug in the assembler where
diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S
index 7df97c5a3a..5d3b68a37f 100644
--- a/arch/arm/cpu/armv7/start.S
+++ b/arch/arm/cpu/armv7/start.S
@@ -182,8 +182,7 @@ stack_setup:
mov sp, r4
adr r0, _start
- cmp r0, r6
- moveq r9, #0 /* no relocation. relocation offset(r9) = 0 */
+ subs r9, r6, r0 /* r9 <- relocation offset */
beq clear_bss /* skip relocation */
mov r1, r6 /* r1 <- scratch for copy_loop */
ldr r3, _image_copy_end_ofs
diff --git a/arch/arm/include/asm/global_data.h b/arch/arm/include/asm/global_data.h
index 2b9af93806..50958b5abe 100644
--- a/arch/arm/include/asm/global_data.h
+++ b/arch/arm/include/asm/global_data.h
@@ -75,6 +75,9 @@ typedef struct global_data {
unsigned long tlb_addr;
#endif
const void *fdt_blob; /* Our device tree, NULL if none */
+#ifdef CONFIG_SYS_SKIP_ARM_RELOCATION
+ ulong malloc_end; /* End of malloc region (addr + 1) */
+#endif
void **jt; /* jump table */
char env_buf[32]; /* buffer for getenv() before reloc. */
#if defined(CONFIG_POST) || defined(CONFIG_LOGBUFFER)
diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
index 92cad9a6eb..ce468c2dc6 100644
--- a/arch/arm/lib/board.c
+++ b/arch/arm/lib/board.c
@@ -369,6 +369,7 @@ void board_init_f(ulong bootflag)
#endif /* CONFIG_FB_ADDR */
#endif /* CONFIG_LCD */
+#ifndef CONFIG_SYS_SKIP_ARM_RELOCATION
/*
* reserve memory for U-Boot code, data & bss
* round down to next 4 kB limit
@@ -377,6 +378,7 @@ void board_init_f(ulong bootflag)
addr &= ~(4096 - 1);
debug("Reserving %ldk for U-Boot at: %08lx\n", gd->mon_len >> 10, addr);
+#endif
#ifndef CONFIG_SPL_BUILD
/*
@@ -449,6 +451,10 @@ void board_init_f(ulong bootflag)
dram_init_banksize();
display_dram_config(); /* and display it */
+#ifdef CONFIG_SYS_SKIP_ARM_RELOCATION
+ gd->malloc_end = addr;
+ addr = _TEXT_BASE;
+#endif
gd->relocaddr = addr;
gd->start_addr_sp = addr_sp;
gd->reloc_off = addr - _TEXT_BASE;
@@ -519,7 +525,11 @@ void board_init_r(gd_t *id, ulong dest_addr)
#endif
/* The Malloc area is immediately below the monitor copy in DRAM */
+#ifdef CONFIG_SYS_SKIP_ARM_RELOCATION
+ malloc_start = gd->malloc_end - TOTAL_MALLOC_LEN;
+#else
malloc_start = dest_addr - TOTAL_MALLOC_LEN;
+#endif
mem_malloc_init (malloc_start, TOTAL_MALLOC_LEN);
#ifdef CONFIG_ARCH_EARLY_INIT_R