linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] ARM: substitute OVERLAY description in linker script
@ 2025-02-24 12:54 Christian Eggers
  2025-02-24 12:54 ` [PATCH v2 2/2] ARM: avoid that vectors are removed during linker garbage collection Christian Eggers
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Christian Eggers @ 2025-02-24 12:54 UTC (permalink / raw)
  To: Russell King, Yuntao Liu, Russell King (Oracle), Arnd Bergmann,
	Linus Walleij, Greg Kroah-Hartman, Catalin Marinas,
	Nathan Chancellor, linux-arm-kernel
  Cc: linux-kernel, Christian Eggers, kernel test robot

If linker garbage collection is active, we must ensure that the vectors
are not removed during linking (by using the KEEP keyword).  But it
seems that the LLD linker doesn't support using the KEEP() keyword
within an overlay description.

The GNU linker manual shows an alternative way to accomplish the same
result without using the overlay statement:

https://sourceware.org/binutils/docs/ld/Overlay-Description.html

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202502222158.UhwuvDZv-lkp@intel.com/
Signed-off-by: Christian Eggers <ceggers@arri.de>
---
v2:
- added this patch as the kernel test robot complained when
  using the LLD linker:
  https://lore.kernel.org/all/202502222158.UhwuvDZv-lkp@intel.com/

 arch/arm/include/asm/vmlinux.lds.h | 21 +++++++++++++--------
 arch/arm/kernel/vmlinux-xip.lds.S  |  2 ++
 arch/arm/kernel/vmlinux.lds.S      |  2 ++
 3 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/arch/arm/include/asm/vmlinux.lds.h b/arch/arm/include/asm/vmlinux.lds.h
index d60f6e83a9f7..7ba309f826f9 100644
--- a/arch/arm/include/asm/vmlinux.lds.h
+++ b/arch/arm/include/asm/vmlinux.lds.h
@@ -31,7 +31,7 @@
  * https://github.com/ClangBuiltLinux/linux/issues/1609
  */
 #ifdef CONFIG_LD_IS_LLD
-#define NOCROSSREFS
+#define NOCROSSREFS(...)
 #endif
 
 /* Set start/end symbol names to the LMA for the section */
@@ -123,16 +123,19 @@
  */
 #define ARM_VECTORS							\
 	__vectors_lma = .;						\
-	OVERLAY 0xffff0000 : NOCROSSREFS AT(__vectors_lma) {		\
-		.vectors {						\
+	/* Note: The LLD linker seems not to support marking input */	\
+	/* sections with KEEP() inside a OVERLAY statement */		\
+	.vectors 0xffff0000 : AT (__vectors_lma) {			\
 			*(.vectors)					\
-		}							\
-		.vectors.bhb.loop8 {					\
+	}								\
+	.vectors.bhb.loop8 0xffff0000 : AT (__vectors_lma +		\
+		SIZEOF(.vectors)) {					\
 			*(.vectors.bhb.loop8)				\
-		}							\
-		.vectors.bhb.bpiall {					\
+	}								\
+	.vectors.bhb.bpiall 0xffff0000 : AT (__vectors_lma +		\
+		SIZEOF(.vectors) +					\
+		SIZEOF(.vectors.bhb.loop8)) {				\
 			*(.vectors.bhb.bpiall)				\
-		}							\
 	}								\
 	ARM_LMA(__vectors, .vectors);					\
 	ARM_LMA(__vectors_bhb_loop8, .vectors.bhb.loop8);		\
@@ -150,6 +153,8 @@
 									\
 	PROVIDE(vector_fiq_offset = vector_fiq - ADDR(.vectors));
 
+#define ARM_NOCROSSREFS NOCROSSREFS(.vectors .vectors.bhb.loop8 .vectors.bhb.bpiall)
+
 #define ARM_TCM								\
 	__itcm_start = ALIGN(4);					\
 	.text_itcm ITCM_OFFSET : AT(__itcm_start - LOAD_OFFSET) {	\
diff --git a/arch/arm/kernel/vmlinux-xip.lds.S b/arch/arm/kernel/vmlinux-xip.lds.S
index 5eddb75a7174..496d609c24c8 100644
--- a/arch/arm/kernel/vmlinux-xip.lds.S
+++ b/arch/arm/kernel/vmlinux-xip.lds.S
@@ -159,6 +159,8 @@ SECTIONS
 	ARM_ASSERTS
 }
 
+ARM_NOCROSSREFS
+
 /*
  * These must never be empty
  * If you have to comment these two assert statements out, your
diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
index de373c6c2ae8..514a030b7d5f 100644
--- a/arch/arm/kernel/vmlinux.lds.S
+++ b/arch/arm/kernel/vmlinux.lds.S
@@ -158,6 +158,8 @@ SECTIONS
 	ARM_ASSERTS
 }
 
+ARM_NOCROSSREFS
+
 #ifdef CONFIG_STRICT_KERNEL_RWX
 /*
  * Without CONFIG_DEBUG_ALIGN_RODATA, __start_rodata_section_aligned will
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-03-11 19:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-24 12:54 [PATCH v2 1/2] ARM: substitute OVERLAY description in linker script Christian Eggers
2025-02-24 12:54 ` [PATCH v2 2/2] ARM: avoid that vectors are removed during linker garbage collection Christian Eggers
2025-02-27 23:22   ` Linus Walleij
2025-02-27 23:22 ` [PATCH v2 1/2] ARM: substitute OVERLAY description in linker script Linus Walleij
2025-03-04 18:49 ` kernel test robot
2025-03-10 20:37   ` Nathan Chancellor
2025-03-11  8:18     ` Christian Eggers
2025-03-11 19:17       ` Nathan Chancellor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).