[PATCH 03/17] MIPS: reloc: fix relocation with CONFIG_64BIT enabled

Ahmad Fatoum a.fatoum at pengutronix.de
Tue Jun 6 01:08:23 PDT 2023


On 05.06.23 22:10, Denis Orlov wrote:
> Use CKSEG instead of KSEG, allowing it to compile on 64BIT
> configurations. Also make sure that we do not truncate target
> relocation address by writing it into a 32-bit wide variable.
> 
> Signed-off-by: Denis Orlov <denorl2009 at gmail.com>

Reviewd-by: Ahmad Fatoum <a.fatoum at pengutronix.de>

> ---
>  arch/mips/lib/reloc.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/mips/lib/reloc.c b/arch/mips/lib/reloc.c
> index b084a88be7..3c845a9663 100644
> --- a/arch/mips/lib/reloc.c
> +++ b/arch/mips/lib/reloc.c
> @@ -108,8 +108,7 @@ static void apply_reloc(unsigned int type, void *addr, long off)
>  
>  void relocate_code(void *fdt, u32 fdt_size, u32 ram_size)
>  {
> -	unsigned long addr, length, bss_len;
> -	u32 relocaddr, new_stack;
> +	unsigned long addr, length, bss_len, relocaddr, new_stack;
>  	uint8_t *buf;
>  	unsigned int type;
>  	long off;
> @@ -121,9 +120,9 @@ void relocate_code(void *fdt, u32 fdt_size, u32 ram_size)
>  	length = __bss_stop - __image_start;
>  	relocaddr = ALIGN_DOWN(ram_size - length, SZ_64K);
>  	if (IS_ENABLED(CONFIG_MMU)) {
> -		relocaddr = KSEG0ADDR(relocaddr);
> +		relocaddr = CKSEG0ADDR(relocaddr);
>  	} else {
> -		relocaddr = KSEG1ADDR(relocaddr);
> +		relocaddr = CKSEG1ADDR(relocaddr);
>  	}
>  	new_stack = relocaddr - MALLOC_SIZE - 16;
>  

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




More information about the barebox mailing list