linker: Modify linker scripts to be more generic
authorTom Rini <trini@konsulko.com>
Tue, 22 Jan 2019 22:09:26 +0000 (17:09 -0500)
committerTom Rini <trini@konsulko.com>
Sun, 27 Jan 2019 03:55:53 +0000 (22:55 -0500)
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.

Cc: Stefano Babic <sbabic@denx.de>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Cc: Jagan Teki <jagan@openedev.com>
Cc: Maxime Ripard <maxime.ripard@bootlin.com>
Cc: Andreas Bießmann <andreas@biessmann.org>
Cc: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Cc: York Sun <york.sun@nxp.com>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Heiko Schocher <hs@denx.de>
Cc: Adam Ford <aford173@gmail.com>
Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Tested-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Tested-by: Adam Ford <aford173@gmail.com> #da850evm & omap3_logic_somlv
Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
22 files changed:
arch/arm/cpu/arm1136/u-boot-spl.lds
arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds
arch/arm/cpu/arm926ejs/orion5x/u-boot-spl.lds
arch/arm/cpu/arm926ejs/spear/u-boot-spl.lds
arch/arm/cpu/armv7/sunxi/u-boot-spl.lds
arch/arm/cpu/armv8/u-boot-spl.lds
arch/arm/cpu/u-boot-spl.lds
arch/arm/mach-at91/arm926ejs/u-boot-spl.lds
arch/arm/mach-at91/armv7/u-boot-spl.lds
arch/arm/mach-omap2/u-boot-spl.lds
arch/arm/mach-rockchip/Kconfig
arch/arm/mach-rockchip/rk3288/u-boot-tpl.lds [deleted file]
arch/arm/mach-rockchip/rk3368/u-boot-tpl.lds [deleted file]
arch/arm/mach-zynq/u-boot-spl.lds
arch/mips/cpu/u-boot-spl.lds
arch/powerpc/cpu/mpc85xx/u-boot-spl.lds
arch/x86/cpu/u-boot-spl.lds
board/Barix/ipam390/u-boot-spl-ipam390.lds
board/davinci/da8xxevm/u-boot-spl-da850evm.lds
board/samsung/common/exynos-uboot-spl.lds
common/spl/Kconfig
scripts/Makefile.spl

index 881275adef51b617d5c94aea9df90388aa819bd7..f83988fd7e6a1182e991ef2d76e037d8598ea053 100644 (file)
@@ -8,8 +8,8 @@
  *     Aneesh V <aneesh@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 }
 
index ffc70ce86bfd78ac971997c24e9c752020d24f59..7e20448f81080469d50e45b9a7e28268a94a1bf7 100644 (file)
@@ -15,7 +15,7 @@ OUTPUT_ARCH(arm)
 ENTRY(_start)
 SECTIONS
 {
-       . = CONFIG_SPL_TEXT_BASE;
+       . = IMAGE_TEXT_BASE;
 
        . = ALIGN(4);
        .text   :
index fbdb1d7e77a4cf7ab26f771a247c1874f7916f3b..a537fe02954bbb9a862a209d74b7d37ed9eee7d4 100644 (file)
@@ -16,8 +16,8 @@
  * Texas Instruments, <www.ti.com>
  *     Aneesh V <aneesh@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 }
 
index 569704c317e9f8964d507b77278ce1adbe118361..0964a9742e4c4b7451a744b0dc8e270e1503482d 100644 (file)
@@ -12,8 +12,8 @@
  * Gary Jennejohn, DENX Software Engineering, <garyj@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)
index 5d7f3f578beff86ada546ddac950ec2e66363561..942c29fc959dfaac8ac0105307fe55012b715756 100644 (file)
@@ -13,8 +13,8 @@
  * Texas Instruments, <www.ti.com>
  *     Aneesh V <aneesh@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 }
 
index 4e48da56be8985ff7a9d27a13c39defe0e6fe2f2..ccbf359bd11d7951d37f589787caa21a877b03f8 100644 (file)
@@ -11,8 +11,8 @@
  *     Aneesh V <aneesh@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 }
 
index 9d1333176b54ed748435c3bb808192b64339bc67..a2aa93a7357d7b6b8442c479dd848172cbb38418 100644 (file)
@@ -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
 
index b714e93b3b219cc8c885aa37268d29e03fabbb6e..f18b17dc931c39a5bdba15d0ae8a628de78ab858 100644 (file)
@@ -4,8 +4,8 @@
  *                   Bo Shen <voice.shen@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
 
index 22237cffc92f1ecaa3833cbd5c949d84022a91db..950ea55d7c4ef6120da2e8a66bf680da06140f17 100644 (file)
@@ -11,8 +11,8 @@
  *         Bo Shen <voice.shen@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 }
 
index a1289f6a74409e2ba87eaa3de9f99efdb3f2d2df..88d81f9b98d61cfdf562e077f7666800d71dadaf 100644 (file)
@@ -8,8 +8,8 @@
  *     Aneesh V <aneesh@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 }
 
index b0082416b0c68d2cdedd478764e1a34173423c92..8e9d88c3f9fa0d6ff866ffc53963ce95add8b6c1 100644 (file)
@@ -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 (file)
index 2e55989..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Copyright (C) 2018 Jagan Teki <jagan@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 (file)
index 7ba35b6..0000000
+++ /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"
index 080c6bf06d0652ff73fd7b0c5232ce7b38dc77ef..106d2e390ba8b096898e4ac95a29cea454c12ca2 100644 (file)
@@ -7,8 +7,8 @@
  * Gary Jennejohn, DENX Software Engineering, <garyj@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 }
 
index be194d314b649a0d07bb19f6201df8cc844b389e..d08d6222c4ab8d6859767104b3a1a03f9a998899 100644 (file)
@@ -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 }
 
index bd0eeb1042606b7f6540b66964c4c616e0bdca1f..27a5fe6306a397ba8da9b6eeff197874d722efef 100644 (file)
@@ -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*)
        }
index 574d992aaa98dd618be3d86bfabd3ae6f030e12d..4e656dc4e5a7b544f174b32ab7eeda3a4eb674fb 100644 (file)
@@ -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*); }
 
index cf13e0a41cd36cbe83f61ee07f5e4ab8ea752484..06ed3fa89f8157f8b34b82f494bd75cbde3150b0 100644 (file)
@@ -7,7 +7,7 @@
  * Guennadi Liakhovetki, DENX Software Engineering, <lg@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")
index f5462f88b1eb120ef17c21632622dbe9dec9abf8..7b5fab7756cb524ee545a14555cd266d83a9b499 100644 (file)
@@ -7,7 +7,7 @@
  * Guennadi Liakhovetki, DENX Software Engineering, <lg@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")
index 0d4be426b69b6b50bb2e9b8cc1400f637ec75ff9..5b32f7feb817ee8ff44d222610016f693477a123 100644 (file)
@@ -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")
index aa24b6653ff263bc0a97de45b9047369894d9f43..54b0dc34f59515bffb0a9e4584fc9dbb97e48c4f 100644 (file)
@@ -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
index 24ee927c72da84f0eb06e2e41bfb2253d1b861de..9d5921606e1d1b89aa4721553d7f857f671ab031 100644 (file)
@@ -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 $@