All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali@kernel.org>
To: "Simon Glass" <sjg@chromium.org>,
	"Heinrich Schuchardt" <xypron.glpk@gmx.de>,
	"Alexander Graf" <agraf@csgraf.de>,
	"Huan Wang" <alison.wang@nxp.com>,
	"Angelo Dureghello" <angelo@sysam.it>,
	"Wolfgang Denk" <wd@denx.de>,
	"Priyanka Jain" <priyanka.jain@nxp.com>,
	"Christophe Leroy" <christophe.leroy@c-s.fr>,
	"Bin Meng" <bmeng.cn@gmail.com>,
	"Marek Behún" <marek.behun@nic.cz>,
	"Tom Rini" <trini@konsulko.com>
Cc: u-boot@lists.denx.de
Subject: [PATCH v2] powerpc: mpc: Put U-Boot version string at correct place by linker script
Date: Sun,  8 Aug 2021 13:20:38 +0200	[thread overview]
Message-ID: <20210808112038.7942-1-pali@kernel.org> (raw)
In-Reply-To: <20210802131838.21097-8-pali@kernel.org>

It is unknown why version string is placed at specific position on these
powerpc mpc platforms. But there is no need to overload version_string
symbol. Just use common definition of version_string and modify linker
script to put it at "correct place".

Signed-off-by: Pali Rohár <pali@kernel.org>

---
Changes in v2:
* Put explicit ".section" keyword before declaring ".text_pre" section as
  some gcc versions cannot recognize specifying custom section without it.
* Tested compilation for:
  $ make CROSS_COMPILE=powerpc-linux-gnu- MCR3000_defconfig u-boot.bin
  and checked that u-boot.bin header is same with and without this patch
---
 arch/powerpc/cpu/mpc83xx/start.S         | 10 +++-------
 arch/powerpc/cpu/mpc83xx/u-boot.lds      |  3 +++
 arch/powerpc/cpu/mpc85xx/start.S         | 10 ++++------
 arch/powerpc/cpu/mpc85xx/u-boot-nand.lds |  4 ++++
 arch/powerpc/cpu/mpc85xx/u-boot-spl.lds  |  4 ++++
 arch/powerpc/cpu/mpc85xx/u-boot.lds      |  4 ++++
 arch/powerpc/cpu/mpc8xx/start.S          |  9 ++++-----
 board/cssi/MCR3000/u-boot.lds            |  2 ++
 8 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/arch/powerpc/cpu/mpc83xx/start.S b/arch/powerpc/cpu/mpc83xx/start.S
index 9da22ce486a9..87747f2b2275 100644
--- a/arch/powerpc/cpu/mpc83xx/start.S
+++ b/arch/powerpc/cpu/mpc83xx/start.S
@@ -13,7 +13,6 @@
 #include <asm-offsets.h>
 #include <config.h>
 #include <mpc83xx.h>
-#include <version.h>
 
 #define CONFIG_83XX	1		/* needed for Linux kernel header files*/
 
@@ -76,7 +75,7 @@
  * times so the processor can fetch it out of flash whether the flash
  * is 8, 16, 32, or 64 bits wide (hardware trickery).
  */
-	.text
+	.section .text_pre
 #define _HRCW_TABLE_ENTRY(w)		\
 	.fill	8,1,(((w)>>24)&0xff);	\
 	.fill	8,1,(((w)>>16)&0xff);	\
@@ -92,12 +91,9 @@
  */
 	.long	0x27051956		/* U-Boot Magic Number */
 
-	.globl	version_string
-version_string:
-	.ascii U_BOOT_VERSION_STRING, "\0"
-
-	.align 2
+/* U-Boot version string is filled at this place by linker script */
 
+	.text
 	.globl enable_addr_trans
 enable_addr_trans:
 	/* enable address translation */
diff --git a/arch/powerpc/cpu/mpc83xx/u-boot.lds b/arch/powerpc/cpu/mpc83xx/u-boot.lds
index d10f528da4c4..309082bc3df5 100644
--- a/arch/powerpc/cpu/mpc83xx/u-boot.lds
+++ b/arch/powerpc/cpu/mpc83xx/u-boot.lds
@@ -10,6 +10,9 @@ SECTIONS
   /* Read-only sections, merged into text segment: */
   .text      :
   {
+    arch/powerpc/cpu/mpc83xx/start.o	(.text_pre)
+    *(.text_version_string)
+    . = ALIGN(2);
     arch/powerpc/cpu/mpc83xx/start.o	(.text*)
     *(.text*)
     . = ALIGN(16);
diff --git a/arch/powerpc/cpu/mpc85xx/start.S b/arch/powerpc/cpu/mpc85xx/start.S
index f41e82ad189f..5ba26d3c449b 100644
--- a/arch/powerpc/cpu/mpc85xx/start.S
+++ b/arch/powerpc/cpu/mpc85xx/start.S
@@ -14,7 +14,6 @@
 #include <asm-offsets.h>
 #include <config.h>
 #include <mpc85xx.h>
-#include <version.h>
 
 #include <ppc_asm.tmpl>
 #include <ppc_defs.h>
@@ -1134,15 +1133,14 @@ switch_as:
 	blr
 #endif
 
-	.text
+	.section .text_pre
 	.globl	_start
 _start:
 	.long	0x27051956		/* U-BOOT Magic Number */
-	.globl	version_string
-version_string:
-	.ascii U_BOOT_VERSION_STRING, "\0"
 
-	.align	4
+/* U-Boot version string is filled at this place by linker script */
+
+	.text
 	.globl	_start_cont
 _start_cont:
 	/* Setup the stack in initial RAM,could be L2-as-SRAM or L1 dcache*/
diff --git a/arch/powerpc/cpu/mpc85xx/u-boot-nand.lds b/arch/powerpc/cpu/mpc85xx/u-boot-nand.lds
index 75b0285e4e51..6e48223380cb 100644
--- a/arch/powerpc/cpu/mpc85xx/u-boot-nand.lds
+++ b/arch/powerpc/cpu/mpc85xx/u-boot-nand.lds
@@ -25,6 +25,10 @@ SECTIONS
   .interp : { *(.interp) }
   .text      :
   {
+    arch/powerpc/cpu/mpc85xx/start.o (.text_pre)
+    *(.text_version_string)
+    . = ALIGN(4);
+    arch/powerpc/cpu/mpc85xx/start.o (.text*)
     *(.text*)
    } :text
     _etext = .;
diff --git a/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds b/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds
index 27a5fe6306a3..2312cd47f11d 100644
--- a/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds
+++ b/arch/powerpc/cpu/mpc85xx/u-boot-spl.lds
@@ -20,6 +20,10 @@ SECTIONS
 {
 	. = IMAGE_TEXT_BASE;
 	.text : {
+		arch/powerpc/cpu/mpc85xx/start.o (.text_pre)
+		*(.text_version_string)
+		. = ALIGN(4);
+		arch/powerpc/cpu/mpc85xx/start.o (.text*)
 		*(.text*)
 	}
 	_etext = .;
diff --git a/arch/powerpc/cpu/mpc85xx/u-boot.lds b/arch/powerpc/cpu/mpc85xx/u-boot.lds
index 22bbac51aa33..40d181ef2caa 100644
--- a/arch/powerpc/cpu/mpc85xx/u-boot.lds
+++ b/arch/powerpc/cpu/mpc85xx/u-boot.lds
@@ -31,6 +31,10 @@ SECTIONS
   .interp : { *(.interp) }
   .text      :
   {
+    arch/powerpc/cpu/mpc85xx/start.o (.text_pre)
+    *(.text_version_string)
+    . = ALIGN(4);
+    arch/powerpc/cpu/mpc85xx/start.o (.text*)
     *(.text*)
    } :text
     _etext = .;
diff --git a/arch/powerpc/cpu/mpc8xx/start.S b/arch/powerpc/cpu/mpc8xx/start.S
index ed735cdee005..09628a0d60f0 100644
--- a/arch/powerpc/cpu/mpc8xx/start.S
+++ b/arch/powerpc/cpu/mpc8xx/start.S
@@ -23,7 +23,6 @@
 #include <asm-offsets.h>
 #include <config.h>
 #include <mpc8xx.h>
-#include <version.h>
 
 #include <ppc_asm.tmpl>
 #include <ppc_defs.h>
@@ -60,12 +59,12 @@
  * r3 - 1st arg to board_init(): IMMP pointer
  * r4 - 2nd arg to board_init(): boot flag
  */
-	.text
+	.section .text_pre
 	.long	0x27051956		/* U-Boot Magic Number			*/
-	.globl	version_string
-version_string:
-	.ascii U_BOOT_VERSION_STRING, "\0"
 
+/* U-Boot version string is filled at this place by linker script */
+
+	.text
 	. = EXC_OFF_SYS_RESET
 	.globl	_start
 _start:
diff --git a/board/cssi/MCR3000/u-boot.lds b/board/cssi/MCR3000/u-boot.lds
index 70aef3241c8e..9b2ead29b4a5 100644
--- a/board/cssi/MCR3000/u-boot.lds
+++ b/board/cssi/MCR3000/u-boot.lds
@@ -16,6 +16,8 @@ SECTIONS
 	. = + SIZEOF_HEADERS;
 	.text          :
 	{
+		arch/powerpc/cpu/mpc8xx/start.o	(.text_pre)
+		*(.text_version_string)
 		arch/powerpc/cpu/mpc8xx/start.o	(.text)
 		arch/powerpc/cpu/mpc8xx/traps.o	(.text*)
 		arch/powerpc/lib/built-in.o		(.text*)
-- 
2.20.1


  reply	other threads:[~2021-08-08 11:21 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-02 13:18 [PATCH 00/11] Reduce usage of timestamp macros Pali Rohár
2021-08-02 13:18 ` [PATCH 01/11] Remove #include <timestamp.h> from files which do not need it Pali Rohár
2021-08-02 13:58   ` Tom Rini
2021-09-23  2:07   ` Tom Rini
2021-08-02 13:18 ` [PATCH 02/11] Remove #include <version.h> " Pali Rohár
2021-08-02 13:58   ` Tom Rini
2021-09-23  2:07   ` Tom Rini
2021-08-02 13:18 ` [PATCH 03/11] efi_loader: Use directly version_string variable Pali Rohár
2021-08-02 20:04   ` Heinrich Schuchardt
2021-08-03  7:37     ` Ilias Apalodimas
2021-09-23  2:07   ` Tom Rini
2021-08-02 13:18 ` [PATCH 04/11] version: Move version_string[] from version.h to version_string.h Pali Rohár
2021-08-02 13:58   ` Tom Rini
2021-09-23  2:08   ` Tom Rini
2021-08-02 13:18 ` [PATCH 05/11] m68k: mcf: Remove overloading version_string Pali Rohár
2021-09-23  2:08   ` Tom Rini
2021-08-02 13:18 ` [PATCH 06/11] version: Put version_string[] variable into section .text_version_string Pali Rohár
2021-08-02 13:58   ` Tom Rini
2021-09-16 17:30   ` [PATCH] xtensa: Put U-Boot version string at correct place by linker script Tom Rini
2021-09-16 19:38     ` Francesco Dolcini
2021-09-16 19:42       ` Tom Rini
2021-09-16 19:50         ` Francesco Dolcini
2021-09-16 20:13           ` Tom Rini
2021-09-16 20:23             ` Francesco Dolcini
2021-09-17  5:21         ` Max Filippov
2021-09-17 12:02           ` Tom Rini
2021-09-17  5:14     ` Max Filippov
2021-09-17 12:04       ` Tom Rini
2021-09-17 12:30         ` Max Filippov
2021-08-02 13:18 ` [PATCH 07/11] powerpc: mpc: " Pali Rohár
2021-08-08 11:20   ` Pali Rohár [this message]
2021-08-08 11:36     ` [PATCH v2] " Pali Rohár
2021-08-24  5:03       ` Christophe Leroy
2021-08-24  9:46         ` Wolfgang Denk
2021-08-24  5:28     ` Christophe Leroy
2021-08-24 11:28       ` Pali Rohár
2021-09-16 19:17     ` Tom Rini
2021-09-16 19:56   ` [PATCH 1/1] powerpc: Drop version_string placement optimization Tom Rini
2021-09-23  2:09     ` Tom Rini
2021-08-02 13:18 ` [PATCH 08/11] version: Do not make version_string[] variable as a weak Pali Rohár
2021-08-02 13:58   ` Tom Rini
2021-09-23  2:08   ` Tom Rini
2021-08-02 13:18 ` [PATCH 09/11] x86: quark: MRC: Remove U_BOOT_DATE and U_BOOT_TIME from debug log Pali Rohár
2021-08-02 19:21   ` Simon Glass
2021-08-02 23:25   ` Bin Meng
2021-09-23  2:08   ` Tom Rini
2021-08-02 13:18 ` [PATCH 10/11] version: Remove global macro U_BOOT_VERSION_STRING from version.h Pali Rohár
2021-08-02 13:59   ` Tom Rini
2021-09-23  2:08   ` Tom Rini
2021-08-02 13:18 ` [PATCH 11/11] Remove including timestamp.h in version.h Pali Rohár
2021-08-02 19:21   ` Simon Glass
2021-08-02 19:42     ` Pali Rohár
2021-08-02 21:31       ` Tom Rini
2021-08-04  5:59         ` Wolfgang Denk
2021-08-04 12:44           ` Tom Rini
2021-08-04 14:36             ` Simon Glass
2021-08-04 14:40               ` Tom Rini
2021-08-04 21:46                 ` Pali Rohár
2021-08-04 21:43     ` Sean Anderson
2021-08-04 21:52       ` Pali Rohár
2021-08-04 22:09       ` Tom Rini
2021-08-04 22:14         ` Pali Rohár
2021-08-04 22:15           ` Tom Rini
2021-08-04 22:22             ` Pali Rohár
2021-09-23  2:08   ` Tom Rini
2021-08-17 11:02 ` [PATCH 00/11] Reduce usage of timestamp macros Pali Rohár
2021-08-17 13:40   ` Tom Rini
2021-09-01 20:59 ` Tom Rini
2021-09-01 21:05   ` Pali Rohár
2021-09-01 21:17     ` Tom Rini
2021-09-01 21:28       ` Pali Rohár
2021-09-01 21:33         ` Tom Rini
2021-09-01 21:44           ` Pali Rohár
2021-09-01 21:49             ` Pali Rohár
2021-09-10 20:56               ` Pali Rohár
2021-09-10 21:18                 ` Tom Rini
2021-09-01 21:56             ` Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210808112038.7942-1-pali@kernel.org \
    --to=pali@kernel.org \
    --cc=agraf@csgraf.de \
    --cc=alison.wang@nxp.com \
    --cc=angelo@sysam.it \
    --cc=bmeng.cn@gmail.com \
    --cc=christophe.leroy@c-s.fr \
    --cc=marek.behun@nic.cz \
    --cc=priyanka.jain@nxp.com \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=wd@denx.de \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.