[U-Boot] [PATCH 3/3] linker: Modify linker scripts to be more generic
Adam Ford
aford173 at gmail.com
Wed Jan 23 20:21:25 UTC 2019
On Tue, Jan 22, 2019 at 4:09 PM Tom Rini <trini at konsulko.com> wrote:
>
> Make use of "IMAGE_MAX_SIZE" and "IMAGE_TEXT_BASE" rather than
> CONFIG_SPL_MAX_SIZE and CONFIG_SPL_TEXT_BASE. This lets us re-use the
> same script for both SPL and TPL. Add logic to scripts/Makefile.spl to
> pass in the right value when preprocessing the script.
Anytime we can re-use, I am happy. :-)
>
> Cc: Stefano Babic <sbabic at denx.de>
> Cc: Fabio Estevam <fabio.estevam at nxp.com>
> Cc: Jagan Teki <jagan at openedev.com>
> Cc: Maxime Ripard <maxime.ripard at bootlin.com>
> Cc: Andreas Bießmann <andreas at biessmann.org>
> Cc: Philipp Tomsich <philipp.tomsich at theobroma-systems.com>
> Cc: Michal Simek <monstr at monstr.eu>
> Cc: Daniel Schwierzeck <daniel.schwierzeck at gmail.com>
> Cc: York Sun <york.sun at nxp.com>
> Cc: Bin Meng <bmeng.cn at gmail.com>
> Cc: Heiko Schocher <hs at denx.de>
> Cc: Adam Ford <aford173 at gmail.com>
Tested-by: Adam Ford <aford173 at gmail.com> #da850evm & omap3_logic_somlv
> Signed-off-by: Tom Rini <trini at konsulko.com>
> ---
> arch/arm/cpu/arm1136/u-boot-spl.lds | 4 ++--
> arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds | 2 +-
> arch/arm/cpu/arm926ejs/orion5x/u-boot-spl.lds | 4 ++--
> arch/arm/cpu/arm926ejs/spear/u-boot-spl.lds | 4 ++--
> arch/arm/cpu/armv7/sunxi/u-boot-spl.lds | 4 ++--
> arch/arm/cpu/armv8/u-boot-spl.lds | 4 ++--
> arch/arm/cpu/u-boot-spl.lds | 4 ++--
> arch/arm/mach-at91/arm926ejs/u-boot-spl.lds | 8 ++++----
> arch/arm/mach-at91/armv7/u-boot-spl.lds | 4 ++--
> arch/arm/mach-omap2/u-boot-spl.lds | 4 ++--
> arch/arm/mach-rockchip/Kconfig | 6 ------
> arch/arm/mach-rockchip/rk3288/u-boot-tpl.lds | 9 ---------
> arch/arm/mach-rockchip/rk3368/u-boot-tpl.lds | 12 ------------
> arch/arm/mach-zynq/u-boot-spl.lds | 4 ++--
> arch/mips/cpu/u-boot-spl.lds | 4 ++--
> arch/powerpc/cpu/mpc85xx/u-boot-spl.lds | 6 +-----
> arch/x86/cpu/u-boot-spl.lds | 2 +-
> board/Barix/ipam390/u-boot-spl-ipam390.lds | 2 +-
> board/davinci/da8xxevm/u-boot-spl-da850evm.lds | 2 +-
> board/samsung/common/exynos-uboot-spl.lds | 2 +-
> common/spl/Kconfig | 2 ++
> scripts/Makefile.spl | 9 +++++++++
> 22 files changed, 41 insertions(+), 61 deletions(-)
> delete mode 100644 arch/arm/mach-rockchip/rk3288/u-boot-tpl.lds
> delete mode 100644 arch/arm/mach-rockchip/rk3368/u-boot-tpl.lds
>
> diff --git a/arch/arm/cpu/arm1136/u-boot-spl.lds b/arch/arm/cpu/arm1136/u-boot-spl.lds
> index 881275adef51..f83988fd7e6a 100644
> --- a/arch/arm/cpu/arm1136/u-boot-spl.lds
> +++ b/arch/arm/cpu/arm1136/u-boot-spl.lds
> @@ -8,8 +8,8 @@
> * Aneesh V <aneesh at ti.com>
> */
>
> -MEMORY { .sram : ORIGIN = CONFIG_SPL_TEXT_BASE,\
> - LENGTH = CONFIG_SPL_MAX_SIZE }
> +MEMORY { .sram : ORIGIN = IMAGE_TEXT_BASE,\
> + LENGTH = IMAGE_MAX_SIZE }
> MEMORY { .sdram : ORIGIN = CONFIG_SPL_BSS_START_ADDR, \
> LENGTH = CONFIG_SPL_BSS_MAX_SIZE }
>
> diff --git a/arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds b/arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds
> index ffc70ce86bfd..7e20448f8108 100644
> --- a/arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds
> +++ b/arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds
> @@ -15,7 +15,7 @@ OUTPUT_ARCH(arm)
> ENTRY(_start)
> SECTIONS
> {
> - . = CONFIG_SPL_TEXT_BASE;
> + . = IMAGE_TEXT_BASE;
>
> . = ALIGN(4);
> .text :
> diff --git a/arch/arm/cpu/arm926ejs/orion5x/u-boot-spl.lds b/arch/arm/cpu/arm926ejs/orion5x/u-boot-spl.lds
> index fbdb1d7e77a4..a537fe02954b 100644
> --- a/arch/arm/cpu/arm926ejs/orion5x/u-boot-spl.lds
> +++ b/arch/arm/cpu/arm926ejs/orion5x/u-boot-spl.lds
> @@ -16,8 +16,8 @@
> * Texas Instruments, <www.ti.com>
> * Aneesh V <aneesh at ti.com>
> */
> -MEMORY { .nor : ORIGIN = CONFIG_SPL_TEXT_BASE,\
> - LENGTH = CONFIG_SPL_MAX_SIZE }
> +MEMORY { .nor : ORIGIN = IMAGE_TEXT_BASE,\
> + LENGTH = IMAGE_MAX_SIZE }
> MEMORY { .bss : ORIGIN = CONFIG_SPL_BSS_START_ADDR, \
> LENGTH = CONFIG_SPL_BSS_MAX_SIZE }
>
> diff --git a/arch/arm/cpu/arm926ejs/spear/u-boot-spl.lds b/arch/arm/cpu/arm926ejs/spear/u-boot-spl.lds
> index 569704c317e9..0964a9742e4c 100644
> --- a/arch/arm/cpu/arm926ejs/spear/u-boot-spl.lds
> +++ b/arch/arm/cpu/arm926ejs/spear/u-boot-spl.lds
> @@ -12,8 +12,8 @@
> * Gary Jennejohn, DENX Software Engineering, <garyj at denx.de>
> */
>
> -MEMORY { .sram : ORIGIN = CONFIG_SPL_TEXT_BASE,\
> - LENGTH = CONFIG_SPL_MAX_SIZE }
> +MEMORY { .sram : ORIGIN = IMAGE_TEXT_BASE,\
> + LENGTH = IMAGE_MAX_SIZE }
>
> OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
> OUTPUT_ARCH(arm)
> diff --git a/arch/arm/cpu/armv7/sunxi/u-boot-spl.lds b/arch/arm/cpu/armv7/sunxi/u-boot-spl.lds
> index 5d7f3f578bef..942c29fc959d 100644
> --- a/arch/arm/cpu/armv7/sunxi/u-boot-spl.lds
> +++ b/arch/arm/cpu/armv7/sunxi/u-boot-spl.lds
> @@ -13,8 +13,8 @@
> * Texas Instruments, <www.ti.com>
> * Aneesh V <aneesh at ti.com>
> */
> -MEMORY { .sram : ORIGIN = CONFIG_SPL_TEXT_BASE,\
> - LENGTH = CONFIG_SPL_MAX_SIZE }
> +MEMORY { .sram : ORIGIN = IMAGE_TEXT_BASE,\
> + LENGTH = IMAGE_MAX_SIZE }
> MEMORY { .sdram : ORIGIN = CONFIG_SPL_BSS_START_ADDR, \
> LENGTH = CONFIG_SPL_BSS_MAX_SIZE }
>
> diff --git a/arch/arm/cpu/armv8/u-boot-spl.lds b/arch/arm/cpu/armv8/u-boot-spl.lds
> index 4e48da56be89..ccbf359bd11d 100644
> --- a/arch/arm/cpu/armv8/u-boot-spl.lds
> +++ b/arch/arm/cpu/armv8/u-boot-spl.lds
> @@ -11,8 +11,8 @@
> * Aneesh V <aneesh at ti.com>
> */
>
> -MEMORY { .sram : ORIGIN = CONFIG_SPL_TEXT_BASE,
> - LENGTH = CONFIG_SPL_MAX_SIZE }
> +MEMORY { .sram : ORIGIN = IMAGE_TEXT_BASE,
> + LENGTH = IMAGE_MAX_SIZE }
> MEMORY { .sdram : ORIGIN = CONFIG_SPL_BSS_START_ADDR,
> LENGTH = CONFIG_SPL_BSS_MAX_SIZE }
>
> diff --git a/arch/arm/cpu/u-boot-spl.lds b/arch/arm/cpu/u-boot-spl.lds
> index 9d1333176b54..a2aa93a7357d 100644
> --- a/arch/arm/cpu/u-boot-spl.lds
> +++ b/arch/arm/cpu/u-boot-spl.lds
> @@ -78,8 +78,8 @@ SECTIONS
> .ARM.exidx : { *(.ARM.exidx*) }
> }
>
> -#if defined(CONFIG_SPL_MAX_SIZE)
> -ASSERT(__image_copy_end - __image_copy_start < (CONFIG_SPL_MAX_SIZE), \
> +#if defined(IMAGE_MAX_SIZE)
> +ASSERT(__image_copy_end - __image_copy_start < (IMAGE_MAX_SIZE), \
> "SPL image too big");
> #endif
>
> diff --git a/arch/arm/mach-at91/arm926ejs/u-boot-spl.lds b/arch/arm/mach-at91/arm926ejs/u-boot-spl.lds
> index b714e93b3b21..f18b17dc931c 100644
> --- a/arch/arm/mach-at91/arm926ejs/u-boot-spl.lds
> +++ b/arch/arm/mach-at91/arm926ejs/u-boot-spl.lds
> @@ -4,8 +4,8 @@
> * Bo Shen <voice.shen at atmel.com>
> */
>
> -MEMORY { .sram : ORIGIN = CONFIG_SPL_TEXT_BASE, \
> - LENGTH = CONFIG_SPL_MAX_SIZE }
> +MEMORY { .sram : ORIGIN = IMAGE_TEXT_BASE, \
> + LENGTH = IMAGE_MAX_SIZE }
> MEMORY { .sdram : ORIGIN = CONFIG_SPL_BSS_START_ADDR, \
> LENGTH = CONFIG_SPL_BSS_MAX_SIZE }
>
> @@ -49,8 +49,8 @@ SECTIONS
> } >.sdram
> }
>
> -#if defined(CONFIG_SPL_MAX_SIZE)
> -ASSERT(__image_copy_end - __start < (CONFIG_SPL_MAX_SIZE), \
> +#if defined(IMAGE_MAX_SIZE)
> +ASSERT(__image_copy_end - __start < (IMAGE_MAX_SIZE), \
> "SPL image too big");
> #endif
>
> diff --git a/arch/arm/mach-at91/armv7/u-boot-spl.lds b/arch/arm/mach-at91/armv7/u-boot-spl.lds
> index 22237cffc92f..950ea55d7c4e 100644
> --- a/arch/arm/mach-at91/armv7/u-boot-spl.lds
> +++ b/arch/arm/mach-at91/armv7/u-boot-spl.lds
> @@ -11,8 +11,8 @@
> * Bo Shen <voice.shen at atmel.com>
> */
>
> -MEMORY { .sram : ORIGIN = CONFIG_SPL_TEXT_BASE, \
> - LENGTH = CONFIG_SPL_MAX_SIZE }
> +MEMORY { .sram : ORIGIN = IMAGE_TEXT_BASE, \
> + LENGTH = IMAGE_MAX_SIZE }
> MEMORY { .sdram : ORIGIN = CONFIG_SPL_BSS_START_ADDR, \
> LENGTH = CONFIG_SPL_BSS_MAX_SIZE }
>
> diff --git a/arch/arm/mach-omap2/u-boot-spl.lds b/arch/arm/mach-omap2/u-boot-spl.lds
> index a1289f6a7440..88d81f9b98d6 100644
> --- a/arch/arm/mach-omap2/u-boot-spl.lds
> +++ b/arch/arm/mach-omap2/u-boot-spl.lds
> @@ -8,8 +8,8 @@
> * Aneesh V <aneesh at ti.com>
> */
>
> -MEMORY { .sram : ORIGIN = CONFIG_SPL_TEXT_BASE,\
> - LENGTH = CONFIG_SPL_MAX_SIZE }
> +MEMORY { .sram : ORIGIN = IMAGE_TEXT_BASE,\
> + LENGTH = IMAGE_MAX_SIZE }
> MEMORY { .sdram : ORIGIN = CONFIG_SPL_BSS_START_ADDR, \
> LENGTH = CONFIG_SPL_BSS_MAX_SIZE }
>
> diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
> index b0082416b0c6..8e9d88c3f9fa 100644
> --- a/arch/arm/mach-rockchip/Kconfig
> +++ b/arch/arm/mach-rockchip/Kconfig
> @@ -75,9 +75,6 @@ config ROCKCHIP_RK3288
>
> if ROCKCHIP_RK3288
>
> -config TPL_LDSCRIPT
> - default "arch/arm/mach-rockchip/rk3288/u-boot-tpl.lds"
> -
> config TPL_TEXT_BASE
> default 0xff704000
>
> @@ -120,9 +117,6 @@ config ROCKCHIP_RK3368
>
> if ROCKCHIP_RK3368
>
> -config TPL_LDSCRIPT
> - default "arch/arm/mach-rockchip/rk3368/u-boot-tpl.lds"
> -
> config TPL_TEXT_BASE
> default 0xff8c1000
>
> diff --git a/arch/arm/mach-rockchip/rk3288/u-boot-tpl.lds b/arch/arm/mach-rockchip/rk3288/u-boot-tpl.lds
> deleted file mode 100644
> index 2e559890ab78..000000000000
> --- a/arch/arm/mach-rockchip/rk3288/u-boot-tpl.lds
> +++ /dev/null
> @@ -1,9 +0,0 @@
> -/* SPDX-License-Identifier: GPL-2.0+ */
> -/*
> - * Copyright (C) 2018 Jagan Teki <jagan at amarulasolutions.com>
> - */
> -
> -#undef CONFIG_SPL_TEXT_BASE
> -#define CONFIG_SPL_TEXT_BASE CONFIG_TPL_TEXT_BASE
> -
> -#include "../../cpu/u-boot-spl.lds"
> diff --git a/arch/arm/mach-rockchip/rk3368/u-boot-tpl.lds b/arch/arm/mach-rockchip/rk3368/u-boot-tpl.lds
> deleted file mode 100644
> index 7ba35b6c94db..000000000000
> --- a/arch/arm/mach-rockchip/rk3368/u-boot-tpl.lds
> +++ /dev/null
> @@ -1,12 +0,0 @@
> -/* SPDX-License-Identifier: GPL-2.0+ */
> -/*
> - * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH
> - */
> -
> -#undef CONFIG_SPL_TEXT_BASE
> -#define CONFIG_SPL_TEXT_BASE CONFIG_TPL_TEXT_BASE
> -
> -#undef CONFIG_SPL_MAX_SIZE
> -#define CONFIG_SPL_MAX_SIZE CONFIG_TPL_MAX_SIZE
> -
> -#include "../../cpu/armv8/u-boot-spl.lds"
> diff --git a/arch/arm/mach-zynq/u-boot-spl.lds b/arch/arm/mach-zynq/u-boot-spl.lds
> index 080c6bf06d06..106d2e390ba8 100644
> --- a/arch/arm/mach-zynq/u-boot-spl.lds
> +++ b/arch/arm/mach-zynq/u-boot-spl.lds
> @@ -7,8 +7,8 @@
> * Gary Jennejohn, DENX Software Engineering, <garyj at denx.de>
> */
>
> -MEMORY { .sram : ORIGIN = CONFIG_SPL_TEXT_BASE,\
> - LENGTH = CONFIG_SPL_MAX_SIZE }
> +MEMORY { .sram : ORIGIN = IMAGE_TEXT_BASE,\
> + LENGTH = IMAGE_MAX_SIZE }
> MEMORY { .sdram : ORIGIN = CONFIG_SPL_BSS_START_ADDR, \
> LENGTH = CONFIG_SPL_BSS_MAX_SIZE }
>
> diff --git a/arch/mips/cpu/u-boot-spl.lds b/arch/mips/cpu/u-boot-spl.lds
> index be194d314b64..d08d6222c4ab 100644
> --- a/arch/mips/cpu/u-boot-spl.lds
> +++ b/arch/mips/cpu/u-boot-spl.lds
> @@ -1,7 +1,7 @@
> /* SPDX-License-Identifier: GPL-2.0+ */
>
> -MEMORY { .spl_mem : ORIGIN = CONFIG_SPL_TEXT_BASE, \
> - LENGTH = CONFIG_SPL_MAX_SIZE }
> +MEMORY { .spl_mem : ORIGIN = IMAGE_TEXT_BASE, \
> + LENGTH = IMAGE_MAX_SIZE }
> MEMORY { .bss_mem : ORIGIN = CONFIG_SPL_BSS_START_ADDR, \
> LENGTH = CONFIG_SPL_BSS_MAX_SIZE }
>
> diff --git a/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds b/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds
> index bd0eeb104260..27a5fe6306a3 100644
> --- a/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds
> +++ b/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds
> @@ -18,11 +18,7 @@ PHDRS
> #endif
> SECTIONS
> {
> -#ifdef CONFIG_TPL_BUILD
> - . = CONFIG_TPL_TEXT_BASE;
> -#else
> - . = CONFIG_SPL_TEXT_BASE;
> -#endif
> + . = IMAGE_TEXT_BASE;
> .text : {
> *(.text*)
> }
> diff --git a/arch/x86/cpu/u-boot-spl.lds b/arch/x86/cpu/u-boot-spl.lds
> index 574d992aaa98..4e656dc4e5a7 100644
> --- a/arch/x86/cpu/u-boot-spl.lds
> +++ b/arch/x86/cpu/u-boot-spl.lds
> @@ -15,7 +15,7 @@ SECTIONS
> /DISCARD/ : { *(.u_boot_list_2_cmd_*) }
> #endif
>
> - . = CONFIG_SPL_TEXT_BASE; /* Location of bootcode in flash */
> + . = IMAGE_TEXT_BASE; /* Location of bootcode in flash */
> __text_start = .;
> .text : { *(.text*); }
>
> diff --git a/board/Barix/ipam390/u-boot-spl-ipam390.lds b/board/Barix/ipam390/u-boot-spl-ipam390.lds
> index cf13e0a41cd3..06ed3fa89f81 100644
> --- a/board/Barix/ipam390/u-boot-spl-ipam390.lds
> +++ b/board/Barix/ipam390/u-boot-spl-ipam390.lds
> @@ -7,7 +7,7 @@
> * Guennadi Liakhovetki, DENX Software Engineering, <lg at denx.de>
> */
>
> -MEMORY { .sram : ORIGIN = CONFIG_SPL_TEXT_BASE,\
> +MEMORY { .sram : ORIGIN = IMAGE_TEXT_BASE,\
> LENGTH = CONFIG_SPL_MAX_FOOTPRINT }
>
> OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
> diff --git a/board/davinci/da8xxevm/u-boot-spl-da850evm.lds b/board/davinci/da8xxevm/u-boot-spl-da850evm.lds
> index f5462f88b1eb..7b5fab7756cb 100644
> --- a/board/davinci/da8xxevm/u-boot-spl-da850evm.lds
> +++ b/board/davinci/da8xxevm/u-boot-spl-da850evm.lds
> @@ -7,7 +7,7 @@
> * Guennadi Liakhovetki, DENX Software Engineering, <lg at denx.de>
> */
>
> -MEMORY { .sram : ORIGIN = CONFIG_SPL_TEXT_BASE,\
> +MEMORY { .sram : ORIGIN = IMAGE_TEXT_BASE,\
> LENGTH = CONFIG_SPL_MAX_FOOTPRINT }
>
> OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
> diff --git a/board/samsung/common/exynos-uboot-spl.lds b/board/samsung/common/exynos-uboot-spl.lds
> index 0d4be426b69b..5b32f7feb817 100644
> --- a/board/samsung/common/exynos-uboot-spl.lds
> +++ b/board/samsung/common/exynos-uboot-spl.lds
> @@ -8,7 +8,7 @@
> * Based on arch/arm/cpu/armv7/omap-common/u-boot-spl.lds
> */
>
> -MEMORY { .sram : ORIGIN = CONFIG_SPL_TEXT_BASE, \
> +MEMORY { .sram : ORIGIN = IMAGE_TEXT_BASE, \
> LENGTH = CONFIG_SPL_MAX_FOOTPRINT }
>
> OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
> diff --git a/common/spl/Kconfig b/common/spl/Kconfig
> index d175bb6cffe8..6a9b4d571e21 100644
> --- a/common/spl/Kconfig
> +++ b/common/spl/Kconfig
> @@ -911,6 +911,8 @@ config TPL_BOARD_INIT
> config TPL_LDSCRIPT
> string "Linker script for the TPL stage"
> depends on TPL
> + default "arch/arm/cpu/armv8/u-boot-spl.lds" if ARM64
> + default "arch/$(ARCH)/cpu/u-boot-spl.lds"
> help
> The TPL stage will usually require a different linker-script
> (as it runs from a different memory region) than the regular
> diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl
> index ca671eb7f5cc..af41f68840b6 100644
> --- a/scripts/Makefile.spl
> +++ b/scripts/Makefile.spl
> @@ -147,6 +147,15 @@ LDPPFLAGS += \
> $(shell $(LD) --version | \
> sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')
>
> +# Turn various CONFIG symbols into IMAGE symbols for easy reuse of
> +# the scripts between SPL and TPL.
> +ifneq ($(CONFIG_$(SPL_TPL_)MAX_SIZE),)
> +LDPPFLAGS += -DIMAGE_MAX_SIZE=$(CONFIG_$(SPL_TPL_)MAX_SIZE)
> +endif
> +ifneq ($(CONFIG_$(SPL_TPL_)TEXT_BASE),)
> +LDPPFLAGS += -DIMAGE_TEXT_BASE=$(CONFIG_$(SPL_TPL_)TEXT_BASE)
> +endif
> +
> MKIMAGEOUTPUT ?= /dev/null
>
> quiet_cmd_mkimage = MKIMAGE $@
> --
> 2.7.4
>
More information about the U-Boot
mailing list