[PATCH 07/10] ARM: lds: define and use BAREBOX_RELOCATION_TABLE

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


The structure of the relocation table is one of the main differences
between different architectures' linker scripts. Hoist it out for ARM
into <asm/barebox.lds.h>.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 arch/arm/include/asm/barebox.lds.h | 15 +++++++++++++++
 arch/arm/lib/pbl.lds.S             | 12 +-----------
 arch/arm/lib32/barebox.lds.S       |  8 +-------
 arch/arm/lib64/barebox.lds.S       |  8 +-------
 4 files changed, 18 insertions(+), 25 deletions(-)

diff --git a/arch/arm/include/asm/barebox.lds.h b/arch/arm/include/asm/barebox.lds.h
index e358064ec6f8..b9c824c4dbf1 100644
--- a/arch/arm/include/asm/barebox.lds.h
+++ b/arch/arm/include/asm/barebox.lds.h
@@ -12,4 +12,19 @@
 #define BAREBOX_OUTPUT_ARCH	"aarch64"
 #endif
 
+#ifdef CONFIG_CPU_32
+#define BAREBOX_RELOCATION_TYPE	rel
+#else
+#define BAREBOX_RELOCATION_TYPE	rela
+#endif
+
+#define BAREBOX_RELOCATION_TABLE					\
+	.rel_dyn_start : { *(.__rel_dyn_start) }			\
+	.BAREBOX_RELOCATION_TYPE.dyn : { *(.BAREBOX_RELOCATION_TYPE*) }	\
+	.rel_dyn_end : { *(.__rel_dyn_end) }				\
+	.__dynsym_start :  { *(.__dynsym_start) }			\
+	.dynsym : { *(.dynsym) }					\
+	.__dynsym_end : { *(.__dynsym_end) }
+
+
 #include <asm-generic/barebox.lds.h>
diff --git a/arch/arm/lib/pbl.lds.S b/arch/arm/lib/pbl.lds.S
index 42c7a4f91fb4..ae1babdcfd27 100644
--- a/arch/arm/lib/pbl.lds.S
+++ b/arch/arm/lib/pbl.lds.S
@@ -58,17 +58,7 @@ SECTIONS
 	}
 	__shasum_end = .;
 
-	.rel_dyn_start : { *(.__rel_dyn_start) }
-#ifdef CONFIG_CPU_32
-	.rel.dyn : { *(.rel*) }
-#else
-	.rela.dyn : { *(.rela*) }
-#endif
-	.rel_dyn_end : { *(.__rel_dyn_end) }
-
-	.__dynsym_start :  { *(.__dynsym_start) }
-	.dynsym : { *(.dynsym) }
-	.__dynsym_end : { *(.__dynsym_end) }
+	BAREBOX_RELOCATION_TABLE
 
 	pbl_code_size =  . - BASE;
 
diff --git a/arch/arm/lib32/barebox.lds.S b/arch/arm/lib32/barebox.lds.S
index ea66b3c3feaf..ec145569bea3 100644
--- a/arch/arm/lib32/barebox.lds.S
+++ b/arch/arm/lib32/barebox.lds.S
@@ -71,13 +71,7 @@ SECTIONS
 
 	. = .;
 
-	.rel_dyn_start : { *(.__rel_dyn_start) }
-	.rel.dyn : { *(.rel*) }
-	.rel_dyn_end : { *(.__rel_dyn_end) }
-
-	.__dynsym_start :  { *(.__dynsym_start) }
-	.dynsym : { *(.dynsym) }
-	.__dynsym_end : { *(.__dynsym_end) }
+	BAREBOX_RELOCATION_TABLE
 
 	_edata = .;
 	.image_end : { *(.__image_end) }
diff --git a/arch/arm/lib64/barebox.lds.S b/arch/arm/lib64/barebox.lds.S
index e2049753fdd5..de777ddb542b 100644
--- a/arch/arm/lib64/barebox.lds.S
+++ b/arch/arm/lib64/barebox.lds.S
@@ -49,13 +49,7 @@ SECTIONS
 
 	.barebox_imd : { BAREBOX_IMD }
 
-	.rel_dyn_start : { *(.__rel_dyn_start) }
-	.rela.dyn : { *(.rela*) }
-	.rel_dyn_end : { *(.__rel_dyn_end) }
-
-	.__dynsym_start :  { *(.__dynsym_start) }
-	.dynsym : { *(.dynsym) }
-	.__dynsym_end : { *(.__dynsym_end) }
+	BAREBOX_RELOCATION_TABLE
 
 	_edata = .;
 
-- 
2.30.2




More information about the barebox mailing list