linux-um archives
 help / color / mirror / Atom feed
From: Alex Hung <alex.hung@amd.com>
To: <richard@nod.at>, <anton.ivanov@cambridgegreys.com>,
	<johannes@sipsolutions.net>, <linux-um@lists.infradead.org>
Cc: <alex.hung@amd.com>, <Bhawanpreet.Lakha@amd.com>
Subject: [PATCH] um: Allow multiple symbol definitions for GCOV builds
Date: Wed, 8 Jul 2026 16:40:06 -0600	[thread overview]
Message-ID: <20260708224006.3405038-1-alex.hung@amd.com> (raw)

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



                 reply	other threads:[~2026-07-08 22:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260708224006.3405038-1-alex.hung@amd.com \
    --to=alex.hung@amd.com \
    --cc=Bhawanpreet.Lakha@amd.com \
    --cc=anton.ivanov@cambridgegreys.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-um@lists.infradead.org \
    --cc=richard@nod.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox