https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122526
Peter Damianov <peter0x44 at disroot dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |peter0x44 at disroot dot org
--- Comment #5 from Peter Damianov <peter0x44 at disroot dot org> ---
I've done some debugging of this and I think it's a binutils problem, not a gcc
one.
It's (maybe?) merging the comdat sections when it shouldn't do that when doing
a relocatable link?
At least, this patch to binutils seems to fix it for me, without any further
changes to gcc:
diff --git a/bfd/coffgen.c b/bfd/coffgen.c
index 071ca0d133c..ed9ced31ec2 100644
--- a/bfd/coffgen.c
+++ b/bfd/coffgen.c
@@ -2766,6 +2766,10 @@ _bfd_coff_section_already_linked (bfd *abfd,
if (sec->output_section == bfd_abs_section_ptr)
return false;
+ /* Don't merge COMDAT sections during relocatable linking. */
+ if (bfd_link_relocatable (info))
+ return false;
+
flags = sec->flags;
if ((flags & SEC_LINK_ONCE) == 0)
return false;
I think ELF has the same problem too - but it doesn't manifest because because
ELF has comdat groups and PE doesn't (HAVE_COMDAT_GROUP is defined)