| From c6c53db727bb8e2aa4d069f712d99c6f543d63bc Mon Sep 17 00:00:00 2001 | |
| From: Sasha Levin <sashal@kernel.org> | |
| Date: Sun, 4 Oct 2026 16:48:26 -0700 | |
| Subject: MIPS: Avoid dead code/data elimination when using recordmcount | |
| From: Rosen Penev <rosenp@gmail.com> | |
| [ Upstream commit 255d9dbd936f7db8b963e82429f6e57cd9d48999 ] | |
| CONFIG_LD_DEAD_CODE_DATA_ELIMINATION builds with -ffunction-sections, | |
| placing every function in its own section. recordmcount refuses to use | |
| weak symbols as section bases, as a strong definition could override | |
| them, so a weak function alone in its section, such as the generic | |
| pcibios_fixup_bus() stub, breaks the build: | |
| Cannot find symbol for section 88: .text.pcibios_fixup_bus. | |
| drivers/pci/probe.o: failed | |
| MIPS always records mcount locations with recordmcount, so this hits | |
| any config with the function tracer and dead code elimination enabled, | |
| e.g. malta_defconfig built with LLVM=1. | |
| Only offer dead code elimination when recordmcount is not used, as | |
| powerpc does since commit f8b2336f15f3 ("powerpc: Avoid dead code/data | |
| elimination when using recordmcount"). In practice this makes it | |
| unavailable together with the function tracer on MIPS. | |
| Fixes: c0436b503591 ("MIPS: Enable dead code elimination") | |
| Signed-off-by: Rosen Penev <rosenp@gmail.com> | |
| Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de> | |
| Signed-off-by: Sasha Levin <sashal@kernel.org> | |
| --- | |
| arch/mips/Kconfig | 2 +- | |
| 1 file changed, 1 insertion(+), 1 deletion(-) | |
| diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig | |
| index 57839f63074f7..5156f13ce3047 100644 | |
| --- a/arch/mips/Kconfig | |
| +++ b/arch/mips/Kconfig | |
| @@ -72,7 +72,7 @@ config MIPS | |
| select HAVE_IRQ_TIME_ACCOUNTING | |
| select HAVE_KPROBES | |
| select HAVE_KRETPROBES | |
| - select HAVE_LD_DEAD_CODE_DATA_ELIMINATION | |
| + select HAVE_LD_DEAD_CODE_DATA_ELIMINATION if !FTRACE_MCOUNT_USE_RECORDMCOUNT | |
| select HAVE_MOD_ARCH_SPECIFIC | |
| select HAVE_NMI | |
| select HAVE_OPROFILE | |
| -- | |
| 2.53.0 | |