Skip to contentSkip to conversation

Tidy up ARM link scripts

PATCH Superseded Simon Glass 3 participants 18 messages Nov 21, 2011 – Feb 23, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover Tidy up ARM link scripts

The ARM link scripts are very similar but each CPU has its own. This series adds support for a default link script across an architecture in arch/<arch>/cpu/u-boot.lds.

It is then possible to remove most of the ARM link scripts. This will make it easier to maintain these.

Changes in v2:
- Add a comment explaining all the ldscript checks
- Remove ziptz2 link script also as it breaks the build
- Make this change in spl/Makefile also

Simon Glass (7):
Allow arch directory to contain .lds without requiring Makefile
arm: Remove jornada link script
arm: Remove zipitz2 link script
Define CPUDIR for the .lds link script
arm: Remove unneeded setting of LDCSRIPT
arm: add a common .lds link script
arm: Use common .lds file where possible

 Makefile                            |   11 ++++-
 arch/arm/config.mk                  |    7 ---
 arch/arm/cpu/arm1136/u-boot.lds     |   89 -----------------------------------
 arch/arm/cpu/arm1176/u-boot.lds     |   78 ------------------------------
 arch/arm/cpu/arm720t/u-boot.lds     |   79 -------------------------------
 arch/arm/cpu/arm920t/u-boot.lds     |   88 ----------------------------------
 arch/arm/cpu/arm925t/u-boot.lds     |   83 --------------------------------
 arch/arm/cpu/arm926ejs/u-boot.lds   |   80 -------------------------------
 arch/arm/cpu/arm946es/u-boot.lds    |   80 -------------------------------
 arch/arm/cpu/arm_intcm/u-boot.lds   |   80 -------------------------------
 arch/arm/cpu/lh7a40x/u-boot.lds     |   80 -------------------------------
 arch/arm/cpu/pxa/u-boot.lds         |   80 -------------------------------
 arch/arm/cpu/s3c44b0/u-boot.lds     |   80 -------------------------------
 arch/arm/cpu/sa1100/u-boot.lds      |   83 --------------------------------
 arch/arm/cpu/{armv7 => }/u-boot.lds |    6 +-
 board/jornada/u-boot.lds            |   58 -----------------------
 board/zipitz2/u-boot.lds            |   56 ----------------------
 spl/Makefile                        |    4 ++
 18 files changed, 17 insertions(+), 1105 deletions(-)
 delete mode 100644 arch/arm/cpu/arm1136/u-boot.lds
 delete mode 100644 arch/arm/cpu/arm1176/u-boot.lds
 delete mode 100644 arch/arm/cpu/arm720t/u-boot.lds
 delete mode 100644 arch/arm/cpu/arm920t/u-boot.lds
 delete mode 100644 arch/arm/cpu/arm925t/u-boot.lds
 delete mode 100644 arch/arm/cpu/arm926ejs/u-boot.lds
 delete mode 100644 arch/arm/cpu/arm946es/u-boot.lds
 delete mode 100644 arch/arm/cpu/arm_intcm/u-boot.lds
 delete mode 100644 arch/arm/cpu/lh7a40x/u-boot.lds
 delete mode 100644 arch/arm/cpu/pxa/u-boot.lds
 delete mode 100644 arch/arm/cpu/s3c44b0/u-boot.lds
 delete mode 100644 arch/arm/cpu/sa1100/u-boot.lds
 rename arch/arm/cpu/{armv7 => }/u-boot.lds (94%)
 delete mode 100644 board/jornada/u-boot.lds
 delete mode 100644 board/zipitz2/u-boot.lds
Signature · 1 line
1.7.3.1
#1 lore raw

PATCH v2 1/7 Allow arch directory to contain .lds without requiring Makefile

The Makefile for a CPU is in arch/($ARCH)/cpu/$(CPU). We want to support having an .lds file in arch/$(ARCH)/cpu without requiring an additional Makefile there. This change makes it clear that we expect a Makefile in the same directory as the link script except in this case.

---
Changes in v2:
- Add a comment explaining all the ldscript checks

 Makefile     |   10 +++++++++-
 spl/Makefile |    3 +++
 2 files changed, 12 insertions(+), 1 deletions(-)
Makefile +9 -1
index fb658f4..423adef 100644
@@ -174,6 +174,8 @@ include $(TOPDIR)/config.mk
 # that (or fail if absent).  Otherwise, search for a linker script in a
 # standard location.
 
+LDSCRIPT_MAKEFILE_DIR = $(dir $(LDSCRIPT))
+
 ifndef LDSCRIPT
 	#LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds.debug
 	ifdef CONFIG_SYS_LDSCRIPT
@@ -182,6 +184,7 @@ ifndef LDSCRIPT
 	endif
 endif
 
+# If there is no specified link script, we look in a number of places for it
 ifndef LDSCRIPT
 	ifeq ($(CONFIG_NAND_U_BOOT),y)
 		LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-nand.lds
@@ -196,6 +199,11 @@ ifndef LDSCRIPT
 		LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot.lds
 	endif
 	ifeq ($(wildcard $(LDSCRIPT)),)
+		LDSCRIPT := $(TOPDIR)/arch/$(ARCH)/cpu/u-boot.lds
+		# We don't expect a Makefile here
+		LDSCRIPT_MAKEFILE_DIR =
+	endif
+	ifeq ($(wildcard $(LDSCRIPT)),)
 $(error could not find linker script)
 	endif
 endif
@@ -495,7 +503,7 @@ depend dep:	$(TIMESTAMP_FILE) $(VERSION_FILE) \
 		$(obj)include/autoconf.mk \
 		$(obj)include/generated/generic-asm-offsets.h \
 		$(obj)include/generated/asm-offsets.h
-		for dir in $(SUBDIRS) $(CPUDIR) $(dir $(LDSCRIPT)) ; do \
+		for dir in $(SUBDIRS) $(CPUDIR) $(LDSCRIPT_MAKEFILE_DIR) ; do \
 			$(MAKE) -C $$dir _depend ; done
 
 TAG_SUBDIRS = $(SUBDIRS)
spl/Makefile +3 -0
index 6ac42a2..82484d4 100644
@@ -87,6 +87,9 @@ ifeq ($(wildcard $(LDSCRIPT)),)
 	LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot-spl.lds
 endif
 ifeq ($(wildcard $(LDSCRIPT)),)
+	LDSCRIPT := $(TOPDIR)/arch/$(ARCH)/cpu/u-boot.lds
+endif
+ifeq ($(wildcard $(LDSCRIPT)),)
 $(error could not find linker script)
 endif
 
Signature · 1 line
1.7.3.1
#2 lore raw

PATCH v2 2/7 arm: Remove jornada link script

In reply to Simon Glass

This link script seems old and incompatible with relocation and its own sa1000 start.S file. It isn't used because the CPU's link script was picked up in preference to this.

---

 board/jornada/u-boot.lds |   58 ----------------------------------------------
 1 files changed, 0 insertions(+), 58 deletions(-)
 delete mode 100644 board/jornada/u-boot.lds
board/jornada/u-boot.lds deleted +0 -58
deleted file mode 100644
index c75b21f..0000000
@@ -1,58 +0,0 @@
-/*
- * (C) Copyright 2000-2004
- * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
- * 2004 (c) MontaVista Software, Inc.
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
-OUTPUT_ARCH(arm)
-ENTRY(_start)
-SECTIONS
-{
-	. = 0x00000000;
-
-	. = ALIGN(4);
-	.text :
-	{
-		cpu/sa1100/start.o	(.text)
-		*(.text)
-	}
-
-	. = ALIGN(4);
-	.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
-
-	. = ALIGN(4);
-	.data : { *(.data) }
-
-	. = ALIGN(4);
-	.got : { *(.got) }
-
-
-	. = .;
-	__u_boot_cmd_start = .;
-	.u_boot_cmd : { *(.u_boot_cmd) }
-	__u_boot_cmd_end = .;
-
-	. = ALIGN(4);
-	__bss_start = .;
-	.bss (NOLOAD) : { *(.bss) . = ALIGN(4); }
-	__bss_end__ = .;
-}
Signature · 1 line
1.7.3.1
#3 lore raw

PATCH v2 3/7 arm: Remove zipitz2 link script

In reply to Simon Glass

This link script doesn't appear to do anything useful or unique, so drop it, and rely on the CPU one.

---
Changes in v2:
- Remove ziptz2 link script also as it breaks the build

 board/zipitz2/u-boot.lds |   56 ----------------------------------------------
 1 files changed, 0 insertions(+), 56 deletions(-)
 delete mode 100644 board/zipitz2/u-boot.lds
board/zipitz2/u-boot.lds deleted +0 -56
deleted file mode 100644
index e1a1ff1..0000000
@@ -1,56 +0,0 @@
-/*
- * (C) Copyright 2000-2005
- * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
-OUTPUT_ARCH(arm)
-ENTRY(_start)
-SECTIONS
-{
-	. = 0x00000000;
-
-	. = ALIGN(4);
-	.text      :
-	{
-	  cpu/pxa/start.o	(.text)
-	  *(.text)
-	}
-
-	. = ALIGN(4);
-	.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
-
-	. = ALIGN(4);
-	.data : { *(.data) }
-
-	. = ALIGN(4);
-	.got : { *(.got) }
-
-	. = .;
-	__u_boot_cmd_start = .;
-	.u_boot_cmd : { *(.u_boot_cmd) }
-	__u_boot_cmd_end = .;
-
-	. = ALIGN(4);
-	__bss_start = .;
-	.bss (NOLOAD) : { *(.bss) . = ALIGN(4); }
-	__bss_end__ = .;
-}
Signature · 1 line
1.7.3.1
#4 lore raw

PATCH v2 4/7 Define CPUDIR for the .lds link script

In reply to Simon Glass

Most link scripts differ only in the directory containing the start.o file. Make this a #define to remove this last difference.

(Note that if start.o were disallowed outside the CPU start directory then we wouldn't even need this. But that is a separate discussion.)

---
Changes in v2:
- Make this change in spl/Makefile also

 Makefile     |    1 +
 spl/Makefile |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)
Makefile +1 -0
index 423adef..3cb00ed 100644
@@ -332,6 +332,7 @@ export PLATFORM_LIBS
 # on the fly.
 LDPPFLAGS += \
 	-include $(TOPDIR)/include/u-boot/u-boot.lds.h \
+	-DCPUDIR=$(CPUDIR) \
 	$(shell $(LD) --version | \
 	  sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')
 
spl/Makefile +1 -0
index 82484d4..232822b 100644
@@ -99,6 +99,7 @@ endif
 LDPPFLAGS += \
 	-include $(TOPDIR)/include/u-boot/u-boot.lds.h \
 	-include $(OBJTREE)/include/config.h \
+	-DCPUDIR=$(CPUDIR) \
 	$(shell $(LD) --version | \
 	  sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')
 
Signature · 1 line
1.7.3.1
#5 lore raw

PATCH v2 5/7 arm: Remove unneeded setting of LDCSRIPT

In reply to Simon Glass

This is set by the top level Makefile anyway, so drop it. This does have the effect of changing the order - now the board link script will have preference over the CPU one. But this seems more correct anyway.

---

 arch/arm/config.mk |    7 -------
 1 files changed, 0 insertions(+), 7 deletions(-)
arch/arm/config.mk +0 -7
index 45f9dca..3c5f987 100644
@@ -70,13 +70,6 @@ PLATFORM_LIBS := $(OBJTREE)/arch/arm/lib/eabi_compat.o \
 endif
 endif
 
-ifdef CONFIG_SYS_LDSCRIPT
-# need to strip off double quotes
-LDSCRIPT := $(subst ",,$(CONFIG_SYS_LDSCRIPT))
-else
-LDSCRIPT := $(SRCTREE)/$(CPUDIR)/u-boot.lds
-endif
-
 # needed for relocation
 ifndef CONFIG_NAND_SPL
 LDFLAGS_u-boot += -pie
Signature · 1 line
1.7.3.1
#6 lore raw

PATCH v2 6/7 arm: add a common .lds link script

In reply to Simon Glass

Most ARM CPUs use a very similar link script. This adds a basic script that can be used by most CPUs.

---

 arch/arm/cpu/u-boot.lds |   85 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 85 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/cpu/u-boot.lds
arch/arm/cpu/u-boot.lds new file +85 -0
new file mode 100644
index 0000000..2d08006
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2004-2008 Texas Instruments
+ *
+ * (C) Copyright 2002
+ * Gary Jennejohn, DENX Software Engineering, <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+ENTRY(_start)
+SECTIONS
+{
+	. = 0x00000000;
+
+	. = ALIGN(4);
+	.text :
+	{
+		__text_start = .;
+		CPUDIR/start.o (.text)
+		*(.text)
+	}
+
+	. = ALIGN(4);
+	.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
+
+	. = ALIGN(4);
+	.data : {
+		*(.data)
+	}
+
+	. = ALIGN(4);
+
+	. = .;
+	__u_boot_cmd_start = .;
+	.u_boot_cmd : { *(.u_boot_cmd) }
+	__u_boot_cmd_end = .;
+
+	. = ALIGN(4);
+
+	__image_copy_end = .;
+
+	.rel.dyn : {
+		__rel_dyn_start = .;
+		*(.rel*)
+		__rel_dyn_end = .;
+	}
+
+	.dynsym : {
+		__dynsym_start = .;
+		*(.dynsym)
+	}
+
+	_end = .;
+
+	.bss __rel_dyn_start (OVERLAY) : {
+		__bss_start = .;
+		*(.bss)
+		 . = ALIGN(4);
+		__bss_end__ = .;
+	}
+
+	/DISCARD/ : { *(.dynstr*) }
+	/DISCARD/ : { *(.dynamic*) }
+	/DISCARD/ : { *(.plt*) }
+	/DISCARD/ : { *(.interp*) }
+	/DISCARD/ : { *(.gnu*) }
+}
Signature · 1 line
1.7.3.1
#7 lore raw

PATCH v2 6/7 arm: add a common .lds link script

Hi Simon,

Le 21/11/2011 21:49, Simon Glass a ?crit :

arch/arm/cpu/u-boot.lds line 36

Quoted 3 lines
arch/arm/cpu/u-boot.lds new file +3 -0
+	.text :
+	{
+		__text_start = .;

This assignment to __text_start does not exist in any of the existing u-boot.lds files. What is the point of it?

arch/arm/cpu/u-boot.lds line 58

Quoted 6 lines
arch/arm/cpu/u-boot.lds new file +6 -0
+	.u_boot_cmd : { *(.u_boot_cmd) }
+	__u_boot_cmd_end = .;
+
+	. = ALIGN(4);
+
+	__image_copy_end = .;

Ditto for __image_copy_end.

These two changes are unexplained in the commit message. Mind you, the one about CPUDIR and start.S isn't either... and it should, because once the commit is in, there is no indication left that it is part of a set, so readers will have a difficulty spotting the changes introduced.

But what bothers me most is that the patch set produces u-boot.bin files which are not binary identical to those produced without the patch set; if I remove the two assignments, then binary identity is preserved.

Note: I check for binary identity by diff'ing hex dumps of u-boot.bin files produced with and without the patch set. If the only difference is the build version and date, I deem the files binary identical. The dump is done with 'od -t x1z -A x u-boot.bin'.

So unless there is a compelling and strictly unavoidable reason for these assignements, please drop them in the V3 patch set.

Amicalement,

Signature · 1 line
Albert.
#8 lore raw

PATCH v2 6/7 arm: add a common .lds link script

Hi Albert,

Quoted 5 lines · Albert ARIBAUD

Hi Simon,

Le 21/11/2011 21:49, Simon Glass a ?crit :

Quoted 7 lines
Quoted 3 lines

+ ? ? ? .text :
+ ? ? ? {
+ ? ? ? ? ? ? ? __text_start = .;

This assignment to __text_start does not exist in any of the existing u-boot.lds files. What is the point of it?

I would like to have a single symbol for the start of the text region across all architectures. ARM has _start but this is not present elsewhere. Also I think it should be defined by the link script.

Quoted 11 lines

arch/arm/cpu/u-boot.lds

Quoted 8 lines

+ ? ? ? .u_boot_cmd : { *(.u_boot_cmd) }
+ ? ? ? __u_boot_cmd_end = .;

arch/arm/cpu/u-boot.lds new file +4 -0
+
+ ? ? ? . = ALIGN(4);
+
+ ? ? ? __image_copy_end = .;

Ditto for __image_copy_end.

This is the end of the region that needs to be copied when U-Boot is relocated. The symbol exists in ARMv7 so I have reproduced it here. If I read the SPL code correctly then it seems to need this.

Quoted 5 lines

These two changes are unexplained in the commit message. Mind you, the one about CPUDIR and start.S isn't either... and it should, because once the commit is in, there is no indication left that it is part of a set, so readers will have a difficulty spotting the changes introduced.

OK I will take a look at these problems.

Quoted 5 lines

But what bothers me most is that the patch set produces u-boot.bin files which are not binary identical to those produced without the patch set; if I remove the two assignments, then binary identity is preserved.

Quoted 7 lines

Note: I check for binary identity by diff'ing hex dumps of u-boot.bin files produced with and without the patch set. If the only difference is the build version and date, I deem the files binary identical. The dump is done with 'od -t x1z -A x u-boot.bin'.

So unless there is a compelling and strictly unavoidable reason for these assignements, please drop them in the V3 patch set.

The binary will need to include values for these symbols in the dynsym area, so adding a link symbol cannot produce an identical binary. But the change should be harmless - it is just an extra symbol.

I do not want to drop these - in fact I want to standardize on these (or something similar that we agree) across all architectures since it makes the generic relocation code easier (at present it uses #ifdef to work out what to do in the two different cases (SPL and non-SPL). Ultimately we can look towards more uniformity across architectures in the .lds files.

I will take another look at this series.

Quoted 4 lines

Amicalement,
--
Albert.

Regards,
Simon

#9 lore raw

PATCH v2 6/7 arm: add a common .lds link script

Hi Simon,

Le 21/02/2012 03:32, Simon Glass a ?crit :

Quoted 14 lines

Hi Albert,

Quoted 10 lines · Albert ARIBAUD

Hi Simon,

Le 21/11/2011 21:49, Simon Glass a ?crit :

Quoted 3 lines
arch/arm/cpu/u-boot.lds new file +3 -0
+       .text :
+       {
+               __text_start = .;
Quoted 6 lines
Quoted 2 lines

This assignment to __text_start does not exist in any of the existing u-boot.lds files. What is the point of it?

I would like to have a single symbol for the start of the text region across all architectures. ARM has _start but this is not present elsewhere. Also I think it should be defined by the link script.

I suspect what you would like to have is a single symbol for the start of the region to copy, rather than the start of the test region per se.

Quoted 34 lines
Quoted 11 lines

arch/arm/cpu/u-boot.lds line 58

Quoted 8 lines
arch/arm/cpu/u-boot.lds new file +6 -0
+       .u_boot_cmd : { *(.u_boot_cmd) }
+       __u_boot_cmd_end = .;
+
+       . = ALIGN(4);
+
+       __image_copy_end = .;

Ditto for __image_copy_end.

This is the end of the region that needs to be copied when U-Boot is relocated. The symbol exists in ARMv7 so I have reproduced it here. If I read the SPL code correctly then it seems to need this.

Quoted 5 lines

These two changes are unexplained in the commit message. Mind you, the one about CPUDIR and start.S isn't either... and it should, because once the commit is in, there is no indication left that it is part of a set, so readers will have a difficulty spotting the changes introduced.

OK I will take a look at these problems.

Quoted 10 lines

But what bothers me most is that the patch set produces u-boot.bin files which are not binary identical to those produced without the patch set; if I remove the two assignments, then binary identity is preserved.

Note: I check for binary identity by diff'ing hex dumps of u-boot.bin files produced with and without the patch set. If the only difference is the build version and date, I deem the files binary identical. The dump is done with 'od -t x1z -A x u-boot.bin'.

Quoted 6 lines
Quoted 2 lines

So unless there is a compelling and strictly unavoidable reason for these assignements, please drop them in the V3 patch set.

The binary will need to include values for these symbols in the dynsym area, so adding a link symbol cannot produce an identical binary. But the change should be harmless - it is just an extra symbol.

If that is only an extra symbol (hence unreferred to so far) then it should not have any impact on relocation data, which apply only to existing references -- just like adding an "extern" definition for int abc;" won't have any effect unless/until some reference to abc exists -- and it should certainly not affect text and data.

However, if I compare builds of edminiv2 with and without patch 7/7 (that's the patch which makes edminiv2 use the common u-boot.lds), then I see changes as early as the 69th byte of the text section.

I suspect the issue is cause by the additional ALIGN() directive that you are adding along with the symbols. Considering that this change should only replace existing symbols (_start and _bss_start) with other, functionally identical symbols, there is no reason to alter alignments in the linker file.

Quoted 6 lines

I do not want to drop these - in fact I want to standardize on these (or something similar that we agree) across all architectures since it makes the generic relocation code easier (at present it uses #ifdef to work out what to do in the two different cases (SPL and non-SPL). Ultimately we can look towards more uniformity across architectures in the .lds files.

I do understand what you want to achieve here -- replace the existing arch-specific symbols that mark the start and end of the area to copy and relocate with arch-agnostic ones. But then, that change in itself is akin to a rename or alias and should have zero effect on the resulting binary.

Quoted 1 line

I will take another look at this series.

I see there were V3 issued for 6/7 and 7/7. I'll comment these.

Quoted 2 lines

Regards,
Simon

Amicalement,

Signature · 1 line
Albert.
#10 lore raw

PATCH v4 6/7 arm: add a common .lds link script

In reply to Simon Glass

Most ARM CPUs use a very similar link script. This adds a basic script that can be used by most CPUs.

Two new symbols are introduced which are intended to eventually be defined on all architectures to make things easier for generic relocation and reduce special-case code for each architecture:

__image_copy_start is the start of the text area (equivalent to the existing _start on ARM). It marks the start of the region which must be copied to a new location during relocation. This symbol is called __text_start on x86 and microblaze.

__image_copy_end is the end of the region which must be copied to a new location during relocation. It is normally equal to the start of the BSS region, but this can vary in some cases (SPL?). Making this an explicit symbol on its own removes any ambiguity and permits common code to always do the right thing.

This new script makes use of CPUDIR, now defined by both Makefile and spl/Makefile, to find the directory containing the start.o object file, which is always placed first in the image.

To permit MMU setup prior to relocation (as used by pxa) we add an area to the link script which contains space for this. This is taken from commit 7f4cfcf. CPUs can put the contents in there using their start.S file. BTW, shouldn't that area be 16KB-aligned?

---
Changes in v3:
- Add more comments in the commit message
- Add section for MMU area, as required by pxa

Changes in v4:
- Add deprecation note to pxa's MMU area
- Rename __text_start to __image_copy_start

 arch/arm/cpu/u-boot.lds |   94 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 94 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/cpu/u-boot.lds
arch/arm/cpu/u-boot.lds new file +94 -0
new file mode 100644
index 0000000..e49ca0c
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2004-2008 Texas Instruments
+ *
+ * (C) Copyright 2002
+ * Gary Jennejohn, DENX Software Engineering, <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+ENTRY(_start)
+SECTIONS
+{
+	. = 0x00000000;
+
+	. = ALIGN(4);
+	.text :
+	{
+		__image_copy_start = .;
+		CPUDIR/start.o (.text)
+		*(.text)
+	}
+
+	. = ALIGN(4);
+	.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
+
+	. = ALIGN(4);
+	.data : {
+		*(.data)
+	}
+
+	. = ALIGN(4);
+
+	. = .;
+	__u_boot_cmd_start = .;
+	.u_boot_cmd : { *(.u_boot_cmd) }
+	__u_boot_cmd_end = .;
+
+	. = ALIGN(4);
+
+	__image_copy_end = .;
+
+	.rel.dyn : {
+		__rel_dyn_start = .;
+		*(.rel*)
+		__rel_dyn_end = .;
+	}
+
+	.dynsym : {
+		__dynsym_start = .;
+		*(.dynsym)
+	}
+
+	_end = .;
+
+	/*
+	 * Deprecated: this MMU section is used by pxa at present but
+	 * should not be used by new boards/CPUs.
+	 */
+	. = ALIGN(4096);
+	.mmutable : {
+		*(.mmutable)
+	}
+
+	.bss __rel_dyn_start (OVERLAY) : {
+		__bss_start = .;
+		*(.bss)
+		 . = ALIGN(4);
+		__bss_end__ = .;
+	}
+
+	/DISCARD/ : { *(.dynstr*) }
+	/DISCARD/ : { *(.dynamic*) }
+	/DISCARD/ : { *(.plt*) }
+	/DISCARD/ : { *(.interp*) }
+	/DISCARD/ : { *(.gnu*) }
+}
Signature · 1 line
1.7.7.3
#11 lore raw

PATCH v2 7/7 arm: Use common .lds file where possible

In reply to Simon Glass

Each cpu directory currently has its own .lds file. This is only needed in most cases because the start.o file is in a different subdir.

Now that we can factor out this difference, we can move most cpus over to the common .lds file.

---

 arch/arm/cpu/arm1136/u-boot.lds   |   89 -------------------------------------
 arch/arm/cpu/arm1176/u-boot.lds   |   78 --------------------------------
 arch/arm/cpu/arm720t/u-boot.lds   |   79 --------------------------------
 arch/arm/cpu/arm920t/u-boot.lds   |   88 ------------------------------------
 arch/arm/cpu/arm925t/u-boot.lds   |   83 ----------------------------------
 arch/arm/cpu/arm926ejs/u-boot.lds |   80 ---------------------------------
 arch/arm/cpu/arm946es/u-boot.lds  |   80 ---------------------------------
 arch/arm/cpu/arm_intcm/u-boot.lds |   80 ---------------------------------
 arch/arm/cpu/armv7/u-boot.lds     |   85 -----------------------------------
 arch/arm/cpu/lh7a40x/u-boot.lds   |   80 ---------------------------------
 arch/arm/cpu/pxa/u-boot.lds       |   80 ---------------------------------
 arch/arm/cpu/s3c44b0/u-boot.lds   |   80 ---------------------------------
 arch/arm/cpu/sa1100/u-boot.lds    |   83 ----------------------------------
 13 files changed, 0 insertions(+), 1065 deletions(-)
 delete mode 100644 arch/arm/cpu/arm1136/u-boot.lds
 delete mode 100644 arch/arm/cpu/arm1176/u-boot.lds
 delete mode 100644 arch/arm/cpu/arm720t/u-boot.lds
 delete mode 100644 arch/arm/cpu/arm920t/u-boot.lds
 delete mode 100644 arch/arm/cpu/arm925t/u-boot.lds
 delete mode 100644 arch/arm/cpu/arm926ejs/u-boot.lds
 delete mode 100644 arch/arm/cpu/arm946es/u-boot.lds
 delete mode 100644 arch/arm/cpu/arm_intcm/u-boot.lds
 delete mode 100644 arch/arm/cpu/armv7/u-boot.lds
 delete mode 100644 arch/arm/cpu/lh7a40x/u-boot.lds
 delete mode 100644 arch/arm/cpu/pxa/u-boot.lds
 delete mode 100644 arch/arm/cpu/s3c44b0/u-boot.lds
 delete mode 100644 arch/arm/cpu/sa1100/u-boot.lds
arch/arm/cpu/arm1136/u-boot.lds deleted +0 -89
deleted file mode 100644
index d1e2851..0000000
@@ -1,89 +0,0 @@
-/*
- * (C) Copyright 2009
- * Ilya Yanok, Emcraft Systems Ltd, <[email protected]>
- *
- * Copyright (C) 2005-2007 Samsung Electronics
- * Kyungin Park <[email protected]>
- *
- * Copyright (c) 2004 Texas Instruments
- *
- * (C) Copyright 2002
- * Gary Jennejohn, DENX Software Engineering, <[email protected]>
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
-OUTPUT_ARCH(arm)
-ENTRY(_start)
-SECTIONS
-{
-	. = 0x00000000;
-
-	. = ALIGN(4);
-	.text :
-	{
-		arch/arm/cpu/arm1136/start.o	(.text)
-		*(.text)
-	}
-
-	. = ALIGN(4);
-	.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
-
-	. = ALIGN(4);
-	.data : {
-		*(.data)
-	}
-
-	. = ALIGN(4);
-
-	. = .;
-	__u_boot_cmd_start = .;
-	.u_boot_cmd : { *(.u_boot_cmd) }
-	__u_boot_cmd_end = .;
-
-	. = ALIGN(4);
-
-	.rel.dyn : {
-		__rel_dyn_start = .;
-		*(.rel*)
-		__rel_dyn_end = .;
-	}
-
-	.dynsym : {
-		__dynsym_start = .;
-		*(.dynsym)
-	}
-
-	_end = .;
-
-	.bss __rel_dyn_start (OVERLAY) : {
-		__bss_start = .;
-		*(.bss)
-		 . = ALIGN(4);
-		__bss_end__ = .;
-	}
-
-	/DISCARD/ : { *(.dynstr*) }
-	/DISCARD/ : { *(.dynamic*) }
-	/DISCARD/ : { *(.plt*) }
-	/DISCARD/ : { *(.interp*) }
-	/DISCARD/ : { *(.gnu*) }
-}
arch/arm/cpu/arm1176/u-boot.lds deleted +0 -78

78 lines not on this page · raw message

arch/arm/cpu/arm720t/u-boot.lds deleted +0 -79

79 lines not on this page · raw message

arch/arm/cpu/arm920t/u-boot.lds deleted +0 -88

88 lines not on this page · raw message

arch/arm/cpu/arm925t/u-boot.lds deleted +0 -83

83 lines not on this page · raw message

arch/arm/cpu/arm926ejs/u-boot.lds deleted +0 -80

80 lines not on this page · raw message

arch/arm/cpu/arm946es/u-boot.lds deleted +0 -80

80 lines not on this page · raw message

arch/arm/cpu/arm_intcm/u-boot.lds deleted +0 -80

80 lines not on this page · raw message

arch/arm/cpu/armv7/u-boot.lds deleted +0 -85

85 lines not on this page · raw message

arch/arm/cpu/lh7a40x/u-boot.lds deleted +0 -80

80 lines not on this page · raw message

arch/arm/cpu/pxa/u-boot.lds deleted +0 -80

80 lines not on this page · raw message

arch/arm/cpu/s3c44b0/u-boot.lds deleted +0 -80

80 lines not on this page · raw message

arch/arm/cpu/sa1100/u-boot.lds deleted +0 -83

83 lines not on this page · raw message

Signature · 1 line
1.7.3.1
#12 lore raw

v2 cover Tidy up ARM link scripts

In reply to Simon Glass

Hi,

Quoted 11 lines · Simon Glass

The ARM link scripts are very similar but each CPU has its own. This series adds support for a default link script across an architecture in arch/<arch>/cpu/u-boot.lds.

It is then possible to remove most of the ARM link scripts. This will make it easier to maintain these.

Changes in v2:
- Add a comment explaining all the ldscript checks
- Remove ziptz2 link script also as it breaks the build
- Make this change in spl/Makefile also

Any comments on this clean-up series from anyone?

Regards,
Simon

Quoted 48 lines

Simon Glass (7):
?Allow arch directory to contain .lds without requiring Makefile ?arm: Remove jornada link script
?arm: Remove zipitz2 link script
?Define CPUDIR for the .lds link script
?arm: Remove unneeded setting of LDCSRIPT
?arm: add a common .lds link script
?arm: Use common .lds file where possible

?Makefile ? ? ? ? ? ? ? ? ? ? ? ? ? ?| ? 11 ++++-
?arch/arm/config.mk ? ? ? ? ? ? ? ? ?| ? ?7 ---
?arch/arm/cpu/arm1136/u-boot.lds ? ? | ? 89 -----------------------------------
?arch/arm/cpu/arm1176/u-boot.lds ? ? | ? 78 ------------------------------
?arch/arm/cpu/arm720t/u-boot.lds ? ? | ? 79 -------------------------------
?arch/arm/cpu/arm920t/u-boot.lds ? ? | ? 88 ----------------------------------
?arch/arm/cpu/arm925t/u-boot.lds ? ? | ? 83 --------------------------------
?arch/arm/cpu/arm926ejs/u-boot.lds ? | ? 80 -------------------------------
?arch/arm/cpu/arm946es/u-boot.lds ? ?| ? 80 -------------------------------
?arch/arm/cpu/arm_intcm/u-boot.lds ? | ? 80 -------------------------------
?arch/arm/cpu/lh7a40x/u-boot.lds ? ? | ? 80 -------------------------------
?arch/arm/cpu/pxa/u-boot.lds ? ? ? ? | ? 80 -------------------------------
?arch/arm/cpu/s3c44b0/u-boot.lds ? ? | ? 80 -------------------------------
?arch/arm/cpu/sa1100/u-boot.lds ? ? ?| ? 83 --------------------------------
?arch/arm/cpu/{armv7 => }/u-boot.lds | ? ?6 +-
?board/jornada/u-boot.lds ? ? ? ? ? ?| ? 58 -----------------------
?board/zipitz2/u-boot.lds ? ? ? ? ? ?| ? 56 ----------------------
?spl/Makefile ? ? ? ? ? ? ? ? ? ? ? ?| ? ?4 ++

?18 files changed, 17 insertions(+), 1105 deletions(-) ?delete mode 100644 arch/arm/cpu/arm1136/u-boot.lds ?delete mode 100644 arch/arm/cpu/arm1176/u-boot.lds ?delete mode 100644 arch/arm/cpu/arm720t/u-boot.lds ?delete mode 100644 arch/arm/cpu/arm920t/u-boot.lds ?delete mode 100644 arch/arm/cpu/arm925t/u-boot.lds ?delete mode 100644 arch/arm/cpu/arm926ejs/u-boot.lds ?delete mode 100644 arch/arm/cpu/arm946es/u-boot.lds ?delete mode 100644 arch/arm/cpu/arm_intcm/u-boot.lds ?delete mode 100644 arch/arm/cpu/lh7a40x/u-boot.lds ?delete mode 100644 arch/arm/cpu/pxa/u-boot.lds ?delete mode 100644 arch/arm/cpu/s3c44b0/u-boot.lds ?delete mode 100644 arch/arm/cpu/sa1100/u-boot.lds ?rename arch/arm/cpu/{armv7 => }/u-boot.lds (94%) ?delete mode 100644 board/jornada/u-boot.lds ?delete mode 100644 board/zipitz2/u-boot.lds

--
1.7.3.1

#13 lore raw

v2 cover Tidy up ARM link scripts

In reply to Simon Glass

Hi Simon,

Le 21/11/2011 21:49, Simon Glass a ?crit :

Quoted 3 lines

The ARM link scripts are very similar but each CPU has its own. This series adds support for a default link script across an architecture in arch/<arch>/cpu/u-boot.lds.

This patch series received no comments, and I apologize for not having chimed in on it as it goes the right way about simplifying ARM architecture.

Currently, all patches in the series do apply except patch 7, which fails on arch/arm/cpu/pxa/u-boot.lds. As this is trivial, I'm going on removing the file manually and testing, but can you please resubmit V3 with a fixed 1/7 patch?

Amicalement,

Signature · 1 line
Albert.
#14 lore raw

v2 cover Tidy up ARM link scripts

Quoted 7 lines

Hi Simon,

Le 21/11/2011 21:49, Simon Glass a ?crit :

Quoted 3 lines

The ARM link scripts are very similar but each CPU has its own. This series adds support for a default link script across an architecture in arch/<arch>/cpu/u-boot.lds.

Quoted 8 lines

This patch series received no comments, and I apologize for not having chimed in on it as it goes the right way about simplifying ARM architecture.

Currently, all patches in the series do apply except patch 7, which fails on arch/arm/cpu/pxa/u-boot.lds. As this is trivial, I'm going on removing the file manually and testing, but can you please resubmit V3 with a fixed 1/7 patch?

Please make sure there were no changes to the linker file. I believe there were some and it might break pxa.

Thanks!

Quoted 2 lines

Amicalement,

#15 lore raw

v2 cover Tidy up ARM link scripts

Hi Marek,

Le 17/02/2012 10:49, Marek Vasut a ?crit :

Quoted 16 lines
Quoted 7 lines

Hi Simon,

Le 21/11/2011 21:49, Simon Glass a ?crit :

Quoted 3 lines

The ARM link scripts are very similar but each CPU has its own. This series adds support for a default link script across an architecture in arch/<arch>/cpu/u-boot.lds.

Quoted 8 lines

This patch series received no comments, and I apologize for not having chimed in on it as it goes the right way about simplifying ARM architecture.

Currently, all patches in the series do apply except patch 7, which fails on arch/arm/cpu/pxa/u-boot.lds. As this is trivial, I'm going on removing the file manually and testing, but can you please resubmit V3 with a fixed 1/7 patch?

Quoted 4 lines

Please make sure there were no changes to the linker file. I believe there were some and it might break pxa.

Thanks!

Thanks for pointing this out. I am not testing pxa boards now, so Simon has time to submit a vV3 patch set before I get bitten by any change in PXA boards.

Amicalement,

Signature · 1 line
Albert.
#16 lore raw

v2 cover Tidy up ARM link scripts

Hi Albert,

Quoted 27 lines · Albert ARIBAUD

Hi Marek,

Le 17/02/2012 10:49, Marek Vasut a ?crit :

Quoted 23 lines
Quoted 9 lines

Hi Simon,

Le 21/11/2011 21:49, Simon Glass a ?crit :

Quoted 4 lines

The ARM link scripts are very similar but each CPU has its own. This series adds support for a default link script across an architecture in arch/<arch>/cpu/u-boot.lds.

Quoted 8 lines

This patch series received no comments, and I apologize for not having chimed in on it as it goes the right way about simplifying ARM architecture.

Currently, all patches in the series do apply except patch 7, which fails on arch/arm/cpu/pxa/u-boot.lds. As this is trivial, I'm going on removing the file manually and testing, but can you please resubmit V3 with a fixed 1/7 patch?

Please make sure there were no changes to the linker file. I believe there were
some and it might break pxa.

Quoted 6 lines
Quoted 1 line

Thanks!

Thanks for pointing this out. I am not testing pxa boards now, so Simon has time to submit a vV3 patch set before I get bitten by any change in PXA boards.

Yes there was a change to add a 4KB MMU memory area to the link script, presumably to allow early MMU enable and using that cache space as SRAM.

I think I will add this feature to the generic .lds file since it does no harm, and it's a feature I would like to implement one day (early MMU enable). It might help ARM11 also.

Quoted 4 lines

Amicalement,
--
Albert.

Regards,
Simon

#17 lore raw

v2 cover Tidy up ARM link scripts

Quoted 30 lines

Hi Albert,

On Fri, Feb 17, 2012 at 2:47 AM, Albert ARIBAUD

Quoted 25 lines · <[email protected]> wrote:

Hi Marek,

Le 17/02/2012 10:49, Marek Vasut a ?crit :

Quoted 21 lines
Quoted 7 lines

Hi Simon,

Le 21/11/2011 21:49, Simon Glass a ?crit :

Quoted 3 lines

The ARM link scripts are very similar but each CPU has its own. This series adds support for a default link script across an architecture in arch/<arch>/cpu/u-boot.lds.

Quoted 8 lines

This patch series received no comments, and I apologize for not having chimed in on it as it goes the right way about simplifying ARM architecture.

Currently, all patches in the series do apply except patch 7, which fails on arch/arm/cpu/pxa/u-boot.lds. As this is trivial, I'm going on removing the file manually and testing, but can you please resubmit V3 with a fixed 1/7 patch?

Please make sure there were no changes to the linker file. I believe there were
some and it might break pxa.

Thanks!

Quoted 7 lines
Quoted 3 lines

Thanks for pointing this out. I am not testing pxa boards now, so Simon has time to submit a vV3 patch set before I get bitten by any change in PXA boards.

Yes there was a change to add a 4KB MMU memory area to the link script, presumably to allow early MMU enable and using that cache space as SRAM.

Exactly, PXA250 has no SRAM so I needed some place to put stack to etc.

M

Quoted 11 lines

I think I will add this feature to the generic .lds file since it does no harm, and it's a feature I would like to implement one day (early MMU enable). It might help ARM11 also.

Quoted 3 lines

Amicalement,
--
Albert.

Regards,
Simon