um: Allow multiple symbol definitions for GCOV builds
PATCH 1/1 um: Allow multiple symbol definitions for GCOV builds
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.
--- arch/um/Makefile | 7 +++++++ 1 file changed, 7 insertions(+)
arch/um/Makefile +7 -0
@@ -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
Signature · 1 line
2.43.0
Johannes Berg
maintainerQuoted 5 lines · Alex Hung
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 infs/seq_file.o). This makes the link fail:
Quoted 8 lines
ld:
libgcov.a(_gcov.o): in function `mangle_path':
multiple definition of `mangle_path';fs/seq_file.o: first defined herePass --allow-multiple-definition to the linker when
CONFIG_GCOVis 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
Quoted 10 lines · Johannes Berg
Quoted 9 lines · Alex Hung
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 infs/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
Quoted 7 lines
Quoted 4 lines
Pass --allow-multiple-definition to the linker when
CONFIG_GCOVis 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
Quoted 2 lines
johannes
Johannes Berg
maintainerHi,
Quoted 11 lines · Alex Hung
Quoted 3 lines
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 renamemangle_path()toseq_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
Quoted 15 lines · Johannes Berg
Hi,
Quoted 11 lines · Alex Hung
Quoted 3 lines
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 renamemangle_path()toseq_mangle_path(). How about reviving it to avoid name conflicts instead?
Quoted 4 lines
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/[email protected]/T/#u).
I will test the series and report here later.
Johannes Berg
maintainerQuoted 17 lines · Alex Hung
Quoted 15 lines · Johannes Berg
Hi,
Quoted 11 lines · Alex Hung
Quoted 3 lines
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 renamemangle_path()toseq_mangle_path(). How about reviving it to avoid name conflicts instead?
Quoted 6 lines
Quoted 4 lines
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.
Quoted 1 line
I sure want to revive them.
Sure, sounds reasonable, feel free, of course!
Quoted 2 lines
The series may also have a solution for the other patch I sent
(https://lore.kernel.org/linux-um/[email protected]/T/#u).
That one we should just apply for ARCH=um, seems reasonable to me.
Quoted 2 lines
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
Quoted 36 lines · Johannes Berg
Quoted 17 lines · Alex Hung
Quoted 15 lines · Johannes Berg
Hi,
Quoted 11 lines · Alex Hung
Quoted 3 lines
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 renamemangle_path()toseq_mangle_path(). How about reviving it to avoid name conflicts instead?Quoted 6 lines
Quoted 4 lines
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.
Quoted 1 line
I sure want to revive them.
Sure, sounds reasonable, feel free, of course!
Quoted 2 lines
The series may also have a solution for the other patch I sent
(https://lore.kernel.org/linux-um/[email protected]/T/#u).
Quoted 7 lines
That one we should just apply for ARCH=um, seems reasonable to me.
Quoted 2 lines
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.
Quoted 2 lines
johannes
Johannes Berg
maintainerQuoted 9 lines · Alex Hung
I think the two patches are relevant today
um: fix
CONFIG_GCOVfor built-in code
seq_file: renamemangle_pathtoseq_mangle_pathI 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