[U-Boot] [PATCH] arm: Add option to disable code relocation
Marek Vasut
marek.vasut at gmail.com
Sun Feb 5 13:05:47 CET 2012
> 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 at chromium.org>
> ---
> arch/arm/config.mk | 2 ++
> arch/arm/cpu/armv7/start.S | 3 +--
> arch/arm/include/asm/global_data.h | 3 +++
> arch/arm/lib/board.c | 10 ++++++++++
> 4 files changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/config.mk b/arch/arm/config.mk
> index 45f9dca..46b52af 100644
> --- a/arch/arm/config.mk
> +++ b/arch/arm/config.mk
> @@ -79,5 +79,7 @@ endif
>
> # needed for relocation
> ifndef CONFIG_NAND_SPL
> +ifndef CONFIG_SYS_SKIP_ARM_RELOCATION
> LDFLAGS_u-boot += -pie
> endif
> +endif
> diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S
> index ef08a55..82eac7c 100644
> --- a/arch/arm/cpu/armv7/start.S
> +++ b/arch/arm/cpu/armv7/start.S
> @@ -183,8 +183,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 c3ff789..23a6077 100644
> --- a/arch/arm/include/asm/global_data.h
> +++ b/arch/arm/include/asm/global_data.h
> @@ -77,6 +77,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 3d78274..81293c3 100644
> --- a/arch/arm/lib/board.c
> +++ b/arch/arm/lib/board.c
> @@ -355,6 +355,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
> @@ -363,6 +364,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
> /*
> @@ -419,6 +421,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;
> @@ -478,7 +484,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);
>
> #if !defined(CONFIG_SYS_NO_FLASH)
Why would you need this one ? Is there any user for this patch?
M
More information about the U-Boot
mailing list