Message ID | 20240808123556.681609-1-liuyuntao12@huawei.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | arm: Fix build issue with LD_DEAD_CODE_DATA_ELIMINATION | expand |
On Thu, Aug 8, 2024, at 14:35, Yuntao Liu wrote: > There is a build issue with LD segmentation fault, while > CONFIG_LD_DEAD_CODE_DATA_ELIMINATION is not enabled, as bellow. > > scripts/link-vmlinux.sh: line 49: 3796 Segmentation fault > (core dumped) ${ld} ${ldflags} -o ${output} ${wl}--whole-archive > ${objs} ${wl}--no-whole-archive ${wl}--start-group > ${libs} ${wl}--end-group ${kallsymso} ${btf_vmlinux_bin_o} ${ldlibs} > > The error occurs in older versions of the GNU ld with version earlier > than 2.36. It makes most sense to have a minimum LD version as > a dependency for HAVE_LD_DEAD_CODE_DATA_ELIMINATION and eliminate > the impact of ".reloc .text, R_ARM_NONE, ." when > CONFIG_LD_DEAD_CODE_DATA_ELIMINATION is not enabled. > > Fixes: ed0f94102251 ("ARM: 9404/1: arm32: enable > HAVE_LD_DEAD_CODE_DATA_ELIMINATION") > Reported-by: Harith George <mail2hgg@gmail.com> > Suggested-by: Arnd Bergmann <arnd@arndb.de> > Signed-off-by: Yuntao Liu <liuyuntao12@huawei.com> > Link: > https://lore.kernel.org/all/14e9aefb-88d1-4eee-8288-ef15d4a9b059@gmail.com/ Looks good to me, Acked-by: Arnd Bergmann <arnd@arndb.de>
On 08-08-2024 18:05, Yuntao Liu wrote: > There is a build issue with LD segmentation fault, while > CONFIG_LD_DEAD_CODE_DATA_ELIMINATION is not enabled, as bellow. > > scripts/link-vmlinux.sh: line 49: 3796 Segmentation fault > (core dumped) ${ld} ${ldflags} -o ${output} ${wl}--whole-archive > ${objs} ${wl}--no-whole-archive ${wl}--start-group > ${libs} ${wl}--end-group ${kallsymso} ${btf_vmlinux_bin_o} ${ldlibs} > > The error occurs in older versions of the GNU ld with version earlier > than 2.36. It makes most sense to have a minimum LD version as > a dependency for HAVE_LD_DEAD_CODE_DATA_ELIMINATION and eliminate > the impact of ".reloc .text, R_ARM_NONE, ." when > CONFIG_LD_DEAD_CODE_DATA_ELIMINATION is not enabled. > > Fixes: ed0f94102251 ("ARM: 9404/1: arm32: enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION") > Reported-by: Harith George <mail2hgg@gmail.com> > Suggested-by: Arnd Bergmann <arnd@arndb.de> > Signed-off-by: Yuntao Liu <liuyuntao12@huawei.com> > Link: https://lore.kernel.org/all/14e9aefb-88d1-4eee-8288-ef15d4a9b059@gmail.com/ > --- > arch/arm/Kconfig | 2 +- > arch/arm/kernel/entry-armv.S | 12 +++++++++--- > 2 files changed, 10 insertions(+), 4 deletions(-) > > diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig > index 54b2bb817a7f..173159e93c99 100644 > --- a/arch/arm/Kconfig > +++ b/arch/arm/Kconfig > @@ -117,7 +117,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 > + select HAVE_LD_DEAD_CODE_DATA_ELIMINATION if (LD_VERSION >= 23600 || LD_IS_LLD) > select HAVE_MOD_ARCH_SPECIFIC > select HAVE_NMI > select HAVE_OPTPROBES if !THUMB2_KERNEL > diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S > index f01d23a220e6..cd443faf8645 100644 > --- a/arch/arm/kernel/entry-armv.S > +++ b/arch/arm/kernel/entry-armv.S > @@ -29,6 +29,12 @@ > #include "entry-header.S" > #include <asm/probes.h> > > +#ifdef CONFIG_HAVE_LD_DEAD_CODE_DATA_ELIMINATION > +#define RELOC_TEXT_NONE (.reloc .text, R_ARM_NONE, .) > +#else > +#define RELOC_TEXT_NONE > +#endif > + > /* > * Interrupt handling. > */ > @@ -1065,7 +1071,7 @@ vector_addrexcptn: > .globl vector_fiq > > .section .vectors, "ax", %progbits > - .reloc .text, R_ARM_NONE, . > + RELOC_TEXT_NONE > W(b) vector_rst > W(b) vector_und > ARM( .reloc ., R_ARM_LDR_PC_G0, .L__vector_swi ) > @@ -1079,7 +1085,7 @@ THUMB( .reloc ., R_ARM_THM_PC12, .L__vector_swi ) > > #ifdef CONFIG_HARDEN_BRANCH_HISTORY > .section .vectors.bhb.loop8, "ax", %progbits > - .reloc .text, R_ARM_NONE, . > + RELOC_TEXT_NONE > W(b) vector_rst > W(b) vector_bhb_loop8_und > ARM( .reloc ., R_ARM_LDR_PC_G0, .L__vector_bhb_loop8_swi ) > @@ -1092,7 +1098,7 @@ THUMB( .reloc ., R_ARM_THM_PC12, .L__vector_bhb_loop8_swi ) > W(b) vector_bhb_loop8_fiq > > .section .vectors.bhb.bpiall, "ax", %progbits > - .reloc .text, R_ARM_NONE, . > + RELOC_TEXT_NONE > W(b) vector_rst > W(b) vector_bhb_bpiall_und > ARM( .reloc ., R_ARM_LDR_PC_G0, .L__vector_bhb_bpiall_swi ) Build tested. Solves the earlier build issue I was seeing. fwiw, you can add my tested by tag if needed. Tested-by: Harith George <mail2hgg@gmail.com>
On Mon, Aug 12, 2024 at 01:21:59PM +0530, Harith George wrote: > On 08-08-2024 18:05, Yuntao Liu wrote: > > There is a build issue with LD segmentation fault, while > > CONFIG_LD_DEAD_CODE_DATA_ELIMINATION is not enabled, as bellow. > > > > scripts/link-vmlinux.sh: line 49: 3796 Segmentation fault > > (core dumped) ${ld} ${ldflags} -o ${output} ${wl}--whole-archive > > ${objs} ${wl}--no-whole-archive ${wl}--start-group > > ${libs} ${wl}--end-group ${kallsymso} ${btf_vmlinux_bin_o} ${ldlibs} > > > > The error occurs in older versions of the GNU ld with version earlier > > than 2.36. It makes most sense to have a minimum LD version as > > a dependency for HAVE_LD_DEAD_CODE_DATA_ELIMINATION and eliminate > > the impact of ".reloc .text, R_ARM_NONE, ." when > > CONFIG_LD_DEAD_CODE_DATA_ELIMINATION is not enabled. > > > > Fixes: ed0f94102251 ("ARM: 9404/1: arm32: enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION") > > Reported-by: Harith George <mail2hgg@gmail.com> > > Suggested-by: Arnd Bergmann <arnd@arndb.de> > > Signed-off-by: Yuntao Liu <liuyuntao12@huawei.com> > > Link: https://lore.kernel.org/all/14e9aefb-88d1-4eee-8288-ef15d4a9b059@gmail.com/ > > Build tested. Solves the earlier build issue I was seeing. > fwiw, you can add my tested by tag if needed. > > Tested-by: Harith George <mail2hgg@gmail.com> (a) please see the note in my signature below. (b) this tested-by needs to be collected by the submitter before it gets into the patch system. (c) it needs to get into the patch system. Bear in mind that as a result of (a), it's going to be better to get it into the patch system sooner rather than later - I am expecting there to be a period of time (weeks) where it will be impossible for me to read the screen...
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 54b2bb817a7f..173159e93c99 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -117,7 +117,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 + select HAVE_LD_DEAD_CODE_DATA_ELIMINATION if (LD_VERSION >= 23600 || LD_IS_LLD) select HAVE_MOD_ARCH_SPECIFIC select HAVE_NMI select HAVE_OPTPROBES if !THUMB2_KERNEL diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S index f01d23a220e6..cd443faf8645 100644 --- a/arch/arm/kernel/entry-armv.S +++ b/arch/arm/kernel/entry-armv.S @@ -29,6 +29,12 @@ #include "entry-header.S" #include <asm/probes.h> +#ifdef CONFIG_HAVE_LD_DEAD_CODE_DATA_ELIMINATION +#define RELOC_TEXT_NONE (.reloc .text, R_ARM_NONE, .) +#else +#define RELOC_TEXT_NONE +#endif + /* * Interrupt handling. */ @@ -1065,7 +1071,7 @@ vector_addrexcptn: .globl vector_fiq .section .vectors, "ax", %progbits - .reloc .text, R_ARM_NONE, . + RELOC_TEXT_NONE W(b) vector_rst W(b) vector_und ARM( .reloc ., R_ARM_LDR_PC_G0, .L__vector_swi ) @@ -1079,7 +1085,7 @@ THUMB( .reloc ., R_ARM_THM_PC12, .L__vector_swi ) #ifdef CONFIG_HARDEN_BRANCH_HISTORY .section .vectors.bhb.loop8, "ax", %progbits - .reloc .text, R_ARM_NONE, . + RELOC_TEXT_NONE W(b) vector_rst W(b) vector_bhb_loop8_und ARM( .reloc ., R_ARM_LDR_PC_G0, .L__vector_bhb_loop8_swi ) @@ -1092,7 +1098,7 @@ THUMB( .reloc ., R_ARM_THM_PC12, .L__vector_bhb_loop8_swi ) W(b) vector_bhb_loop8_fiq .section .vectors.bhb.bpiall, "ax", %progbits - .reloc .text, R_ARM_NONE, . + RELOC_TEXT_NONE W(b) vector_rst W(b) vector_bhb_bpiall_und ARM( .reloc ., R_ARM_LDR_PC_G0, .L__vector_bhb_bpiall_swi )
There is a build issue with LD segmentation fault, while CONFIG_LD_DEAD_CODE_DATA_ELIMINATION is not enabled, as bellow. scripts/link-vmlinux.sh: line 49: 3796 Segmentation fault (core dumped) ${ld} ${ldflags} -o ${output} ${wl}--whole-archive ${objs} ${wl}--no-whole-archive ${wl}--start-group ${libs} ${wl}--end-group ${kallsymso} ${btf_vmlinux_bin_o} ${ldlibs} The error occurs in older versions of the GNU ld with version earlier than 2.36. It makes most sense to have a minimum LD version as a dependency for HAVE_LD_DEAD_CODE_DATA_ELIMINATION and eliminate the impact of ".reloc .text, R_ARM_NONE, ." when CONFIG_LD_DEAD_CODE_DATA_ELIMINATION is not enabled. Fixes: ed0f94102251 ("ARM: 9404/1: arm32: enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION") Reported-by: Harith George <mail2hgg@gmail.com> Suggested-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Yuntao Liu <liuyuntao12@huawei.com> Link: https://lore.kernel.org/all/14e9aefb-88d1-4eee-8288-ef15d4a9b059@gmail.com/ --- arch/arm/Kconfig | 2 +- arch/arm/kernel/entry-armv.S | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-)