linux-um archives
 help / color / mirror / Atom feed
* [PATCH] um: Allow multiple symbol definitions for GCOV builds
@ 2026-07-08 22:40 Alex Hung
  0 siblings, 0 replies; only message in thread
From: Alex Hung @ 2026-07-08 22:40 UTC (permalink / raw)
  To: richard, anton.ivanov, johannes, linux-um; +Cc: alex.hung, Bhawanpreet.Lakha

GCOV-enabled UML builds link GCC's libgcov into the final vmlinux
image. libgcov provides helper symbols such as mangle_path(), which
collide with kernel symbols of the same name (for example the one in
fs/seq_file.o). This makes the link fail:

  ld: libgcov.a(_gcov.o): in function `mangle_path':
  multiple definition of `mangle_path';
  fs/seq_file.o: first defined here

Pass --allow-multiple-definition to the linker when CONFIG_GCOV is set
so the final UML link succeeds while keeping the kernel-provided
definition.

Assisted-by: Copilot:Claude-Opus-4.8
Signed-off-by: Alex Hung <alex.hung@amd.com>
---
 arch/um/Makefile | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/um/Makefile b/arch/um/Makefile
index 721b652ffb65..09c8354c8b65 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -137,6 +137,13 @@ ifeq ($(CONFIG_LD_IS_BFD),y)
 LDFLAGS_EXECSTACK += $(call ld-option,--no-warn-rwx-segments)
 endif
 
+# GCC's libgcov defines symbols that can collide with UML kernel code, such as
+# mangle_path(). Allow the final link to keep the kernel definitions when GCOV
+# pulls in libgcov.
+ifdef CONFIG_GCOV
+	KBUILD_LDFLAGS += --allow-multiple-definition
+endif
+
 LD_FLAGS_CMDLINE = $(foreach opt,$(KBUILD_LDFLAGS) $(LDFLAGS_EXECSTACK),-Wl,$(opt))
 
 # Used by link-vmlinux.sh which has special support for um link
-- 
2.43.0



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-07-08 22:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-08 22:40 [PATCH] um: Allow multiple symbol definitions for GCOV builds Alex Hung

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox