[PATCH 06/10] lds: move OUTPUT_FORMAT/ARCH definition into header

Ahmad Fatoum a.fatoum at pengutronix.de
Sun Oct 9 23:11:18 PDT 2022


In order to allow us having architecture-indepenent linker scripts, move
the definition for the format and the architecture into the new
<asm/barebox.lds.h> header file.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 arch/arm/include/asm/barebox.lds.h       |  8 ++++++++
 arch/arm/lib/pbl.lds.S                   | 10 +++-------
 arch/arm/lib32/barebox.lds.S             |  4 ++--
 arch/arm/lib64/barebox.lds.S             |  4 ++--
 arch/kvx/include/asm/barebox.lds.h       |  3 +++
 arch/mips/include/asm/barebox.lds.h      |  2 ++
 arch/mips/lib/barebox.lds.S              |  2 +-
 arch/mips/lib/pbl.lds.S                  |  2 +-
 arch/mips/pbl/zbarebox.lds.S             |  2 +-
 arch/openrisc/cpu/barebox.lds.S          |  2 +-
 arch/openrisc/include/asm/barebox.lds.h  |  2 ++
 arch/powerpc/boards/pcm030/barebox.lds.S |  2 +-
 arch/powerpc/include/asm/barebox.lds.h   |  2 ++
 arch/powerpc/mach-mpc85xx/barebox.lds.S  |  2 +-
 arch/riscv/include/asm/barebox.lds.h     |  7 +++++++
 arch/riscv/lib/barebox.lds.S             |  8 ++------
 arch/riscv/lib/pbl.lds.S                 |  8 ++------
 arch/x86/include/asm/barebox.lds.h       |  8 ++++++++
 arch/x86/mach-efi/elf_ia32_efi.lds.S     |  4 ++--
 arch/x86/mach-efi/elf_x86_64_efi.lds.S   |  4 ++--
 20 files changed, 53 insertions(+), 33 deletions(-)

diff --git a/arch/arm/include/asm/barebox.lds.h b/arch/arm/include/asm/barebox.lds.h
index 327beaf4bfb8..e358064ec6f8 100644
--- a/arch/arm/include/asm/barebox.lds.h
+++ b/arch/arm/include/asm/barebox.lds.h
@@ -4,4 +4,12 @@
 #include <mach/barebox.lds.h>
 #endif
 
+#ifdef CONFIG_CPU_32
+#define BAREBOX_OUTPUT_FORMAT	"elf32-littlearm", "elf32-littlearm", "elf32-littlearm"
+#define BAREBOX_OUTPUT_ARCH	"arm"
+#else
+#define BAREBOX_OUTPUT_FORMAT	"elf64-littleaarch64", "elf64-littleaarch64", "elf64-littleaarch64"
+#define BAREBOX_OUTPUT_ARCH	"aarch64"
+#endif
+
 #include <asm-generic/barebox.lds.h>
diff --git a/arch/arm/lib/pbl.lds.S b/arch/arm/lib/pbl.lds.S
index cc4b12f44893..42c7a4f91fb4 100644
--- a/arch/arm/lib/pbl.lds.S
+++ b/arch/arm/lib/pbl.lds.S
@@ -11,13 +11,9 @@
 #define BASE	(TEXT_BASE - SZ_2M)
 #endif
 
-#ifdef CONFIG_CPU_32
-OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
-OUTPUT_ARCH(arm)
-#else
-OUTPUT_FORMAT("elf64-littleaarch64", "elf64-littleaarch64", "elf64-littleaarch64")
-OUTPUT_ARCH(aarch64)
-#endif
+OUTPUT_FORMAT(BAREBOX_OUTPUT_FORMAT)
+OUTPUT_ARCH(BAREBOX_OUTPUT_ARCH)
+
 SECTIONS
 {
 	. = BASE;
diff --git a/arch/arm/lib32/barebox.lds.S b/arch/arm/lib32/barebox.lds.S
index 2bf66657a367..ea66b3c3feaf 100644
--- a/arch/arm/lib32/barebox.lds.S
+++ b/arch/arm/lib32/barebox.lds.S
@@ -4,8 +4,8 @@
 #include <asm/barebox.lds.h>
 #include <asm/secure.h>
 
-OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
-OUTPUT_ARCH(arm)
+OUTPUT_FORMAT(BAREBOX_OUTPUT_FORMAT)
+OUTPUT_ARCH(BAREBOX_OUTPUT_ARCH)
 ENTRY(start)
 SECTIONS
 {
diff --git a/arch/arm/lib64/barebox.lds.S b/arch/arm/lib64/barebox.lds.S
index c1069c896f27..e2049753fdd5 100644
--- a/arch/arm/lib64/barebox.lds.S
+++ b/arch/arm/lib64/barebox.lds.S
@@ -3,8 +3,8 @@
 
 #include <asm/barebox.lds.h>
 
-OUTPUT_FORMAT("elf64-littleaarch64", "elf64-littleaarch64", "elf64-littleaarch64")
-OUTPUT_ARCH(aarch64)
+OUTPUT_FORMAT(BAREBOX_OUTPUT_FORMAT)
+OUTPUT_ARCH(BAREBOX_OUTPUT_ARCH)
 ENTRY(start)
 SECTIONS
 {
diff --git a/arch/kvx/include/asm/barebox.lds.h b/arch/kvx/include/asm/barebox.lds.h
index 540d740959ff..4b0581c81aeb 100644
--- a/arch/kvx/include/asm/barebox.lds.h
+++ b/arch/kvx/include/asm/barebox.lds.h
@@ -1,3 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 
+#define LDS_OUTPUT_FORMAT	"elf64-kvx"
+#define LDS_OUTPUT_ARCH		"kvx:kv3-1:64"
+
 #include <asm-generic/barebox.lds.h>
diff --git a/arch/mips/include/asm/barebox.lds.h b/arch/mips/include/asm/barebox.lds.h
index 540d740959ff..124f3d5d6667 100644
--- a/arch/mips/include/asm/barebox.lds.h
+++ b/arch/mips/include/asm/barebox.lds.h
@@ -1,3 +1,5 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 
+#define BAREBOX_OUTPUT_ARCH	"mips"
+
 #include <asm-generic/barebox.lds.h>
diff --git a/arch/mips/lib/barebox.lds.S b/arch/mips/lib/barebox.lds.S
index 87668c7a7320..1259a4e94fc5 100644
--- a/arch/mips/lib/barebox.lds.S
+++ b/arch/mips/lib/barebox.lds.S
@@ -6,7 +6,7 @@
 
 #include <asm/barebox.lds.h>
 
-OUTPUT_ARCH(mips)
+OUTPUT_ARCH(BAREBOX_OUTPUT_ARCH)
 ENTRY(_start)
 SECTIONS
 {
diff --git a/arch/mips/lib/pbl.lds.S b/arch/mips/lib/pbl.lds.S
index 521333df0be0..4cf0398f33d1 100644
--- a/arch/mips/lib/pbl.lds.S
+++ b/arch/mips/lib/pbl.lds.S
@@ -10,7 +10,7 @@
 
 #define BASE    (TEXT_BASE - SZ_2M)
 
-OUTPUT_ARCH("mips")
+OUTPUT_ARCH(BAREBOX_OUTPUT_ARCH)
 SECTIONS
 {
 	. = BASE;
diff --git a/arch/mips/pbl/zbarebox.lds.S b/arch/mips/pbl/zbarebox.lds.S
index 2d82065bce08..e3114dfe2230 100644
--- a/arch/mips/pbl/zbarebox.lds.S
+++ b/arch/mips/pbl/zbarebox.lds.S
@@ -6,7 +6,7 @@
 #include <asm/barebox.lds.h>
 #include <asm-generic/memory_layout.h>
 
-OUTPUT_ARCH("mips")
+OUTPUT_ARCH(BAREBOX_OUTPUT_ARCH)
 ENTRY(pbl_start)
 SECTIONS
 {
diff --git a/arch/openrisc/cpu/barebox.lds.S b/arch/openrisc/cpu/barebox.lds.S
index f6999a113438..3fae1af37594 100644
--- a/arch/openrisc/cpu/barebox.lds.S
+++ b/arch/openrisc/cpu/barebox.lds.S
@@ -16,7 +16,7 @@
 #include <config.h>
 #include <asm/barebox.lds.h>
 
-OUTPUT_FORMAT("elf32-or1k", "elf32-or1k", "elf32-or1k")
+OUTPUT_FORMAT(BAREBOX_OUTPUT_FORMAT)
 ENTRY(__reset)
 __DYNAMIC  =  0;
 
diff --git a/arch/openrisc/include/asm/barebox.lds.h b/arch/openrisc/include/asm/barebox.lds.h
index 540d740959ff..87d868e1ad21 100644
--- a/arch/openrisc/include/asm/barebox.lds.h
+++ b/arch/openrisc/include/asm/barebox.lds.h
@@ -1,3 +1,5 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 
+#define BAREBOX_OUTPUT_FORMAT "elf32-or1k", "elf32-or1k", "elf32-or1k"
+
 #include <asm-generic/barebox.lds.h>
diff --git a/arch/powerpc/boards/pcm030/barebox.lds.S b/arch/powerpc/boards/pcm030/barebox.lds.S
index b90e88058113..146b63fe8889 100644
--- a/arch/powerpc/boards/pcm030/barebox.lds.S
+++ b/arch/powerpc/boards/pcm030/barebox.lds.S
@@ -16,7 +16,7 @@
 
 #include <asm/barebox.lds.h>
 
-OUTPUT_ARCH("powerpc")
+OUTPUT_ARCH(BAREBOX_OUTPUT_ARCH)
 ENTRY(_start)
 /* Do we need any of these for elf?
    __DYNAMIC = 0;    */
diff --git a/arch/powerpc/include/asm/barebox.lds.h b/arch/powerpc/include/asm/barebox.lds.h
index 540d740959ff..14477bd44a37 100644
--- a/arch/powerpc/include/asm/barebox.lds.h
+++ b/arch/powerpc/include/asm/barebox.lds.h
@@ -1,3 +1,5 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 
+#define BAREBOX_OUTPUT_ARCH	"powerpc"
+
 #include <asm-generic/barebox.lds.h>
diff --git a/arch/powerpc/mach-mpc85xx/barebox.lds.S b/arch/powerpc/mach-mpc85xx/barebox.lds.S
index 253fd3735e48..764854a860e7 100644
--- a/arch/powerpc/mach-mpc85xx/barebox.lds.S
+++ b/arch/powerpc/mach-mpc85xx/barebox.lds.S
@@ -21,7 +21,7 @@
 #define RESET_VECTOR_ADDRESS    0xfffffffc
 #endif
 
-OUTPUT_ARCH("powerpc")
+OUTPUT_ARCH(BAREBOX_OUTPUT_ARCH)
 ENTRY(_start_e500)
 
 PHDRS
diff --git a/arch/riscv/include/asm/barebox.lds.h b/arch/riscv/include/asm/barebox.lds.h
index 540d740959ff..0fa05df6ff2e 100644
--- a/arch/riscv/include/asm/barebox.lds.h
+++ b/arch/riscv/include/asm/barebox.lds.h
@@ -1,3 +1,10 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 
+#define BAREBOX_OUTPUT_ARCH	"riscv"
+#ifdef CONFIG_64BIT
+#define BAREBOX_OUTPUT_FORMAT	"elf64-littleriscv"
+#else
+#define BAREBOX_OUTPUT_FORMAT	"elf32-littleriscv"
+#endif
+
 #include <asm-generic/barebox.lds.h>
diff --git a/arch/riscv/lib/barebox.lds.S b/arch/riscv/lib/barebox.lds.S
index 5de32a47e7c0..101615ab052a 100644
--- a/arch/riscv/lib/barebox.lds.S
+++ b/arch/riscv/lib/barebox.lds.S
@@ -13,13 +13,9 @@
 
 #include <asm/barebox.lds.h>
 
-OUTPUT_ARCH(riscv)
+OUTPUT_ARCH(BAREBOX_OUTPUT_ARCH)
 ENTRY(start)
-#ifdef CONFIG_64BIT
-OUTPUT_FORMAT("elf64-littleriscv")
-#else
-OUTPUT_FORMAT("elf32-littleriscv")
-#endif
+OUTPUT_FORMAT(BAREBOX_OUTPUT_FORMAT)
 SECTIONS
 {
 	. = 0x0;
diff --git a/arch/riscv/lib/pbl.lds.S b/arch/riscv/lib/pbl.lds.S
index ba59024ae037..0fe7dfda8eb4 100644
--- a/arch/riscv/lib/pbl.lds.S
+++ b/arch/riscv/lib/pbl.lds.S
@@ -5,12 +5,8 @@
 #include <asm/barebox.lds.h>
 #include <asm-generic/memory_layout.h>
 
-OUTPUT_ARCH(riscv)
-#ifdef CONFIG_64BIT
-OUTPUT_FORMAT("elf64-littleriscv")
-#else
-OUTPUT_FORMAT("elf32-littleriscv")
-#endif
+OUTPUT_ARCH(BAREBOX_OUTPUT_ARCH)
+OUTPUT_FORMAT(BAREBOX_OUTPUT_FORMAT)
 SECTIONS
 {
 	. = 0x0;
diff --git a/arch/x86/include/asm/barebox.lds.h b/arch/x86/include/asm/barebox.lds.h
index 540d740959ff..f00d36c4e747 100644
--- a/arch/x86/include/asm/barebox.lds.h
+++ b/arch/x86/include/asm/barebox.lds.h
@@ -1,3 +1,11 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 
+#ifdef CONFIG_X86_32
+#define BAREBOX_OUTPUT_FORMAT	"elf32-i386", "elf32-i386", "elf32-i386"
+#define BAREBOX_OUTPUT_ARCH	"i386"
+#else
+#define BAREBOX_OUTPUT_FORMAT	"elf64-x86-64", "elf64-x86-64", "elf64-x86-64"
+#define BAREBOX_OUTPUT_ARCH	"i386:x86-64"
+#endif
+
 #include <asm-generic/barebox.lds.h>
diff --git a/arch/x86/mach-efi/elf_ia32_efi.lds.S b/arch/x86/mach-efi/elf_ia32_efi.lds.S
index 14ae702e5049..4b1300724300 100644
--- a/arch/x86/mach-efi/elf_ia32_efi.lds.S
+++ b/arch/x86/mach-efi/elf_ia32_efi.lds.S
@@ -2,8 +2,8 @@
 
 #include <asm/barebox.lds.h>
 
-OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
-OUTPUT_ARCH(i386)
+OUTPUT_FORMAT(BAREBOX_OUTPUT_FORMAT)
+OUTPUT_ARCH(BAREBOX_OUTPUT_ARCH)
 ENTRY(_start)
 SECTIONS
 {
diff --git a/arch/x86/mach-efi/elf_x86_64_efi.lds.S b/arch/x86/mach-efi/elf_x86_64_efi.lds.S
index 8c666235ce1a..f63c0c0c939e 100644
--- a/arch/x86/mach-efi/elf_x86_64_efi.lds.S
+++ b/arch/x86/mach-efi/elf_x86_64_efi.lds.S
@@ -4,8 +4,8 @@
 
 /* Same as elf_x86_64_fbsd_efi.lds, except for OUTPUT_FORMAT below - KEEP IN SYNC */
 
-OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
-OUTPUT_ARCH(i386:x86-64)
+OUTPUT_FORMAT(BAREBOX_OUTPUT_FORMAT)
+OUTPUT_ARCH(BAREBOX_OUTPUT_ARCH)
 ENTRY(_start)
 SECTIONS
 {
-- 
2.30.2




More information about the barebox mailing list