See also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99488 When LTO is enabled, debug sections have names like .gnu.debuglto_.debug_* and which type is marked as PROGBITS. While normal debug info for MIPS is marked as SHT_MIPS_DWARF. So linker fails to merge the two sections, which make the output has 2 section with the same name: root@mipsel:/build/innoextract/innoextract-1.8# readelf -Wa debian/innoextract/usr/bin/innoextract | grep debug_info [32] .debug_info MIPS_DWARF 00000000 09a8c0 1b77ef 00 0 0 1 [40] .debug_info PROGBITS 00000000 4ff4b4 50302b 00 0 0 1 Let's just mark .gnu.debuglto_.debug_* as SHT_MIPS_DWARF. Index: binutils-2.36.50.20210618/bfd/elfxx-mips.c =================================================================== --- binutils-2.36.50.20210618.orig/bfd/elfxx-mips.c +++ binutils-2.36.50.20210618/bfd/elfxx-mips.c @@ -7448,7 +7448,9 @@ _bfd_mips_elf_section_from_shdr (bfd *ab break; case SHT_MIPS_DWARF: if (! startswith (name, ".debug_") - && ! startswith (name, ".zdebug_")) + && ! startswith (name, ".gnu.debuglto_.debug_") + && ! startswith (name, ".zdebug_") + && ! startswith (name, ".gnu.debuglto_.zdebug_")) return false; break; case SHT_MIPS_SYMBOL_LIB: @@ -7669,7 +7671,9 @@ _bfd_mips_elf_fake_sections (bfd *abfd, hdr->sh_entsize = sizeof (Elf_External_ABIFlags_v0); } else if (startswith (name, ".debug_") - || startswith (name, ".zdebug_")) + || startswith (name, ".gnu.debuglto_.debug_") + || startswith (name, ".zdebug_") + || startswith (name, ".gnu.debuglto_.zdebug_")) { hdr->sh_type = SHT_MIPS_DWARF;
The master branch has been updated by Nick Clifton <nickc@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9a39f7389d8971dc754e45a73128616a5346008c commit 9a39f7389d8971dc754e45a73128616a5346008c Author: YunQiang Su <yunqiang.su@cipunited.com> Date: Wed Jun 30 17:16:22 2021 +0100 Mark .gnu.debuglto_.debug_* as SHT_MIPS_DWARF PR mips/28009 * bfd/elfxx-mips.c (_bfd_mips_elf_section_from_shdr, _bfd_mips_elf_fake_sections): Mark LTO debug info as SHT_MIPS_DWARF.
Hi YunQiang, Thanks for the bug report and patch. I have now applied your patch. Cheers Nick