[PATCH] mark .gnu.debuglto_.debug_* as SHT_MIPS_DWARF

YunQiang Su yunqiang.su@cipunited.com
Thu Jun 24 08:32:44 GMT 2021


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 sections with the same name:

  # 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

This also makes dwz unhappy.

bfd/ChangeLog:
	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.
---
 bfd/elfxx-mips.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index 426f432d9d0..b3775da2c0c 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -7448,7 +7448,9 @@ _bfd_mips_elf_section_from_shdr (bfd *abfd,
       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, Elf_Internal_Shdr *hdr, asection *sec)
       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;
 
-- 
2.30.2



More information about the Binutils mailing list