* [PATCH] um: Allow multiple symbol definitions for GCOV builds
@ 2026-07-08 22:40 Alex Hung
2026-07-21 21:58 ` Johannes Berg
0 siblings, 1 reply; 8+ messages 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] 8+ messages in thread
* Re: [PATCH] um: Allow multiple symbol definitions for GCOV builds
2026-07-08 22:40 [PATCH] um: Allow multiple symbol definitions for GCOV builds Alex Hung
@ 2026-07-21 21:58 ` Johannes Berg
2026-07-21 22:23 ` Alex Hung
0 siblings, 1 reply; 8+ messages in thread
From: Johannes Berg @ 2026-07-21 21:58 UTC (permalink / raw)
To: Alex Hung, richard, anton.ivanov, linux-um; +Cc: Bhawanpreet.Lakha
On Wed, 2026-07-08 at 16:40 -0600, Alex Hung wrote:
> 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.
>
I cannot see how that would possibly result in correct behaviour (beyond
being able to link)??
johannes
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] um: Allow multiple symbol definitions for GCOV builds
2026-07-21 21:58 ` Johannes Berg
@ 2026-07-21 22:23 ` Alex Hung
2026-07-22 14:02 ` Johannes Berg
0 siblings, 1 reply; 8+ messages in thread
From: Alex Hung @ 2026-07-21 22:23 UTC (permalink / raw)
To: Johannes Berg, richard, anton.ivanov, linux-um; +Cc: Bhawanpreet.Lakha
On 7/21/26 15:58, Johannes Berg wrote:
> On Wed, 2026-07-08 at 16:40 -0600, Alex Hung wrote:
>> 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.
>>
>
> I cannot see how that would possibly result in correct behaviour (beyond
> being able to link)??
Hi Johannes,
Good point. --allow-multiple-definition silences the linker error, but
picking kernel or libgcov's mangle_path() will break the other at runtime.
I saw your previous patch
(https://lkml.iu.edu/hypermail/linux/kernel/2103.1/06604.html) to rename
mangle_path() to seq_mangle_path(). How about reviving it to avoid name
conflicts instead?
Alex
>
> johannes
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] um: Allow multiple symbol definitions for GCOV builds
2026-07-21 22:23 ` Alex Hung
@ 2026-07-22 14:02 ` Johannes Berg
2026-07-22 16:09 ` Alex Hung
0 siblings, 1 reply; 8+ messages in thread
From: Johannes Berg @ 2026-07-22 14:02 UTC (permalink / raw)
To: Alex Hung, richard, anton.ivanov, linux-um; +Cc: Bhawanpreet.Lakha
Hi,
On Tue, 2026-07-21 at 16:23 -0600, Alex Hung wrote:
> >
> > I cannot see how that would possibly result in correct behaviour (beyond
> > being able to link)??
> Good point. --allow-multiple-definition silences the linker error, but
> picking kernel or libgcov's mangle_path() will break the other at runtime.
>
> I saw your previous patch
> (https://lkml.iu.edu/hypermail/linux/kernel/2103.1/06604.html) to rename
> mangle_path() to seq_mangle_path(). How about reviving it to avoid name
> conflicts instead?
Honestly, I completely forgot about that. Looks like I ran into the
typical "nobody wants to merge it" problem ...
johannes
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] um: Allow multiple symbol definitions for GCOV builds
2026-07-22 14:02 ` Johannes Berg
@ 2026-07-22 16:09 ` Alex Hung
2026-07-22 16:14 ` Johannes Berg
0 siblings, 1 reply; 8+ messages in thread
From: Alex Hung @ 2026-07-22 16:09 UTC (permalink / raw)
To: Johannes Berg, richard, anton.ivanov, linux-um; +Cc: Bhawanpreet.Lakha
On 7/22/26 08:02, Johannes Berg wrote:
> Hi,
>
> On Tue, 2026-07-21 at 16:23 -0600, Alex Hung wrote:
>>>
>>> I cannot see how that would possibly result in correct behaviour (beyond
>>> being able to link)??
>
>> Good point. --allow-multiple-definition silences the linker error, but
>> picking kernel or libgcov's mangle_path() will break the other at runtime.
>>
>> I saw your previous patch
>> (https://lkml.iu.edu/hypermail/linux/kernel/2103.1/06604.html) to rename
>> mangle_path() to seq_mangle_path(). How about reviving it to avoid name
>> conflicts instead?
>
> Honestly, I completely forgot about that. Looks like I ran into the
> typical "nobody wants to merge it" problem ...
>
> johannes
Is there any concerns or blockers to merge them? I sure want to revive them.
The series may also have a solution for the other patch I sent
(https://lore.kernel.org/linux-um/eea36454-cbbe-4690-980d-b4ec9423f3a0@amd.com/T/#u).
I will test the series and report here later.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] um: Allow multiple symbol definitions for GCOV builds
2026-07-22 16:09 ` Alex Hung
@ 2026-07-22 16:14 ` Johannes Berg
2026-07-24 0:44 ` Alex Hung
0 siblings, 1 reply; 8+ messages in thread
From: Johannes Berg @ 2026-07-22 16:14 UTC (permalink / raw)
To: Alex Hung, richard, anton.ivanov, linux-um; +Cc: Bhawanpreet.Lakha
On Wed, 2026-07-22 at 10:09 -0600, Alex Hung wrote:
>
> On 7/22/26 08:02, Johannes Berg wrote:
> > Hi,
> >
> > On Tue, 2026-07-21 at 16:23 -0600, Alex Hung wrote:
> > > >
> > > > I cannot see how that would possibly result in correct behaviour (beyond
> > > > being able to link)??
> >
> > > Good point. --allow-multiple-definition silences the linker error, but
> > > picking kernel or libgcov's mangle_path() will break the other at runtime.
> > >
> > > I saw your previous patch
> > > (https://lkml.iu.edu/hypermail/linux/kernel/2103.1/06604.html) to rename
> > > mangle_path() to seq_mangle_path(). How about reviving it to avoid name
> > > conflicts instead?
> >
> > Honestly, I completely forgot about that. Looks like I ran into the
> > typical "nobody wants to merge it" problem ...
> >
> > johannes
>
> Is there any concerns or blockers to merge them?
I don't _think_ so, I guess it ended up mostly procedural, since it was
across different maintainers etc., and I lost interest because we
stopped trying to use gcov.
> I sure want to revive them.
Sure, sounds reasonable, feel free, of course!
> The series may also have a solution for the other patch I sent
> (https://lore.kernel.org/linux-um/eea36454-cbbe-4690-980d-b4ec9423f3a0@amd.com/T/#u).
That one we should just apply for ARCH=um, seems reasonable to me.
> I will test the series and report here later.
>
Thanks. Please just resend whatever you think should be included, maybe
first all the UML stuff separately.
johannes
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] um: Allow multiple symbol definitions for GCOV builds
2026-07-22 16:14 ` Johannes Berg
@ 2026-07-24 0:44 ` Alex Hung
2026-07-24 6:42 ` Johannes Berg
0 siblings, 1 reply; 8+ messages in thread
From: Alex Hung @ 2026-07-24 0:44 UTC (permalink / raw)
To: Johannes Berg, richard, anton.ivanov, linux-um; +Cc: Bhawanpreet.Lakha
On 7/22/26 10:14, Johannes Berg wrote:
> On Wed, 2026-07-22 at 10:09 -0600, Alex Hung wrote:
>>
>> On 7/22/26 08:02, Johannes Berg wrote:
>>> Hi,
>>>
>>> On Tue, 2026-07-21 at 16:23 -0600, Alex Hung wrote:
>>>>>
>>>>> I cannot see how that would possibly result in correct behaviour (beyond
>>>>> being able to link)??
>>>
>>>> Good point. --allow-multiple-definition silences the linker error, but
>>>> picking kernel or libgcov's mangle_path() will break the other at runtime.
>>>>
>>>> I saw your previous patch
>>>> (https://lkml.iu.edu/hypermail/linux/kernel/2103.1/06604.html) to rename
>>>> mangle_path() to seq_mangle_path(). How about reviving it to avoid name
>>>> conflicts instead?
>>>
>>> Honestly, I completely forgot about that. Looks like I ran into the
>>> typical "nobody wants to merge it" problem ...
>>>
>>> johannes
>>
>> Is there any concerns or blockers to merge them?
>
> I don't _think_ so, I guess it ended up mostly procedural, since it was
> across different maintainers etc., and I lost interest because we
> stopped trying to use gcov.
>
>> I sure want to revive them.
>
> Sure, sounds reasonable, feel free, of course!
>
>> The series may also have a solution for the other patch I sent
>> (https://lore.kernel.org/linux-um/eea36454-cbbe-4690-980d-b4ec9423f3a0@amd.com/T/#u).
>
> That one we should just apply for ARCH=um, seems reasonable to me.
>
>> I will test the series and report here later.
>>
>
> Thanks. Please just resend whatever you think should be included, maybe
> first all the UML stuff separately.
Hi Johannes,
I think the two patches are relevant today
um: fix CONFIG_GCOV for built-in code
seq_file: rename mangle_path to seq_mangle_path
I will update the patch date and add my SoB, and then send them to
mailing list, if that's okay.
>
> johannes
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] um: Allow multiple symbol definitions for GCOV builds
2026-07-24 0:44 ` Alex Hung
@ 2026-07-24 6:42 ` Johannes Berg
0 siblings, 0 replies; 8+ messages in thread
From: Johannes Berg @ 2026-07-24 6:42 UTC (permalink / raw)
To: Alex Hung, richard, anton.ivanov, linux-um; +Cc: Bhawanpreet.Lakha
On Thu, 2026-07-23 at 18:44 -0600, Alex Hung wrote:
>
>
> I think the two patches are relevant today
>
> um: fix CONFIG_GCOV for built-in code
> seq_file: rename mangle_path to seq_mangle_path
>
> I will update the patch date and add my SoB, and then send them to
> mailing list, if that's okay.
Sure. The first is probably the same as your prior RFC anyway?
I'd probably send them separately - good chance they might (need to) go
through different trees.
johannes
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-07-24 6:42 UTC | newest]
Thread overview: 8+ messages (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
2026-07-21 21:58 ` Johannes Berg
2026-07-21 22:23 ` Alex Hung
2026-07-22 14:02 ` Johannes Berg
2026-07-22 16:09 ` Alex Hung
2026-07-22 16:14 ` Johannes Berg
2026-07-24 0:44 ` Alex Hung
2026-07-24 6:42 ` Johannes Berg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox