[PATCH] um: Allow multiple symbol definitions for GCOV builds

Alex Hung alex.hung at amd.com
Wed Jul 8 15:40:06 PDT 2026


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 at 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




More information about the linux-um mailing list