summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Schwierzeck <daniel.schwierzeck@gmail.com>2016-05-26 15:28:38 +0200
committerDaniel Schwierzeck <daniel.schwierzeck@gmail.com>2016-05-31 09:38:11 +0200
commit07f5b966aa2a4fe3a9bed8e90103cb0fe83c8748 (patch)
treeb1754cbc5b886e0f6d7a1b5823e841e320cced43
parent0f832b9cdcbe8a024b53c585622d70129652d20b (diff)
MIPS: provide a default u-boot-spl.lds
Provide a default linker script for SPL binaries. Start address and size of text section and BSS section are configurable. All sections are arranged in a way that only relevant sections are kept in the code section for maximum size reduction. All other sections are kept but moved outside the code section to help with debugging. Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com> Acked-by: Marek Vasut <marex@denx.de>
-rw-r--r--arch/mips/config.mk5
-rw-r--r--arch/mips/cpu/u-boot-spl.lds90
2 files changed, 93 insertions, 2 deletions
diff --git a/arch/mips/config.mk b/arch/mips/config.mk
index 609a998f3b6..dcd346002ca 100644
--- a/arch/mips/config.mk
+++ b/arch/mips/config.mk
@@ -65,7 +65,7 @@ else
PF_ABICALLS := -mabicalls
PF_PIC := -fpic
PF_PIE := -pie
-PF_OBJCOPY := -j .got -j .u_boot_list -j .rel.dyn -j .padding
+PF_OBJCOPY := -j .got -j .rel.dyn -j .padding
PF_OBJCOPY += -j .dtb.init.rodata
endif
@@ -74,4 +74,5 @@ PLATFORM_CPPFLAGS += -msoft-float
PLATFORM_LDFLAGS += -G 0 -static -n -nostdlib
PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
LDFLAGS_FINAL += --gc-sections $(PF_PIE)
-OBJCOPYFLAGS += -j .text -j .rodata -j .data $(PF_OBJCOPY)
+OBJCOPYFLAGS += -j .text -j .rodata -j .data -j .u_boot_list
+OBJCOPYFLAGS += $(PF_OBJCOPY)
diff --git a/arch/mips/cpu/u-boot-spl.lds b/arch/mips/cpu/u-boot-spl.lds
new file mode 100644
index 00000000000..07004ea1115
--- /dev/null
+++ b/arch/mips/cpu/u-boot-spl.lds
@@ -0,0 +1,90 @@
+/*
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+MEMORY { .spl_mem : ORIGIN = CONFIG_SPL_TEXT_BASE, \
+ LENGTH = CONFIG_SPL_MAX_SIZE }
+MEMORY { .bss_mem : ORIGIN = CONFIG_SPL_BSS_START_ADDR, \
+ LENGTH = CONFIG_SPL_BSS_MAX_SIZE }
+
+OUTPUT_ARCH(mips)
+ENTRY(_start)
+SECTIONS
+{
+ . = 0x00000000;
+
+ . = ALIGN(4);
+ .text : {
+ *(.text*)
+ } > .spl_mem
+
+ . = ALIGN(4);
+ .rodata : {
+ *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
+ } > .spl_mem
+
+ . = ALIGN(4);
+ .data : {
+ *(SORT_BY_ALIGNMENT(.data*))
+ *(SORT_BY_ALIGNMENT(.sdata*))
+ } > .spl_mem
+
+#ifdef CONFIG_SPL_DM
+ . = ALIGN(4);
+ .u_boot_list : {
+ KEEP(*(SORT(.u_boot_list*)));
+ } > .spl_mem
+#endif
+
+ . = ALIGN(4);
+ __image_copy_end = .;
+
+ .bss (NOLOAD) : {
+ __bss_start = .;
+ *(.bss*)
+ *(.sbss*)
+ *(COMMON)
+ . = ALIGN(4);
+ __bss_end = .;
+ } > .bss_mem
+
+ .rel.dyn (NOLOAD) : {
+ *(.rel.dyn)
+ }
+
+ .dynsym : {
+ *(.dynsym)
+ }
+
+ .dynbss : {
+ *(.dynbss)
+ }
+
+ .dynstr : {
+ *(.dynstr)
+ }
+
+ .dynamic : {
+ *(.dynamic)
+ }
+
+ .plt : {
+ *(.plt)
+ }
+
+ .interp : {
+ *(.interp)
+ }
+
+ .gnu : {
+ *(.gnu*)
+ }
+
+ .MIPS.stubs : {
+ *(.MIPS.stubs)
+ }
+
+ .hash : {
+ *(.hash)
+ }
+}