File binutils-fix-keepdebug.diff of Package cross-m68k-binutils.24139

Fix for bsc#1191908

without this the sections in the .debug file have content, which leads
to the groups sections being adhered to (instead of being ignored) leading
to errors in crash when loading kernel modules .ko.debug files.

commit 7c4643efe7befea8e5063e8b56c0400fd8cee2d5
Author: Alan Modra <amodra@gmail.com>
Date:   Fri Jan 28 23:08:27 2022 +1030

    objcopy --only-keep-debug
    
    From: Peilin Ye <peilin.ye@bytedance.com>
    objcopy's --only-keep-debug option has been broken for ELF files since
    commit 8c803a2dd7d3.
    
      1. binutils/objcopy.c:setup_section() marks non-debug sections as
         SHT_NOBITS, then calls bfd_copy_private_section_data();
      2. If ISEC and OSEC share the same section flags,
         bfd/elf.c:_bfd_elf_init_private_section_data() restores OSEC's
         section type back to ISEC's section type, effectively undoing
         "make_nobits".
    
            * objcopy.c (setup_section): Act on make_nobits after calling
            bfd_copy_private_section_data.

Index: binutils-2.37/binutils/objcopy.c
===================================================================
--- binutils-2.37.orig/binutils/objcopy.c
+++ binutils-2.37/binutils/objcopy.c
@@ -4080,9 +4080,6 @@ setup_section (bfd *ibfd, sec_ptr isecti
       goto loser;
     }
 
-  if (make_nobits)
-    elf_section_type (osection) = SHT_NOBITS;
-
   size = bfd_section_size (isection);
   size = bfd_convert_section_size (ibfd, isection, obfd, size);
   if (copy_byte >= 0)
@@ -4176,6 +4173,9 @@ setup_section (bfd *ibfd, sec_ptr isecti
       goto loser;
     }
 
+  if (make_nobits)
+    elf_section_type (osection) = SHT_NOBITS;
+
   /* All went well.  */
   return;
 
openSUSE Build Service is sponsored by