* [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
* [PATCH v2 2/2] ARM: avoid that vectors are removed during linker garbage collection
2025-02-24 12:54 [PATCH v2 1/2] ARM: substitute OVERLAY description in linker script Christian Eggers
@ 2025-02-24 12:54 ` 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
2 siblings, 1 reply; 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
Without this, the vectors are removed if LD_DEAD_CODE_DATA_ELIMINATION
is enabled. At startup, the CPU (silently) hangs in the undefined
instruction exception as soon as the first timer interrupt arrives.
Fixes: ed0f94102251 ("ARM: 9404/1: arm32: enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION")
Signed-off-by: Christian Eggers <ceggers@arri.de>
---
v2:
- changed patch title
arch/arm/include/asm/vmlinux.lds.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/arm/include/asm/vmlinux.lds.h b/arch/arm/include/asm/vmlinux.lds.h
index 7ba309f826f9..288057e07e69 100644
--- a/arch/arm/include/asm/vmlinux.lds.h
+++ b/arch/arm/include/asm/vmlinux.lds.h
@@ -126,16 +126,16 @@
/* Note: The LLD linker seems not to support marking input */ \
/* sections with KEEP() inside a OVERLAY statement */ \
.vectors 0xffff0000 : AT (__vectors_lma) { \
- *(.vectors) \
+ KEEP(*(.vectors)) \
} \
.vectors.bhb.loop8 0xffff0000 : AT (__vectors_lma + \
SIZEOF(.vectors)) { \
- *(.vectors.bhb.loop8) \
+ KEEP(*(.vectors.bhb.loop8)) \
} \
.vectors.bhb.bpiall 0xffff0000 : AT (__vectors_lma + \
SIZEOF(.vectors) + \
SIZEOF(.vectors.bhb.loop8)) { \
- *(.vectors.bhb.bpiall) \
+ KEEP(*(.vectors.bhb.bpiall)) \
} \
ARM_LMA(__vectors, .vectors); \
ARM_LMA(__vectors_bhb_loop8, .vectors.bhb.loop8); \
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/2] ARM: substitute OVERLAY description in linker script
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-03-04 18:49 ` kernel test robot
2 siblings, 0 replies; 8+ messages in thread
From: Linus Walleij @ 2025-02-27 23:22 UTC (permalink / raw)
To: Christian Eggers
Cc: Russell King, Yuntao Liu, Russell King (Oracle), Arnd Bergmann,
Greg Kroah-Hartman, Catalin Marinas, Nathan Chancellor,
linux-arm-kernel, linux-kernel, kernel test robot
On Mon, Feb 24, 2025 at 1:54 PM Christian Eggers <ceggers@arri.de> wrote:
> 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>
Looks right to me:
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/2] ARM: avoid that vectors are removed during linker garbage collection
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
0 siblings, 0 replies; 8+ messages in thread
From: Linus Walleij @ 2025-02-27 23:22 UTC (permalink / raw)
To: Christian Eggers
Cc: Russell King, Yuntao Liu, Russell King (Oracle), Arnd Bergmann,
Greg Kroah-Hartman, Catalin Marinas, Nathan Chancellor,
linux-arm-kernel, linux-kernel
On Mon, Feb 24, 2025 at 1:54 PM Christian Eggers <ceggers@arri.de> wrote:
> Without this, the vectors are removed if LD_DEAD_CODE_DATA_ELIMINATION
> is enabled. At startup, the CPU (silently) hangs in the undefined
> instruction exception as soon as the first timer interrupt arrives.
>
> Fixes: ed0f94102251 ("ARM: 9404/1: arm32: enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION")
> Signed-off-by: Christian Eggers <ceggers@arri.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/2] ARM: substitute OVERLAY description in linker script
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 ` [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
2 siblings, 1 reply; 8+ messages in thread
From: kernel test robot @ 2025-03-04 18:49 UTC (permalink / raw)
To: Christian Eggers, Russell King, Yuntao Liu, Russell King (Oracle),
Arnd Bergmann, Linus Walleij, Greg Kroah-Hartman, Catalin Marinas,
Nathan Chancellor, linux-arm-kernel
Cc: llvm, oe-kbuild-all, linux-kernel, Christian Eggers,
kernel test robot
Hi Christian,
kernel test robot noticed the following build errors:
[auto build test ERROR on soc/for-next]
[also build test ERROR on linus/master v6.14-rc5 next-20250304]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Christian-Eggers/ARM-avoid-that-vectors-are-removed-during-linker-garbage-collection/20250224-210146
base: https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git for-next
patch link: https://lore.kernel.org/r/20250224125414.2184-1-ceggers%40arri.de
patch subject: [PATCH v2 1/2] ARM: substitute OVERLAY description in linker script
config: arm-milbeaut_m10v_defconfig (https://download.01.org/0day-ci/archive/20250305/202503050230.820w99b6-lkp@intel.com/config)
compiler: clang version 21.0.0git (https://github.com/llvm/llvm-project 14170b16028c087ca154878f5ed93d3089a965c6)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250305/202503050230.820w99b6-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202503050230.820w99b6-lkp@intel.com/
All errors (new ones prefixed by >>):
>> ld.lld: error: section .vectors.bhb.bpiall virtual address range overlaps with .vectors.bhb.loop8
>>> .vectors.bhb.bpiall range is [0xFFFF0000, 0xFFFF001F]
>>> .vectors.bhb.loop8 range is [0xFFFF0000, 0xFFFF001F]
--
>> ld.lld: error: section .vectors.bhb.loop8 virtual address range overlaps with .vectors
>>> .vectors.bhb.loop8 range is [0xFFFF0000, 0xFFFF001F]
>>> .vectors range is [0xFFFF0000, 0xFFFF001F]
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/2] ARM: substitute OVERLAY description in linker script
2025-03-04 18:49 ` kernel test robot
@ 2025-03-10 20:37 ` Nathan Chancellor
2025-03-11 8:18 ` Christian Eggers
0 siblings, 1 reply; 8+ messages in thread
From: Nathan Chancellor @ 2025-03-10 20:37 UTC (permalink / raw)
To: kernel test robot, Christian Eggers
Cc: Russell King, Yuntao Liu, Russell King (Oracle), Arnd Bergmann,
Linus Walleij, Greg Kroah-Hartman, Catalin Marinas,
linux-arm-kernel, llvm, oe-kbuild-all, linux-kernel
On Wed, Mar 05, 2025 at 02:49:38AM +0800, kernel test robot wrote:
> Hi Christian,
>
> kernel test robot noticed the following build errors:
>
> [auto build test ERROR on soc/for-next]
> [also build test ERROR on linus/master v6.14-rc5 next-20250304]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
>
> url: https://github.com/intel-lab-lkp/linux/commits/Christian-Eggers/ARM-avoid-that-vectors-are-removed-during-linker-garbage-collection/20250224-210146
> base: https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git for-next
> patch link: https://lore.kernel.org/r/20250224125414.2184-1-ceggers%40arri.de
> patch subject: [PATCH v2 1/2] ARM: substitute OVERLAY description in linker script
> config: arm-milbeaut_m10v_defconfig (https://download.01.org/0day-ci/archive/20250305/202503050230.820w99b6-lkp@intel.com/config)
> compiler: clang version 21.0.0git (https://github.com/llvm/llvm-project 14170b16028c087ca154878f5ed93d3089a965c6)
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250305/202503050230.820w99b6-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202503050230.820w99b6-lkp@intel.com/
>
> All errors (new ones prefixed by >>):
>
> >> ld.lld: error: section .vectors.bhb.bpiall virtual address range overlaps with .vectors.bhb.loop8
> >>> .vectors.bhb.bpiall range is [0xFFFF0000, 0xFFFF001F]
> >>> .vectors.bhb.loop8 range is [0xFFFF0000, 0xFFFF001F]
> --
> >> ld.lld: error: section .vectors.bhb.loop8 virtual address range overlaps with .vectors
> >>> .vectors.bhb.loop8 range is [0xFFFF0000, 0xFFFF001F]
> >>> .vectors range is [0xFFFF0000, 0xFFFF001F]
Looking at ld.lld's code, this error is intentionally ignored for
OVERLAY:
https://github.com/llvm/llvm-project/blob/9f170e6abed4a7b393bb8abbf07ac8d6930aa3b0/lld/ELF/Writer.cpp#L2751-L2761
I have submitted a patch that allows KEEP within OVERLAY to match GNU
ld:
https://github.com/llvm/llvm-project/pull/130661
Once/if that is accepted, we should go back to your v1 with something
like the following diff on top to keep things working for all linkers. I
hope that it won't take long for the ld.lld change to get reviewed and
landed but if this needs to be fixed urgently, this whole diff minus
'|| LLD_VERSION >= 210000' on the init/Kconfig change should work (with
a comment change). I can always send a follow up change to add it back.
Cheers,
Nathan
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 835b5f100e92..f3f6b7a33b79 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -121,7 +121,7 @@ config ARM
select HAVE_KERNEL_XZ
select HAVE_KPROBES if !XIP_KERNEL && !CPU_ENDIAN_BE32 && !CPU_V7M
select HAVE_KRETPROBES if HAVE_KPROBES
- select HAVE_LD_DEAD_CODE_DATA_ELIMINATION if (LD_VERSION >= 23600 || LD_IS_LLD)
+ select HAVE_LD_DEAD_CODE_DATA_ELIMINATION if (LD_VERSION >= 23600 || LD_CAN_USE_KEEP_IN_OVERLAY)
select HAVE_MOD_ARCH_SPECIFIC
select HAVE_NMI
select HAVE_OPTPROBES if !THUMB2_KERNEL
diff --git a/arch/arm/include/asm/vmlinux.lds.h b/arch/arm/include/asm/vmlinux.lds.h
index f2ff79f740ab..14811b4f48ec 100644
--- a/arch/arm/include/asm/vmlinux.lds.h
+++ b/arch/arm/include/asm/vmlinux.lds.h
@@ -34,6 +34,12 @@
#define NOCROSSREFS
#endif
+#ifdef CONFIG_LD_CAN_USE_KEEP_IN_OVERLAY
+#define OVERLAY_KEEP(x) KEEP(x)
+#else
+#define OVERLAY_KEEP(x) x
+#endif
+
/* Set start/end symbol names to the LMA for the section */
#define ARM_LMA(sym, section) \
sym##_start = LOADADDR(section); \
@@ -125,13 +131,13 @@
__vectors_lma = .; \
OVERLAY 0xffff0000 : NOCROSSREFS AT(__vectors_lma) { \
.vectors { \
- KEEP(*(.vectors)) \
+ OVERLAY_KEEP(*(.vectors)) \
} \
.vectors.bhb.loop8 { \
- KEEP(*(.vectors.bhb.loop8)) \
+ OVERLAY_KEEP(*(.vectors.bhb.loop8)) \
} \
.vectors.bhb.bpiall { \
- KEEP(*(.vectors.bhb.bpiall)) \
+ OVERLAY_KEEP(*(.vectors.bhb.bpiall)) \
} \
} \
ARM_LMA(__vectors, .vectors); \
diff --git a/init/Kconfig b/init/Kconfig
index d0d021b3fa3b..fc994f5cd5db 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -129,6 +129,11 @@ config CC_HAS_COUNTED_BY
# https://github.com/llvm/llvm-project/pull/112636
depends on !(CC_IS_CLANG && CLANG_VERSION < 190103)
+config LD_CAN_USE_KEEP_IN_OVERLAY
+ # ld.lld prior to 21.0.0 did not support KEEP within an overlay description
+ # https://github.com/llvm/llvm-project/pull/130661
+ def_bool LD_IS_BFD || LLD_VERSION >= 210000
+
config RUSTC_HAS_COERCE_POINTEE
def_bool RUSTC_VERSION >= 108400
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/2] ARM: substitute OVERLAY description in linker script
2025-03-10 20:37 ` Nathan Chancellor
@ 2025-03-11 8:18 ` Christian Eggers
2025-03-11 19:17 ` Nathan Chancellor
0 siblings, 1 reply; 8+ messages in thread
From: Christian Eggers @ 2025-03-11 8:18 UTC (permalink / raw)
To: kernel test robot, Nathan Chancellor
Cc: Russell King, Yuntao Liu, Russell King (Oracle), Arnd Bergmann,
Linus Walleij, Greg Kroah-Hartman, Catalin Marinas,
linux-arm-kernel, llvm, oe-kbuild-all, linux-kernel
[Resending, as first message got HTML'ed by my mailer...]
Hi Nathan,
thanks for pushing this into the right direction. Actually I didn't recognize that
lld complains about overlapping virtual address ranges, maybe the .config provided
by the first LKP report (which I used for testing) didn't enable the necessary options.
On Monday, 10 March 2025, 21:37:29 CET, Nathan Chancellor wrote:
> On Wed, Mar 05, 2025 at 02:49:38AM +0800, kernel test robot wrote:
> > Hi Christian,
> >
> > kernel test robot noticed the following build errors:
> >
> > [auto build test ERROR on soc/for-next]
> > [also build test ERROR on linus/master v6.14-rc5 next-20250304]
> > [If your patch is applied to the wrong git tree, kindly drop us a note.
> > And when submitting patch, we suggest to use '--base' as documented in
> > https://git-scm.com/docs/git-format-patch#_base_tree_information]
> >
> > url: https://github.com/intel-lab-lkp/linux/commits/Christian-Eggers/ARM-avoid-that-vectors-are-removed-during-linker-garbage-collection/20250224-210146
> > base: https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git for-next
> > patch link: https://lore.kernel.org/r/20250224125414.2184-1-ceggers%40arri.de
> > patch subject: [PATCH v2 1/2] ARM: substitute OVERLAY description in linker script
> > config: arm-milbeaut_m10v_defconfig (https://download.01.org/0day-ci/archive/20250305/202503050230.820w99b6-lkp@intel.com/config)
> > compiler: clang version 21.0.0git (https://github.com/llvm/llvm-project 14170b16028c087ca154878f5ed93d3089a965c6)
> > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250305/202503050230.820w99b6-lkp@intel.com/reproduce)
> >
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <lkp@intel.com>
> > | Closes: https://lore.kernel.org/oe-kbuild-all/202503050230.820w99b6-lkp@intel.com/
> >
> > All errors (new ones prefixed by >>):
> >
> > >> ld.lld: error: section .vectors.bhb.bpiall virtual address range overlaps with .vectors.bhb.loop8
> > >>> .vectors.bhb.bpiall range is [0xFFFF0000, 0xFFFF001F]
> > >>> .vectors.bhb.loop8 range is [0xFFFF0000, 0xFFFF001F]
> > --
> > >> ld.lld: error: section .vectors.bhb.loop8 virtual address range overlaps with .vectors
> > >>> .vectors.bhb.loop8 range is [0xFFFF0000, 0xFFFF001F]
> > >>> .vectors range is [0xFFFF0000, 0xFFFF001F]
>
> Looking at ld.lld's code, this error is intentionally ignored for
> OVERLAY:
>
> https://github.com/llvm/llvm-project/blob/9f170e6abed4a7b393bb8abbf07ac8d6930aa3b0/lld/ELF/Writer.cpp#L2751-L2761
>
> I have submitted a patch that allows KEEP within OVERLAY to match GNU
> ld:
>
> https://github.com/llvm/llvm-project/pull/130661
>
> Once/if that is accepted, we should go back to your v1 with something
> like the following diff on top to keep things working for all linkers. I
> hope that it won't take long for the ld.lld change to get reviewed and
> landed but if this needs to be fixed urgently, this whole diff minus
> '|| LLD_VERSION >= 210000' on the init/Kconfig change should work (with
> a comment change). I can always send a follow up change to add it back.
I build from an internal tree, so I am not in hurry. As the Kconfig changes
probably should take your Signed-Off-By, I am also fine if you do the necessary
changes on my v1 and resubmit it together with your patch when it is time.
>
> Cheers,
> Nathan
>
regards,
Christian
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index 835b5f100e92..f3f6b7a33b79 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -121,7 +121,7 @@ config ARM
> select HAVE_KERNEL_XZ
> select HAVE_KPROBES if !XIP_KERNEL && !CPU_ENDIAN_BE32 && !CPU_V7M
> select HAVE_KRETPROBES if HAVE_KPROBES
> - select HAVE_LD_DEAD_CODE_DATA_ELIMINATION if (LD_VERSION >= 23600 || LD_IS_LLD)
> + select HAVE_LD_DEAD_CODE_DATA_ELIMINATION if (LD_VERSION >= 23600 || LD_CAN_USE_KEEP_IN_OVERLAY)
> select HAVE_MOD_ARCH_SPECIFIC
> select HAVE_NMI
> select HAVE_OPTPROBES if !THUMB2_KERNEL
> diff --git a/arch/arm/include/asm/vmlinux.lds.h b/arch/arm/include/asm/vmlinux.lds.h
> index f2ff79f740ab..14811b4f48ec 100644
> --- a/arch/arm/include/asm/vmlinux.lds.h
> +++ b/arch/arm/include/asm/vmlinux.lds.h
> @@ -34,6 +34,12 @@
> #define NOCROSSREFS
> #endif
>
> +#ifdef CONFIG_LD_CAN_USE_KEEP_IN_OVERLAY
> +#define OVERLAY_KEEP(x) KEEP(x)
> +#else
> +#define OVERLAY_KEEP(x) x
> +#endif
> +
> /* Set start/end symbol names to the LMA for the section */
> #define ARM_LMA(sym, section) \
> sym##_start = LOADADDR(section); \
> @@ -125,13 +131,13 @@
> __vectors_lma = .; \
> OVERLAY 0xffff0000 : NOCROSSREFS AT(__vectors_lma) { \
> .vectors { \
> - KEEP(*(.vectors)) \
> + OVERLAY_KEEP(*(.vectors)) \
> } \
> .vectors.bhb.loop8 { \
> - KEEP(*(.vectors.bhb.loop8)) \
> + OVERLAY_KEEP(*(.vectors.bhb.loop8)) \
> } \
> .vectors.bhb.bpiall { \
> - KEEP(*(.vectors.bhb.bpiall)) \
> + OVERLAY_KEEP(*(.vectors.bhb.bpiall)) \
> } \
> } \
> ARM_LMA(__vectors, .vectors); \
> diff --git a/init/Kconfig b/init/Kconfig
> index d0d021b3fa3b..fc994f5cd5db 100644
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -129,6 +129,11 @@ config CC_HAS_COUNTED_BY
> # https://github.com/llvm/llvm-project/pull/112636
> depends on !(CC_IS_CLANG && CLANG_VERSION < 190103)
>
> +config LD_CAN_USE_KEEP_IN_OVERLAY
> + # ld.lld prior to 21.0.0 did not support KEEP within an overlay description
> + # https://github.com/llvm/llvm-project/pull/130661
> + def_bool LD_IS_BFD || LLD_VERSION >= 210000
> +
> config RUSTC_HAS_COERCE_POINTEE
> def_bool RUSTC_VERSION >= 108400
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/2] ARM: substitute OVERLAY description in linker script
2025-03-11 8:18 ` Christian Eggers
@ 2025-03-11 19:17 ` Nathan Chancellor
0 siblings, 0 replies; 8+ messages in thread
From: Nathan Chancellor @ 2025-03-11 19:17 UTC (permalink / raw)
To: Christian Eggers
Cc: kernel test robot, Russell King, Yuntao Liu,
Russell King (Oracle), Arnd Bergmann, Linus Walleij,
Greg Kroah-Hartman, Catalin Marinas, linux-arm-kernel, llvm,
oe-kbuild-all, linux-kernel
On Tue, Mar 11, 2025 at 09:18:48AM +0100, Christian Eggers wrote:
> thanks for pushing this into the right direction. Actually I didn't recognize that
> lld complains about overlapping virtual address ranges, maybe the .config provided
> by the first LKP report (which I used for testing) didn't enable the necessary options.
Right, it looks like CONFIG_HARDEN_BRANCH_HISTORY is not enabled in the
first configuration (since it was a randconfig) whereas it was in the
second configuration.
> On Monday, 10 March 2025, 21:37:29 CET, Nathan Chancellor wrote:
> > On Wed, Mar 05, 2025 at 02:49:38AM +0800, kernel test robot wrote:
> > > Hi Christian,
> > >
> > > kernel test robot noticed the following build errors:
> > >
> > > [auto build test ERROR on soc/for-next]
> > > [also build test ERROR on linus/master v6.14-rc5 next-20250304]
> > > [If your patch is applied to the wrong git tree, kindly drop us a note.
> > > And when submitting patch, we suggest to use '--base' as documented in
> > > https://git-scm.com/docs/git-format-patch#_base_tree_information]
> > >
> > > url: https://github.com/intel-lab-lkp/linux/commits/Christian-Eggers/ARM-avoid-that-vectors-are-removed-during-linker-garbage-collection/20250224-210146
> > > base: https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git for-next
> > > patch link: https://lore.kernel.org/r/20250224125414.2184-1-ceggers%40arri.de
> > > patch subject: [PATCH v2 1/2] ARM: substitute OVERLAY description in linker script
> > > config: arm-milbeaut_m10v_defconfig (https://download.01.org/0day-ci/archive/20250305/202503050230.820w99b6-lkp@intel.com/config)
> > > compiler: clang version 21.0.0git (https://github.com/llvm/llvm-project 14170b16028c087ca154878f5ed93d3089a965c6)
> > > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250305/202503050230.820w99b6-lkp@intel.com/reproduce)
> > >
> > > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > > the same patch/commit), kindly add following tags
> > > | Reported-by: kernel test robot <lkp@intel.com>
> > > | Closes: https://lore.kernel.org/oe-kbuild-all/202503050230.820w99b6-lkp@intel.com/
> > >
> > > All errors (new ones prefixed by >>):
> > >
> > > >> ld.lld: error: section .vectors.bhb.bpiall virtual address range overlaps with .vectors.bhb.loop8
> > > >>> .vectors.bhb.bpiall range is [0xFFFF0000, 0xFFFF001F]
> > > >>> .vectors.bhb.loop8 range is [0xFFFF0000, 0xFFFF001F]
> > > --
> > > >> ld.lld: error: section .vectors.bhb.loop8 virtual address range overlaps with .vectors
> > > >>> .vectors.bhb.loop8 range is [0xFFFF0000, 0xFFFF001F]
> > > >>> .vectors range is [0xFFFF0000, 0xFFFF001F]
> >
> > Looking at ld.lld's code, this error is intentionally ignored for
> > OVERLAY:
> >
> > https://github.com/llvm/llvm-project/blob/9f170e6abed4a7b393bb8abbf07ac8d6930aa3b0/lld/ELF/Writer.cpp#L2751-L2761
> >
> > I have submitted a patch that allows KEEP within OVERLAY to match GNU
> > ld:
> >
> > https://github.com/llvm/llvm-project/pull/130661
> >
> > Once/if that is accepted, we should go back to your v1 with something
> > like the following diff on top to keep things working for all linkers. I
> > hope that it won't take long for the ld.lld change to get reviewed and
> > landed but if this needs to be fixed urgently, this whole diff minus
> > '|| LLD_VERSION >= 210000' on the init/Kconfig change should work (with
> > a comment change). I can always send a follow up change to add it back.
>
>
> I build from an internal tree, so I am not in hurry. As the Kconfig changes
> probably should take your Signed-Off-By, I am also fine if you do the necessary
> changes on my v1 and resubmit it together with your patch when it is time.
I landed the ld.lld change a little bit ago so I will go ahead and send
along my patch plus yours formally shortly.
https://github.com/llvm/llvm-project/commit/381599f1fe973afad3094e55ec99b1620dba7d8c
Thanks again for bringing this up.
Cheers,
Nathan
^ permalink raw reply [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).